mac xampp apache php 配置

安装完xampp后,想添加一个virsualhost,一直报错。查了半天资料,都是乱说,后来看到了一篇国外的文章,终于弄出来了,整理一下。
 
第一步,配置本地hosts
sudo vi /etc/hosts
在后面添加你的域名xxx.com
127.0.0.1   xxx.com
 
第二步 启用apache的虚拟主机功能
打开配置文件 vi /Applications/XAMPP/xamppfiles/etc/httpd.conf
找到下面这一行,去掉最前面的#
#Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
 
第三步 配置虚拟主机
首先打开配置文件 vi /Applications/XAMPP/etc/extra/httpd-vhosts.conf
清空里面的内容,因为是新安装的,不清空也可以
先把localhost的virsualhost配置一下,不然会出错,一般都是卡在这里了。我的网站编辑器有问题,查看页面源码可以看到配置文件。
 
默认虚拟主机
<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>
 
然后添加自己的虚拟主机
<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还是有403错误, 就找到/Applications/XAMPP/xamppfiles/etc/httpd.conf
 
修改里面的User和Group, User修改为你的电脑的用户名, group修改为staff
也就是
#User daemon
User mac
#Group daemon
Group staff
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值