close

在 AWS EC2 裝好基本的 LAMP 環境之後,想設一下 Apache Virtual Host 設定
結果居然無法運作,查了一下才發現在 Apache 2.4.6 (或更之前) 有對這部份的設定做了一些調整
以下是簡易的筆記

1. NameVirtualHost*:80 這行已經廢除,不用再寫了
2. 原本的 http.conf 已經預設加上 IncludeOptional conf.d/*.conf
    所以可以把 Virtual Host 的設定獨立成另一隻檔案,我習慣命名為 vhosts.conf,放在 /etc/httpd/conf.d/vhosts.conf
3. <VirtualHost> 的調整
由原本的
<VirtualHost sample.com>
        DocumentRoot  /var/www/www_sample
        ServerName sample.com
        CustomLog logs/access_log combined
        DirectoryIndex  index.php index.html index.htm index.shtml
        <Directory "/var/www/www_sample">
            Options FollowSymLinks
            AllowOverride All
        </Directory>
</VirtualHost>

改為
<VirtualHost *:80>
        DocumentRoot  /var/www/www_sample
        ServerName sample.com
        CustomLog logs/access_log combined
        DirectoryIndex  index.php index.html index.htm index.shtml
        <Directory "/var/www/www_sample">
            Options FollowSymLinks
            AllowOverride All
        </Directory>
</VirtualHost>

domain name 不用再重覆寫兩遍了!!

請參考:http://stackoverflow.com/questions/25608659/virtualhost-is-not-working-under-apache-2-4-6-on-centos-7

arrow
arrow
    全站熱搜

    wbkuo 發表在 痞客邦 留言(1) 人氣()