Mac OS X (El Capitan) Virtual Hosts 设置
- 发表于
- macOS
Mac OS X (El Capitan) Virtual Hosts(虚拟主机) 设置
所需用到文件:
- /Applications/XAMPP/xamppfiles/etc/httpd.conf
- /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
- /etc/hosts
httpd.conf
找到
1 2 |
# Virtual hosts # Include etc/extra/httpd-vhosts.conf |
改为:
1 2 |
# Virtual hosts Include etc/extra/httpd-vhosts.conf |
httpd-vhosts.conf
创建新的虚拟主机配置:
1 2 3 4 5 6 7 8 9 10 11 |
# My WebService host <VirtualHost *:80> ServerName webservice.local DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/api/public" <Directory "/Applications/XAMPP/xamppfiles/htdocs/api/public "> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory> ErrorLog "logs/webservice.local-error_log" </VirtualHost> |
其中webservice.local为你的解析域名
hosts file
命令:sudo nano /etc/hosts
1 2 |
# XAMPP VirtualHost mappings 127.0.0.1 webservice.local |
结束;但有部分朋友会出现
403 Error
打开/Applications/XAMPP/xamppfiles/etc/httpd.conf
1 2 3 4 5 6 |
# User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # User daemon Group daemon |
把User daemon 中的 daemon改为你的MAC的用户名即可!
参考:
http://mrgott.com/misc/20-setting-up-virtual-hosts-for-xampp-on-mac-os-x-el-capitan
原文连接:Mac OS X (El Capitan) Virtual Hosts 设置
所有媒体,可在保留署名、
原文连接
的情况下转载,若非则不得使用我方内容。