[问题] CentOS 7 的httpd (问题已解)

楼主: hirokofan (笠原弘子 命!)   2018-07-31 19:28:38
这几天使用CentOS 7 安装一个网站,档案放在/var/www/html/aaaa
跑起来很正常(此时用 htt p://IP/aaaa/ 连上)
但是在我使用VirtualHost处理后却一直出现400 bad request
负责连上去的主机在/etc/hosts增加
192.168.0.213 aaaa.test.tw
192.168.0.213 aaaa_bbbb.test.tw
服务器这边
localhost的DN是 aaaa.test.tw,指到/var/www/html
VirtualHost的DN是 aaaa_bbbb.test.tw,指到/var/www/bbbb
(预期还要增加cccc dddd eeee....)
状况以alias过的phpmyadmin来说
htt p://192.168.0.213/phpmyadmin 正常
htt p://aaaa.test.tw/phpmyadmin 正常
htt p://aaaa_bbbb.test.tw/phpmyadmin 400 bad request
因为资料夹在mv之前网站是可以正常运作的,因此应该不是权限的问题
LOG的部份有写到指定的档案中,因此设定档是有被读进去的
测试一直失败于是一直调设定档重开服务
有时localhost的纪录写到VirtualHost那边
有时VirtualHost的纪录写到localhost去
不变的是只要连到aaaa_bbbb.test.tw就会400 bad request
还请有经验的人指导一下orz
VirtualHost.conf的设定
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/bbbb
ServerName "aaaa_bbbb.test.tw"
#ServerName aaaa.test.tw
#ServerAlias aaaa_bbbb.test.tw
CustomLog logs/bbbb_access.log combined
ErrorLog logs/bbbb_error.log
LogLevel warn
<Directory "/var/www/bbbb">
DirectoryIndex index.html index.php
Options MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
httpd.conf一开始没有动,因为测试一直没成功也改了一堆,
这里贴的是一开始的状态
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin [email protected]
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
#EnableMMAP off
EnableSendfile on
IncludeOptional conf.d/*.conf
作者: axuiolji (泰)   2018-08-01 07:16:00
SElinux有开吗?有开有可能是它在搞鬼,用ls -Z看一下你/var/www/aaa跟bbb的context有没有相同
楼主: hirokofan (笠原弘子 命!)   2018-08-01 07:21:00
SElinux已经关了如果把bbbb移到/var/www/html/下面,只要VirtualHost的设定上去,会连/var/www/html/底下的东西都连不上因此VirtualHost的设定是有作用但是不知道有什么问题

Links booklink

Contact Us: admin [ a t ] ucptt.com