The Apache server comes with your Mac, and if you need to use the Apache server on your Mac, you only need to configure and start the server.
The Apache version that comes with Mac 10.10 is 2.4
The Apache version that comes with Mac 10.9 is 2.2
1. Start the server
Open terminal and enter sudo apachectl start.
After booting, enter http://localhost in the browser to see "It works!"
Common commands:
Start server: sudo apachectl start
Shutdown server: sudo apachectl stop
Restart server: sudo apachectl restart
2. Configure Personal Sites
The Apache configuration file that comes with Mac is placed in the/etc/apache2/directory
- Open/etc/apache2/httpd.conf, find the following lines, remove the opening #
LoadModule Userdir_module libexec/apache2/mod_userdir.soinclude/private/etc/apache2/extra/httpd-userdir.conf
- Open the/etc/apache2/extra/httpd-userdir.conf, find the following, and remove the # number from the beginning
Include/private/etc/apache2/users/*.conf
- Under the/etc/apache2/users folder, create a Fengquan. conf profile (what your user name is, and what the red part says). Write the following in the file: ( Fengquanbelow, change your username)
<"/users/fengquan/sites/"> Options Indexes multiviews AllowOverride None require all granted</Directory>
- Create a ~/sites folder and create a index.html under the folder, and write something in it.
- Restart the Apache server. sudo apachectl restart
3. Support PHP
Open the/etc/apache2/httpd.conf, find the following, remove the previous # number
LoadModule Php5_module libexec/apache2/libphp5.so
Restarting the server
4. Permissions issues
Mac 10.9, apache2.2, control permissions are used
<"/users/fengquan/sites/"> Options Indexes multiviews allowoverride None Order allow,deny allow from all</Directory>
Mac 10.10, apache2.4, CONTROL permission changed to
<"/users/fengquan/sites/"> Options Indexes multiviews allowoverride None require all granted</Directory>
Enjoy yourself!
MAC 10.10 Apache Server Configuration