Find used Apache:
$ which -a httpd
/usr/local/bin/httpd
/usr/sbin/httpd
$ whereis httpd
/usr/sbin/httpd
which shows you both of your apache, whereis shows you the currently used apache
Internal Apache
- Binary:
/usr/sbin/httpd - Start/Stop:
sudo /usr/sbin/apachectl start - Version:
/usr/sbin/apachectl -v - Config:
/etc/apache2/httpd.conf
Homebrew Apache
- Binary:
/usr/local/bin/httpd(symlink to ../Cellar/httpd) - Start/Stop:
sudo /usr/local/bin/apachectl start - Version:
/usr/local/bin/apachectl -v - Config:
/usr/local/etc/httpd/httpd.conf
Homebrew Apache (Apple Silicon)
substitute /opt/homebrew for /usr/local in the group directly above. for example
- Binary:
/opt/homebrew/bin/httpd(symlink to ../Cellar/httpd) - Start/Stop:
sudo /opt/homebrew/bin/apachectl start - Version:
/opt/homebrew/bin/apachectl -v - Config:
/opt/homebrew/etc/httpd/httpd.conf
Note: For me the Internal and the Homebrew Apache are at the same Version.
Answer from nito on Stack ExchangeFind used Apache:
$ which -a httpd
/usr/local/bin/httpd
/usr/sbin/httpd
$ whereis httpd
/usr/sbin/httpd
which shows you both of your apache, whereis shows you the currently used apache
Internal Apache
- Binary:
/usr/sbin/httpd - Start/Stop:
sudo /usr/sbin/apachectl start - Version:
/usr/sbin/apachectl -v - Config:
/etc/apache2/httpd.conf
Homebrew Apache
- Binary:
/usr/local/bin/httpd(symlink to ../Cellar/httpd) - Start/Stop:
sudo /usr/local/bin/apachectl start - Version:
/usr/local/bin/apachectl -v - Config:
/usr/local/etc/httpd/httpd.conf
Homebrew Apache (Apple Silicon)
substitute /opt/homebrew for /usr/local in the group directly above. for example
- Binary:
/opt/homebrew/bin/httpd(symlink to ../Cellar/httpd) - Start/Stop:
sudo /opt/homebrew/bin/apachectl start - Version:
/opt/homebrew/bin/apachectl -v - Config:
/opt/homebrew/etc/httpd/httpd.conf
Note: For me the Internal and the Homebrew Apache are at the same Version.
Nito's answer is correct. But whereis does not give you the current apache being used. This is a better description of what whereis does. I was getting confused, as per the above comments, so I posted another question. This will help to clarify if others are in my situation.
How do I determine what version of Apache I'm using?
macos - Changing default Apache version on Mac OS - Stack Overflow
centos - How can I tell what version of apache I'm running? - Unix & Linux Stack Exchange
How do I determine what version of Apache… - Apple Community
How about in the apachectl wrapper script you stick something like this at the end.
tail -5 /var/log/httpd/error_log
you should see something like this in a normal startup
- [Fri Apr 22 23:39:20 2011] [notice] Digest: generating secret for
digest authentication ... - [Fri Apr 22 23:39:20 2011] [notice] Digest: done
- [Fri Apr 22 23:39:20 2011] [warn] pid file
/mlk/apache/pid/httpd.pid overwritten -- Unclean shutdown of previous Apache run? - [Fri Apr 22 23:39:20 2011] [notice] Apache/2.0.63 (Unix) DAV/2 configured -- resuming normal operations
Otherwise any error should at least in part be shown here. The key phrase is hilighted above.
Additional: /usr/sbin/apachectl is owned by root, you must be a privileged user to do this. sudo vi /usr/sbin/apachectl
move to the end of the file and insert this between the "esac" and "exit $ERROR" lines. ie.
esac
sleep 2; tail -5 /var/log/httpd/error_log
exit $ERROR
Note this will print out the last few lines no matter what action you take with the script, stop start, restart. you may want to only put it in the start part of the case statement.
I have the same problem on my mac. When ever I attempt to start apache and nothing happens, I immediately run this command. In my case the problem always seems to be in the apache configuration files.
apachectl configtest
You first need to find out where are those binaries stored. For this you may use the whereis command.
whereis httpd
The output will give you the different path for the files httpd like this:
httpd: /usr/sbin/httpd /usr/lib64/httpd /etc/httpd /usr/share/httpd /usr/share/man/man8/httpd.8.gz
Then, for the binaries, you can check the version using the path with the attribute -v
/usr/sbin/httpd -v
Output:
Server version: Apache/2.4.6 (CentOS)
Server built: Oct 19 2017 20:39:16
For the yum installed version, you may also use the following command:
sudo yum list installed httpd
Installed Packages
httpd.x86_64 2.4.6-67.el7.centos.6
Another last solution is to use: rpm -q httpd
You can check Apache Version in Ubuntu by using this Command -
apachectl -v
The Result will be like this -
vishal@vishal:~$ apachectl -v
Server version: Apache/2.4.41 (Ubuntu)
Server built: 2020-08-12T19:46:17