您好,登錄后才能下訂單哦!
apache-2.4.12基于域名訪問的多虛擬主機配置
原始配置:
<VirtualHost *:80>
ServerAdmin kk@etiantian.org
DocumentRoot "/data/cms"
ServerName www.etiantian.org
ServerAlias etiantian.org
ErrorLog "logs/www.etiantian.org-error_log"
CustomLog "logs/www.etiantian.org-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kk@etiantian.org
DocumentRoot "/data/bbs"
ServerName bbs.etiantian.org
ErrorLog "logs/bbs.etiantian.org-error_log"
CustomLog "logs/bbs.etiantian.org-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kk@etiantian.org
DocumentRoot "/data/blog"
ServerName blog.etiantian.org
ErrorLog "logs/blog.etiantian.org-error_log"
CustomLog "logs/blog.etiantian.org-access_log" common
</VirtualHost>
以上的基于域名訪問的多虛擬主機配置大家能看出錯在哪嗎?乍一看沒有問題,可是在apache-2.4.12下這樣配置完,訪問出現403錯誤,無權限訪問。根據提示查看了目錄以及文件的權限問題,沒有問題;查看程序錯誤日志和系統日志也沒有明顯的錯誤;這時冷靜下來好好想了想,目錄及文件權限沒有問題,那剩下就是站點目錄訪問權限了,于是在虛擬主機配置文件里面的虛擬主機配置前加入這么一段:
<Directory "虛擬主機站點目錄">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
再些修改虛擬主機配置文件如下:
<Directory "/data">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin kk@etiantian.com
DocumentRoot "/data/cms"
ServerName www.etiantian.org
ServerAlias etiantian.org
ErrorLog "logs/www.etiantian.org-error_log"
CustomLog "logs/www.etiantian.org-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kk@etiantian.com
DocumentRoot "/data/bbs"
ServerName bbs.etiantian.org
ErrorLog "logs/bbs.etiantian.org-error_log"
CustomLog "logs/bbs.etiantian.org-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin kk@etiantian.com
DocumentRoot "/data/blog"
ServerName blog.etiantian.org
ErrorLog "logs/blog.etiantian.org-error_log"
CustomLog "logs/blog.etiantian.org-access_log" common
</VirtualHost>
經過以上的修改后,重啟apache服務,現在可以正常訪問,呵呵,大功能告成!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。