mac下xampp简单虚拟主机配置
多域名,虚拟主机的配置
开启虚拟主机配置选项:
打开httpd.conf文件,找到httpd-vhosts.conf那一行,解除该行注释;
打开httpd-vhosts.conf文件
修改如下
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/htdocs"
<Directory "/Applications/XAMPP/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
如需要虚拟主机的Directory对应的路径不在“/Applications/XAMPP/htdocs”这个里面,而在桌面的某个文件夹,则须在httpd.conf找到
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
修改‘User daemon’为 ‘User 系统用户名’
在添加下面内容
<VirtualHost *:80>
ServerName localaliapp.com
DocumentRoot "/Users/loganv/Desktop/do/aliapp/webroot"
<Directory "/Users/loganv/Desktop/do/aliapp/webroot">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
如出现403,尝试chmod -R 777 /Users/loganv/Desktop/do/aliapp/
如没有真实外网域名,则需在本地
vi /etc/hosts
加一行
127.0.0.1 localaliapp.com