簡體   English   中英

Apache 遷移到虛擬主機

[英]Apache moving to virtual hosts

希望從每台機器的單個 apache/網站轉移到每台機器的多個虛擬主機設置時獲得一些指導。

當前設置:帶有從源代碼安裝的軟件包的 LAMP 堆棧:Apache 2.4.2、php 5.4.3 和 mysql 5.1.63 對於當前的單站點 (site1.ie) 設置,我有虛擬主機詳細信息、DocumentRoot 和 Directory 指令指向httpd.conf 中當前站點的 site1 documentroot。

為了啟用虛擬主機,我取消了 Include conf/extra/httpd-vhosts.conf 的注釋,並將虛擬主機站點配置詳細信息移到 httpd-vhosts.conf 中。 像這樣的東西:

<VirtualHost _default_:443>
ServerName http://site1.ie
DocumentRoot "/usr/local/apache2/htdocs/site1"
ServerAlias site1.ie
</VirtualHost>

當我取消注釋 httpd.conf 文件中的 DocumentRoot 詳細信息並重新啟動 httpd 時,我在嘗試加載 site1.ie 時收到 403 forbidden 錯誤。

httpd-vhosts.conf 中的目錄指令(從 httpd.conf 移出):

<Directory "/usr/local/apache2/htdocs/site1">
    Options Indexes FollowSymLinks
    AllowOverride AuthConfig
    Require all granted
</Directory>

編輯:

httpd 中的 error_log 給出了這個錯誤:AH01630:客戶端被服務器配置拒絕:/usr/local/apache2/htdocs/

這是網站數據的位置是否由該目錄指令控制:

<Directory />
    AllowOverride none
    Require all denied
</Directory>

據我所知,這是拒絕訪問此文件夾但允許通過自己的目錄指令訪問其子文件夾的默認設置?

發生 403 問題的點是當我注釋掉主 httpd.conf 文件中的 DocumentRoot 並在 virtualhost 指令(在 httpd.conf 文件或 httpd-vhosts.conf 文件中)定義 DocumentRoot 時。

我暫時將目錄/指令(如上所示)更改為 Require all allowed ,這消除了 403 錯誤,但我所使用的只是默認的 apache 'It works' 頁面。 我仍然無法訪問為 site1 定義的 documentroot 目錄。

有人會指出我做錯了什么嗎?

我想你會在這個網站上找到你的答案。

這是可能導致您出現問題的事項清單。

我相信您的標簽需要位於標簽內的 vhosts 文件中才能使其工作,因為您已在 httpd.conf 文件中啟用了虛擬主機,例如:

<VirtualHost *:443>
    ServerName site1.ie
    ServerAlias site1.ie
    DocumentRoot "/usr/local/apache2/htdocs/site1"
    <Directory "/usr/local/apache2/htdocs/site1">
        Options Indexes FollowSymLinks
        AllowOverride AuthConfig
        Require all granted
    </Directory>
</VirtualHost>

還可以考慮向 httpd.conf 添加變量,以便您可以在一個位置進行調整,如下所示:

Define INSTALL_DIR d:/wamp64
Define SRVRPATH ${INSTALL_DIR}/usr/local/apache2/htdocs

這將允許您更改上面的第一個代碼塊

    DocumentRoot "/usr/local/apache2/htdocs/site1"
    <Directory "/usr/local/apache2/htdocs/site1">

    DocumentRoot "${SRVRPATH}/site1"
    <Directory "${SRVRPATH}/site1">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM