apache2.4.27配置虛擬主機

1:在httpd.conf中,把這行打開

Include conf/extra/httpd-vhosts.conf

2:進到conf/extra/裏,修改httpd-vhosts.conf


原文件是這樣的

<VirtualHost *:80>

    ServerAdmin [email protected] (郵箱)

    DocumentRoot "/web/www1" (發佈目錄)

    ServerName www.luo.com (域名)

    ServerAlias www.luo2.com (這可配置多域名)

    ErrorLog "logs/dummy-host.example.com-error_log" (日誌)

    CustomLog "logs/dummy-host.example.com-access_log" common(日誌)

</VirtualHost>


<VirtualHost *:80>

    ServerAdmin [email protected]

    DocumentRoot "/web/www2"

    ServerName www.luo1.com

    ErrorLog "logs/dummy-host2.example.com-error_log"

    CustomLog "logs/dummy-host2.example.com-access_log" common

</VirtualHost>


這樣配置好後還是打不開,顯示無權限

乍一看沒有問題,可是在apache-2.4.37下這樣配置完,無權限訪問。根據提示查看了目錄以及文件的權限問題,沒有問題;查看程序錯誤日誌和系統日誌也沒有明顯的錯誤;這時冷靜下來好好想了想,目錄及文件權限沒有問題,那剩下就是站點目錄訪問權限了,於是在虛擬主機配置文件裏面的虛擬主機配置後加這麼一段

<Directory "/data/webapps/www2">

    AllowOverride All

    Options Indexes FollowSymLinks Includes ExecCGI

    Order allow,deny

    Allow from all


配置文件如下


<VirtualHost *:80>

    ServerAdmin [email protected]

    DocumentRoot "/web/www1"

    ServerName www.luo.com

    ServerAlias www.luo2.com

    ErrorLog "logs/dummy-host.example.com-error_log"

    CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

<Directory "/web/www1">

    AllowOverride All

   Options Indexes FollowSymLinks Includes ExecCGI

    Order allow,deny

    Allow from all


<VirtualHost *:80>

    ServerAdmin [email protected]

    DocumentRoot "/web/www2"

    ServerName www.luo1.com

    ErrorLog "logs/dummy-host2.example.com-error_log"

    CustomLog "logs/dummy-host2.example.com-access_log" common

</VirtualHost>

<Directory "/web/www2">

    AllowOverride All

    Options Indexes FollowSymLinks Includes ExecCGI

    Order allow,deny

    Allow from all


經過以上的修改後,重啓Apache服務,現在可以正常訪問

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章