XAMPP on Mac 配置 Virual Host

来源:互联网 发布:淘宝卖家申请直播 编辑:程序博客网 时间:2024/05/31 13:14
先在hosts文件里加入virtual host的域名,指向127.0.0.1 我一般使用的命名规则是dev-domainname.com
[python] view plaincopy在CODE上查看代码片派生到我的代码片
  1. sudo nano /private/etc/hosts  

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. # VirtualHosts Mapping  
  2. 127.0.0.1 dev-domainname.com  

接下来配置Apache,打开Apache的配置文件 /Applications/XAMPP/etc/httpd.conf

搜索 “Virtual hosts”
[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. # Virtual hosts  
  2. # Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf  

把第二行注释打开,让Apache去读虚拟主机的配置文件
[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. # Virtual hosts  
  2. Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf  

在以上httpd-vhosts.conf里添加Virtual Host的配置
[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. # localhost  
  2. <VirtualHost *:80>  
  3.     ServerName localhost  
  4.     DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"  
  5.     <Directory "/Applications/XAMPP/xamppfiles/htdocs">  
  6.         Options Indexes FollowSymLinks Includes execCGI  
  7.         AllowOverride All  
  8.         Require all granted  
  9.     </Directory>  
  10. </VirtualHost>  

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. # My custom host  
  2. <VirtualHost *:80>  
  3.     ServerName mysite.local  
  4.     DocumentRoot "/Users/yourusername/path/to/your/site"  
  5.     <Directory "/Users/yourusername/path/to/your/site">  
  6.         Options Indexes FollowSymLinks Includes ExecCGI  
  7.         AllowOverride All  
  8.         Require all granted  
  9.     </Directory>  
  10.     ErrorLog "logs/mysite.local-error_log"  
  11. </VirtualHost>  

重启Apache,访问dev-domainname.com出现403错误,在httpd.conf里面搜索User Deamon,把deamon改成OS的用户名,重启Apache,就可以了。


转载:http://blog.csdn.net/alexjames_83/article/details/40505893
0 0
原创粉丝点击