1. Open "terminal (terminal)", enter sudo apachectl-v, this command shows Apache version 2, open Apache, enter sudo apachectl start, open, enter vi/etc/hosts, view 1 27.0.0.1 corresponds to localhost, enter localhost in the browser address bar to display it works! Description Apache open successfully, Apache root directory is located under "/library (Resource library)/webserver/documents/"
The installation directory for Apache is:/etc/apache2/,etc is hidden by default. You can enter "OPEN/ETC" in terminal to open
3. Setting up a virtual host
- Run "" At Terminal
sudo vi /etc/apache2/httpd.conf
to open the Apche configuration file
- Find "" In httpd.conf
#Include /private/etc/apache2/extra/httpd-vhosts.conf
, click ' i ', go to edit mode, remove the previous " #
" comment, turn on the virtual host function, then press ' ESC ', then ' shift ' + ': ' Input ': Wq.
- Run "
sudo apachectl restart
", after restarting Apache, the virtual Host Configuration feature is turned on.
- Run "
sudo vi /etc/apache2/extra/httpd-vhosts.conf
", the configuration virtual host file httpd-vhost.conf is opened and the virtual host is configured.
- Locate the Set up virtual host sample, and comment out the # number before adding
- Add your own virtual host configuration, such as, where 80 is the port number, servername for the project to open in the browser name, documentroot as the file path, if the Laravel framework, the path to public, the following two items are error log and user log path settings.
7, set the host file, command line input ' vi/etc/hosts ', add servername to 127.0.0.1, such as this project, add 127.0.0.1 mch.rrd.com 8, restart Apache server, command line input ' sudo AP Achectl Restart ' 9, browser input servername you can see the project in the browser! Reference for configuring a virtual host in Mac OS X
Mac OSX Virtual Host configuration