Linux學習筆記 13(apache 配置虛擬服務器VirtualHost)

配置VirtualHost,虛擬服務器信息

 vi /usr/local/apache/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/data/webapps/test01"
    ServerName www.test01.com
  <Directory "/data/webapps/test01">
    AllowOverride All
    Options Indexes FollowSymLinks
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/data/webapps/test02"
    ServerName www.test02.com
  <Directory "/data/webapps/test02">
    AllowOverride All
    Options Indexes FollowSymLinks
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

創建對應的web發佈內容

此時訪問對應的網址,會出現錯誤,原因是訪問的主機host無法解析對應的網址

配置訪問的主機的hosts文件

C:\Windows\System32\drivers\etc

修改httpd.conf文件

vi /usr/local/apache/conf/httpd.conf
加入如下配置:Include conf/extra/httpd-vhosts.conf

/usr/local/apache/bin/apachectl graceful

 

 

如果出現錯誤,

Forbidden

You don't have permission to access / on this server.

請參考:https://mp.csdn.net/postedit/102163009

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