Mac 下 Apache 配置虚拟主机更改 Apache 文件路

2018-07-05  本文已影响0人  Edwinpanzzz

Mac 下自带 Apache 本来是一件很完美的事,但是由于 DocumentRoot 路径是 /Library/WebServer/Documents ,所以会出现各种权限问题(当然我只遇见了权限问题,我感觉应该会有其他问题)。拖宿舍大佬的福,通过配置 Apache 虚拟主机完美解决,这里记录一下。

进入 /etc/apache2 这个路径,找到配置文件 httpd.conf ,在文件最后添加如下代码:

<VirtualHost 127.0.0.1:80>
    ServerName mypro
    ServerAlias mypro
    DocumentRoot "/Volumes/IOS/web"
    DirectoryIndex index.html index.php
</VirtualHost>

<VirtualHost localhost:80>
    ServerName mypro
    ServerAlias mypro
    DocumentRoot "/Volumes/IOS/web"
    DirectoryIndex index.html index.php
</VirtualHost>

<Directory "/Volumes/IOS/web">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
     Require all granted
</Directory>

记住,上述几处 DocumentRoot 要改为自己的路径!

上一篇 下一篇

猜你喜欢

热点阅读