天天看点

Mac Apache2.4 相关配置

前提: mac 自带apache 

1. mac 10.13 自带的Apache 为2.4.28, 所以不需要再去下载了;

2. apache 所在位置 : /etc/apache2/httpd.conf  vhosts文件位置 : /etc/apache2/extra/httpd-vhost.sconf

3.  配置文件在做修改之前的先备份,防止改烂了,不知道怎么办;

4. httpd.conf

    <Directory />

        AllowOverride All

        Require all denied

    </Directory>

   将AllowOverride 后面的修改成All ,开启mod_rewrite.so 模块;

    # Virtual hosts // 开启虚拟主机

    Include /private/etc/apache2/extra/httpd-vhosts.conf

5. httpd-vhosts.conf 

    注意你的apache的版本,httpd -v 可查看apache版本

    网上多是apache2.2 版本的配置,2.4 不能使用。(这里有坑)

    2.4 vhosts虚拟主机配置:

    <VirtualHost *:80>

        DocumentRoot "目录路径"

        ServerName xxxx

        ErrorLog "/private/var/log/apache2/web-error_log"

        CustomLog "/private/var/log/apache2/web-access_log" common

        <Directory "目录路径">

        Options Indexes FollowSymLinks MultiViews

        AllowOverride None

        Require all granted

        </Directory>

    </VirtualHost>

    修改hosts文件 

    位置 /etc/hosts

    添加 127.0.0.1   虚拟主机名称

   修改项目文件夹的权限, 找到项目文件夹的根文件夹,递归修改权限。 (这里有坑)

    某些项目项目可能可能会产生runtime, 也要给上权限。