apache 配置多個網站(配置虛擬主機)
阿新 • • 發佈:2019-01-01
1、配置虛擬主機需要註解掉
# DocumentRoot "F:/www"
這樣虛擬主機才會執行;配置方式:
2、在apache.conf 中解開 Virtual hosts 配置檔案。
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
3、在apache/conf/extra/ 資料夾下 開啟 httpd-vhosts.conf 配置虛擬主機:
注意 2.2 和2.4 在許可權上有點不同。
<VirtualHost *:80> //埠號
DocumentRoot "C:/www" // 虛擬目錄
ServerName www. my.com // 訪問該域名是呼叫該配置
DirectoryIndex index.php // 預設首頁
<Directory "C:/www"> // 許可權設定
Allow from all // 訪問所有檔案(PS 適用於 apache 2.2)
Require all granted //訪問所有牡目錄(PS 使用與 apache2.4)
Options Indexes // 如果沒有首頁,顯示虛擬目錄下所有檔案連結。
</Directory>
</VirtualHost>