Mac下apache虚拟主机配置

Mac下apache服务器配置虚拟主机,主要分为以下几个步骤:
apache的版本是2.4, 查看版本 :sudo apachectl -v

  1. 找到配置httd.conf /etc/apache2/httpd.conf
    以下注释打开,大概在228行附近
    <Directory />
        AllowOverride none
        Require all denied
    </Directory>

这儿的注释也打开,大概在517行

    Include /private/etc/apache2/extra/httpd-vhosts.conf
  1. 找到 /private/etc/apache2/extra/httpd-vhosts.conf 文件
<VirtualHost *:80>
        DocumentRoot "/data/proxy"
        ServerName test.com
	DirectoryIndex index.html index.php

        ErrorLog "/private/var/log/apache2/test.local-error_log"
        CustomLog "/private/var/log/apache2/test.local-access_log" common

        <Directory "/data/proxy">
		Options -Indexes +FollowSymlinks
                AllowOverride All
                Order allow,deny
		Allow from all
		Require all granted
        </Directory>
</VirtualHost>

ServerName是主机名,DocumentRoot是该虚拟主机的根目录,以上配置根据自己需求适当修改。

然后启动Apache, sudo apachectl restart 即可。

以上如果出现权限的问题,确保apache对 目录有访问权限。最简单粗暴额设置方法: chmod -R /data/proxy(你的具体目录) 777

posted @ 2020-04-13 23:17  码农搬用工  阅读(278)  评论(0编辑  收藏  举报