Skip to content

macOS Apache

/Library/WebServer/Documents
/Users/username/Sites

Enabling the Web Server

Command to Enable the Web Server

In Mountain Lion, the Web Sharing checkbox in System Preferences > Sharing is gone. Instead, do the following:

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


sudo apachectl start also enables the launchd daemon.
It overrides the Disabled key in /System/Library/LaunchDaemons/org.apache.httpd.plist by modifying /private/var/db/launchd.db/com.apple.launchd/overrides.plist, just like launchctl load -w.

Note

For http://localhost/~username/ to work, you have to create /etc/apache2/users/username.conf and add a <Directory> directive like this:

<Directory "/Users/username/Sites/">
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

or add in FollowSymLinks to avoid having issues when hosting WordPress sites in the folder:

<Directory "/Users/username/Sites/">
    Options FollowSymLinks Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Apache Web Server - Keep the Webserver on on After Restart

sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool false

http://reviews.cnet.com/8301-13727_7-57481978-263/how-to-enable-web-sharing-in-os-x-mountain-lion/

Adding Virtual Hosts

sudo vim /etc/apache2/extra/httpd-vhosts.conf

Tuts

Apps