Home >Backend Development >PHP Tutorial >Configure PHP and virtual machine for Apache that comes with Mac
Operating system: OS The message is that apache starts normally
apache相关命令: 启动:sudo apachectl start 停止:sudo apachectl stop 重启:sudo apachectl restart 查看版本号:sudo apachectl -v
2. Add the PHP module
Enter the command in the terminal: sudo vi /etc/apache2/httpd.conf, open httpd.confRemove the PHP module Comment '#' in front, restart apache, php added successfully
3. Configure the 'mysites' virtual machine1. Enter the command in the terminal: mkdir /Users/your username/Sites, add this folder As the physical storage location for the 'mysites' virtual machine.2. Open httpd.config and remove the '#' in front of "
# Include /private/etc/apache2/extra/httpd-vhosts.conf".3. Select the content between DocumentRoot
"/Library/WebServer/Documents"
Enter the command in the terminal: sudo vi /etc/apache2/extra/httpd-vhosts.conf to open httpd-vhosts.conf.
Comment the two default virtual machines and add '#' in front of each line Next, add the following code, save and exit, restart apache# 'localhost'虚拟机 <virtualhost> 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'虚拟机 <virtualhost> DocumentRoot "/Users/你的用户名/Sites" ServerName mysites ErrorLog "/private/var/log/apache2/mysites-error_log" CustomLog "/private/var/log/apache2/mysites-access_log" common </virtualhost>
Enter the command in the terminal: sudo vi /etc/ hosts, add "127.0.0.1 mysites", save and exit. Enter the command in the terminal: sudo vi /Users/your username/Sites/info.php, add "" , save and exit
Enter http://mysites/info.php in the browser
This is the end, thank you for reading! Written by Zhuoshui Qingzhou on January 12, 2016Reference document: http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.htmlThe above introduces the configuration of PHP and virtual machine for Mac's own Apache, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.