Reference Address:
Http://www.codesec.net/view/244646.html
Apache Related commands:
Start: sudo apachectl start
Stop: sudo apachectl stop
Restart: sudo apachectl restart
View version number: sudo apachectl-v
2. Add PHP Module
Enter command in terminal: sudo vi/etc/apache2/httpd.conf, open httpd.conf
Remove the comment ' # ' from the front of the PHP module and restart apache,php add success
3. Configure ' Mysites ' virtual machine
1. In the terminal input command: mkdir/users/your user name/sites, add this folder as the physical storage location for the ' mysites ' virtual machine.
2. Open the httpd.conf and remove the ' # ' in front of ' # include/private/etc/apache2/extra/httpd-vhosts.conf '.
3. Select DocumentRoot "/library/webserver/documents" <directory "/library/webserver/documents" > ... </Directory > Copy the contents to the bottom of it, modify the yellow area to "/users/your username/sites" and save the exit.
In the terminal input command: sudo vi/etc/apache2/extra/httpd-vhosts.conf, open httpd-vhosts.conf.
Note Two default virtual machines with ' # ' in front of each line
Next, add the following code, save the exit, restart Apache
# ' localhost ' virtual machine
<virtualhost *:80>
DocumentRoot "/library/webserver/documents"
ServerName localhost
Errorlog "/private/var/log/apache2/localhost-error_log"
Customlog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost>
# ' mysites ' virtual machine
<virtualhost *:80>
DocumentRoot "/users/Your user name/sites"
ServerName mysites
Errorlog "/private/var/log/apache2/mysites-error_log"
Customlog "/private/var/log/apache2/mysites-access_log" common
</VirtualHost>
In Terminal input command: sudo vi/etc/hosts, add "127.0.0.1 mysites", Save exit
In the terminal input command: sudo vi/users/your username/sites/info.php, add "<?php echo phpinfo ();?>", Save exit
Enter http://mysites/info.php in the browser
Configure PHP and virtual machines for your Mac's own Apache