我正在使用CentOS8
,并使用 bog-standard ( yum install httpd php
) 安装 apache 和 php。
我有一个/etc/httpd/conf.d/trip.mydomain.mytld.conf
如下所示的配置():
<VirtualHost *:80>
ServerName trip.mydomain.mytld
DocumentRoot /var/www/trip/public
<Directory "/var/www/trip/public">
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =trip.mydomain.mytld
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
作为健全性检查:
$ ls -la /var/www/
...
drwxr-xr-x. 10 apache root 4096 Oct 5 23:01 trip
...
$ ls -la /var/www/trip
...
drwxr-xr-x. 7 apache root 4096 Oct 6 01:07 public
...
$ ls -la /var/www/trip/public
...
-rwxr-xr-x. 1 apache root 532 Oct 5 22:04 index.php
...
为了确保它不是 SELinux,我已禁用它并重新启动了服务器,但无济于事……
无论我尝试什么,当我加载时trip.mydomain.mytld
,都会出现 403 Forbidden,并且我的日志中填充了以下内容:
AH01276: Cannot serve directory /var/www/tripwire/public: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
我有另一个使用类似配置运行的服务,我不知道这到底是什么问题——但我认为这是因为第一个配置是“默认”的,虽然我不确定这可能会导致什么问题。
如果相关的话,运行结果httpd -S
如下:
VirtualHost configuration:
*:443 is a NameVirtualHost
default server auth.mydomain.mytld (/etc/httpd/conf.d/auth.mydomain.mytld-le-ssl.conf:2)
port 443 namevhost auth.mydomain.mytld (/etc/httpd/conf.d/auth.mydomain.mytld-le-ssl.conf:2)
port 443 namevhost tripwire.mydomain.mytld (/etc/httpd/conf.d/tripwire.mydomain.mytld-le-ssl.conf:2)
*:80 is a NameVirtualHost
default server auth.mydomain.mytld (/etc/httpd/conf.d/auth.mydomain.mytld.conf:1)
port 80 namevhost auth.mydomain.mytld (/etc/httpd/conf.d/auth.mydomain.mytld.conf:1)
port 80 namevhost tripwire.mydomain.mytld (/etc/httpd/conf.d/tripwire.mydomain.mytld.conf:1)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/etc/httpd/run/" mechanism=default
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
PidFile: "/etc/httpd/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48