wensnort 发表于 2012-06-13 15:36

centos下面搭建apache2.2.15的虚拟主机问题,求大神解决,谢谢!

本帖最后由 wensnort 于 2012-06-13 22:34 编辑

我的linux系统版本是CentOS6.2,apache版本是2.2.15,我配置的虚拟主机为什么打不开呢,开打的都是默认主页,求大神解决,下面附配置:


为了不耽大神的时间,我修改的地方,已用绿色标注出来
etc/httpd/conf/httpd.conf 文件的详细配置


NameVirtualHost 192.168.2.158:80

<VirtualHost 192.168.2.158:80>
        ServerName www.testone.com
        DocumentRoot /home/testone
</VirtualHost>

<VirtualHost 192.168.2.158:80>
        ServerNamewww.testtwo.com
        DocumentRoot /home/testtwo
</VirtualHost>


<Directory /home>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

其他配置

# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.158 www.testone.com
192.168.2.158 www.testtwo.com
# ifconfig eth0
eth0      Link encap:EthernetHWaddr 00:0C:29:14:BA:E1
          inet addr:192.168.2.158Bcast:192.168.2.255Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe14:bae1/64 Scope:Link
          UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
          RX packets:4640 errors:0 dropped:0 overruns:0 frame:0
          TX packets:183 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1354746 (1.2 MiB)TX bytes:36431 (35.5 KiB)
          Interrupt:19 Base address:0x2024

# cd /home
# ls -l
总用量 60
-rw-r--r--.1 rootroot   85686月 13 15:07 httpd
-rw-r--r--.1 rootroot344186月 13 11:53 httpd.conf_bak
drwx------. 27 snort snort40966月 13 12:29 snort
drwxr-xr-x.2 rootroot   40966月 13 12:38 testone
drwxr-xr-x.2 rootroot   40966月 13 12:39 testtwo
# cd testone/
# ls -l
总用量 4
-rwxrwxrwx. 1 root root 216月 13 12:38 index.html
# cat index.html
this is test one web
#



启动httd是提示的错误和使用httpd -S提示的信息:

# service httpd restart
停止 httpd:                                             [确定]
正在启动 httpd:httpd: apr_sockaddr_info_get() failed for centos-2
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                         [确定]
# httpd -S
httpd: apr_sockaddr_info_get() failed for centos-2
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
VirtualHost configuration:
192.168.2.158:80       is a NameVirtualHost
         default server www.testone.com (/etc/httpd/conf/httpd.conf:1013)
         port 80 namevhost www.testone.com (/etc/httpd/conf/httpd.conf:1013)
         port 80 namevhost www.testtwo.com (/etc/httpd/conf/httpd.conf:1018)
wildcard NameVirtualHosts and _default_ servers:
_default_:443          127.0.0.1 (/etc/httpd/conf.d/ssl.conf:74)
Syntax OK
#
最后的提示




wensnort 发表于 2012-06-13 17:19

求各位大神帮帮吧,小弟弄了一个星期,始终没有搞定,要崩溃啦。。。。:'(

chenyx 发表于 2012-06-14 17:31

配置没看出来问题.楼主看下你的apache的error_log,看看里面有没有提示.
我觉得可能是权限的问题.

angerdevil 发表于 2012-06-15 17:51

目录下文件是否有权限?
应该来说是权限的问题;
关掉防火墙、selinux试试,

奔跑的糖葫芦 发表于 2012-06-16 09:04

你指定你的网页默认文档的位置了吗?
试试在虚拟主机里添加一条命令让他成为这样.<VirtualHost 192.168.2.158:80>
      ServerNamewww.testtwo.com
      DocumentRoot /home/testtwo
       Directoryindex index.html
</VirtualHost>

添加一句.Directoryindex index.html
试试

1404383934 发表于 2012-06-29 11:29

本帖最后由 1404383934 于 2012-06-29 11:29 编辑

你先把welcome.conf里面的东西注释掉,看看发生什么?

夜真灰_ 发表于 2014-02-06 21:31

我也遇到了相关的问题,我测试的结果是在默认目录下没有问题,所谓的默认目录是/var/www/html下没问题,但是自己修改网站跟目录却出现和楼主一样的问题,按照上面大神的提示,我试着关闭了防火墙,还是不行,也就是说跟防火墙没关系,最后把selinux修改成了Permissive模式,就可以了。不知道什么原因,求大神解释

夜真灰_ 发表于 2014-02-06 21:32

回复 4# angerdevil


    我也遇到了相关的问题,我测试的结果是在默认目录下没有问题,所谓的默认目录是/var/www/html下没问题,但是自己修改网站跟目录却出现和楼主一样的问题,按照上面大神的提示,我试着关闭了防火墙,还是不行,也就是说跟防火墙没关系,最后把selinux修改成了Permissive模式,就可以了。不知道什么原因,求大神解释

devon6686 发表于 2014-03-05 09:27

自定义documentroot需要修改目录及文件类型属性为httpd_sys_content_t,ll -Zd /var/www/html 可以看到这个,属于selinux范畴,关闭selinux当然也有效。
页: [1]
查看完整版本: centos下面搭建apache2.2.15的虚拟主机问题,求大神解决,谢谢!