Mac - Apache

mac

How did I install Apache onto my MacBook?

Apache is already pre-installed on my MacBook. I tried using the below commands to install Apache before I realized that it was pre-installed.

  1. brew install homebrew/apache/httpd24
  2. mkdir -p ~/Library/LaunchAgents
  3. ln -sfv /usr/local/opt/httpd24/*.plist ~/Library/LaunchAgents
  4. launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd24.plist
  5. Edit the /usr/local/etc/apache2/2.4/httpd.conf

How can we configure the pre-installed Apache to start automatically?

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

How can we prevent the pre-installed Apache from starting automatically?

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Where is the configuration file for the pre-installed Apache?

/etc/apache2/httpd.conf
/private/etc/apache2/other

Where are the log files generated by the pre-installed Apache?

/private/var/log/apache2

What is the default DocumentRoot used by the pre-installed Apache?

/Library/WebServer/Documents

How can we check the syntax of the configuration file?

/usr/sbin/httpd -S
apachectl configtest

How can we stop Apache?

apachectl stop

How can we start Apache?

apachectl start
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License