[問題] 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