这几天使用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