您的位置:首页 > 运维架构 > Apache

Apache配置虚拟主机

2014-04-19 17:52 295 查看
1、修改Apache主配置文件

[root@localhost ~]# vim /usr/local/apache2/conf/httpd.conf
Include conf/extra/httpd-vhosts.conf
2、修改虚拟主机文件
<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
[root@localhost two.com]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
DocumentRoot "/usr/local/apache2/htdocs/one.com"  //网页文档配置路径
ServerName www.one.com    //虚拟主机名称
ServerAlias www.1.com     //虚拟主机别名
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/usr/local/apache2/htdocs/two.com"
ServerName www.two.com
ServerAlias www.1.com
</VirtualHost>
3、创建网页配置文件
[root@localhost htdocs]# mkdir one.com two.com
[root@localhost htdocs]# cd one.com
[root@localhost one.com]# echo "This is  first page" >index.html
[root@localhost htdocs]# cd two.com/
[root@localhost two.com]# echo "This is  second page" >index.html
4、测试
[root@localhost two.com]# /usr/local/apache2/bin/apachectl restart
[root@localhost two.com]# curl www.one.com
This is  first page
[root@localhost two.com]# curl www.two.com
This is  second page


本文出自 “linux成长之路” 博客,请务必保留此出处http://linuxlovers.blog.51cto.com/6787002/1398656
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: