配置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.