虚拟主机是指一个机器上运行多个网站(例如a.example.com和b.example.com). 虚拟主机
127.0.0.1 qiu.localhost.com
/private/etc/apache2/httpd.conf
, 去掉虚拟主机配置文件前面的注释符
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
/Library/WebServer/Documents/qiu/index.php
内容如下
<?php phpinfo();
/private/etc/apache2/extra/httpd-vhosts.conf
中添加一个虚拟主机配置
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents/qiu"
ServerName qiu.localhost.com
</VirtualHost>
sudo apachectl restart
http://qiu.localhost.com/
看到php版本信息表示成功以上例子为本机环境, 线上环境将域名解析到主机ip即可