Home >Backend Development >PHP Tutorial >Configure PHP and virtual machine for Apache that comes with Mac

Configure PHP and virtual machine for Apache that comes with Mac

WBOY
WBOYOriginal
2016-07-29 09:06:56945browse

Operating system: OS The message is that apache starts normally

apache相关命令:

启动:sudo apachectl start

停止:sudo apachectl stop

重启:sudo apachectl restart

查看版本号:sudo apachectl -v

Configure PHP and virtual machine for Apache that comes with Mac

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 machine

1. Enter the command in the terminal: mkdir /Users/your username/Sites, add this folder As the physical storage location for the 'mysites' virtual machine.

Configure PHP and virtual machine for Apache that comes with Mac2. 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"

"/Library/WebServer/Documents"> ... and copy the content to it below; modify the yellow area to "/Users/your username/Sites", save and exit.

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

Configure PHP and virtual machine for Apache that comes with Mac

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>

Configure PHP and virtual machine for Apache that comes with MacEnter 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, 2016

Reference document: http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.html

Configure PHP and virtual machine for Apache that comes with Mac The 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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn