发布于 2014-10-27 07:41:37 | 3677 次阅读 | 评论: 2 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

XAMPP PHP开发集成软件包

XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建 XAMPP 软件站集成软件包。这个软件包原来的名字是LAMPP,但是为了避免误解,最新的几个版本就改名为 XAMPP 了。它可以在Windows、Linux、Solaris、M ac OS X 等多种操作系统下安装使用,支持多语言:英文、简体中文、繁体中文、韩文、俄文、日文等。


本文为大家讲解的是如何在Mac系统下配置xampp集成环境的虚拟主机(vhost),感兴趣的同学参考下。
 
先在hosts文件里加入virtual host的域名,指向127.0.0.1 我一般使用的命名规则是dev-domainname.com

sudo nano /private/etc/hosts  

 

# VirtualHosts Mapping  

127.0.0.1 dev-domainname.com  


接下来配置Apache,打开Apache的配置文件 /Applications/XAMPP/etc/httpd.conf
 
搜索 “Virtual hosts”

# Virtual hosts  

# Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf  

 
把第二行注释打开,让Apache去读虚拟主机的配置文件

# Virtual hosts  

Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf  


在以上httpd-vhosts.conf里添加Virtual Host的配置

    # localhost  
    <VirtualHost *:80>  
        ServerName localhost  
        DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"  
        <Directory "/Applications/XAMPP/xamppfiles/htdocs">  
            Options Indexes FollowSymLinks Includes execCGI  
            AllowOverride All  
            Require all granted  
        </Directory>  
    </VirtualHost> 

    # My custom host  
    <VirtualHost *:80>  
        ServerName mysite.local  
        DocumentRoot "/Users/yourusername/path/to/your/site"  
        <Directory "/Users/yourusername/path/to/your/site">  
            Options Indexes FollowSymLinks Includes ExecCGI  
            AllowOverride All  
            Require all granted  
        </Directory>  
        ErrorLog "logs/mysite.local-error_log"  
    </VirtualHost> 

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


最新网友评论  共有(2)条评论 发布评论 返回顶部
麻花 发布于2016-09-07 10:25:29
完美解决 多谢!
支持(0)  反对(0)  回复
PHPERZ网友 发布于2015-03-19 09:59:13
我用的是最新版的mac系统,经验证,会提示Access forbidden!

You don\'t have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.

Error 403

a1.com
Apache/2.4.10 (Unix) OpenSSL/1.0.1j PHP/5.6.3 mod_perl/2.0.8-dev Perl/v5.16.3
支持(3)  反对(0)  回复

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务