首页 > 代码库 > Apache虚拟主机配置
Apache虚拟主机配置
为了方面管理我这里用httpd-vhosts.conf配置文件来配置
打开[root@apache ~]# vi /usr/local/apache/conf/httpd.conf
找到Include conf/extra/httpd-vhosts.conf把#去掉使用文件生效
# Fancy directory listings
#Include conf/extra/httpd-autoindex.conf# Language settings
#Include conf/extra/httpd-languages.conf# User home directories
#Include conf/extra/httpd-userdir.conf# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf# Virtual hosts
Include conf/extra/httpd-vhosts.conf打开[root@apache ~]# vi /usr/local/apache/conf/extra/httpd-vhosts.conf添加以下内容
<VirtualHost 172.16.4.59:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache/htdocs/www.wys.com"
ServerName www.wys.com
ErrorLog "/usr/local/apache/htdocs/www.wys.com/error_log"
CustomLog "/usr/local/apache/htdocs/www.wys.com/access_log" common
</VirtualHost><VirtualHost 172.16.4.59:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/local/apache/htdocs/www.wys123.com"
ServerName www.wys123.com
ErrorLog "/usr/local/apache/htdocs/www.wys123.com/error_log"
CustomLog "/usr/local/apache/htdocs/www.wys123.com/access_log" common重启Apache
修改hosts文件
[root@apache ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 www.wys123.com
127.0.0.1 www.wys.com浏览器打开www.wys.com是否成功。
至此结束
Apache虚拟主机配置