天天看點

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, 也要給上權限。