VirtualHost 上的 PHP 不起作用但在默认网站上起作用

VirtualHost 上的 PHP 不起作用但在默认网站上起作用

我有一个 apache 服务器版本:Amazon Linux 2 上的 Apache/2.4.46。PHP 在端口 443 上运行良好。我在端口 81 上添加了另一个虚拟主机。PHP 无法在此端口上运行。

配置:

Listen 80
<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName "www.mspvl.in"
    ServerAlias "mspvl.in"
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mspvl.in [OR]
RewriteCond %{SERVER_NAME} =mspvl.in
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Listen 81
<VirtualHost *:81>
    DocumentRoot "/var/www/html/phpMyAdmin"
    ServerName "www.test.in"
    ErrorLog /var/log/httpd/vhost81_error_log
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/test.in/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/test.in/privkey.pem
</VirtualHost>

和 ...

<Directory "/var/www/html/phpMyAdmin">
    Options Indexes ExecCGI FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
    php_admin_flag engine on
</Directory>

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
</Directory>

<Directory "/var/www/html/phpMyAdmin">
    Options Indexes ExecCGI FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
    php_admin_flag engine on
</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>

IncludeOptional conf.d/*.conf
Include /etc/httpd/conf/httpd-le-ssl.conf

当我通过以下方式访问普通 html 文件时https://www.test.in:81/test.html,它确实有效。但是https://www.test.in:81/test.php产生 403 Forbidden 错误。

文件权限:

-rw-r--r--  1 ec2-user apache       52 Apr 29 08:09 test.html
-rwxr-xr-x  1 ec2-user apache       82 Apr 29 08:49 test.php

日志文件:ssl_access_log:

117.232.103.170 - - [29/Apr/2021:17:21:07 +0000] "GET /test.php HTTP/1.1" 403 199 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
117.232.103.170 - - [29/Apr/2021:17:21:07 +0000] "GET /favicon.ico HTTP/1.1" 200 22486 "https://www.test.in:81/test.php" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
117.232.103.170 - - [29/Apr/2021:17:21:27 +0000] "-" 408 - "-" "-"

日志文件vhost81_error_log:

[Thu Apr 29 17:21:07.128643 2021] [ssl:info] [pid 30312] [client 117.232.103.170:49793] AH01964: Connection to child 2 established (server www.test.in:443)
[Thu Apr 29 17:21:07.128794 2021] [ssl:debug] [pid 30312] ssl_engine_kernel.c(2353): [client 117.232.103.170:49793] AH02043: SSL virtual host for servername www.test.in found
[Thu Apr 29 17:21:07.128807 2021] [core:debug] [pid 30312] protocol.c(2341): [client 117.232.103.170:49793] AH03155: select protocol from h2,h2c,http/1.1, choices=h2,http/1.1 for server www.test.in
[Thu Apr 29 17:21:07.128812 2021] [core:debug] [pid 30312] protocol.c(2386): [client 117.232.103.170:49793] AH03156: select protocol, proposals=http/1.1 preferences=h2,h2c,http/1.1 configured=h2,h2c,http/1.1
[Thu Apr 29 17:21:07.128815 2021] [core:debug] [pid 30312] protocol.c(2404): [client 117.232.103.170:49793] AH03157: selected protocol=http/1.1
[Thu Apr 29 17:21:07.129063 2021] [ssl:info] [pid 30355] [client 117.232.103.170:24820] AH01964: Connection to child 6 established (server www.test.in:443)
[Thu Apr 29 17:21:07.129158 2021] [ssl:debug] [pid 30355] ssl_engine_kernel.c(2353): [client 117.232.103.170:24820] AH02043: SSL virtual host for servername www.test.in found
[Thu Apr 29 17:21:07.129168 2021] [core:debug] [pid 30355] protocol.c(2341): [client 117.232.103.170:24820] AH03155: select protocol from h2,h2c,http/1.1, choices=h2,http/1.1 for server www.test.in
[Thu Apr 29 17:21:07.129172 2021] [core:debug] [pid 30355] protocol.c(2386): [client 117.232.103.170:24820] AH03156: select protocol, proposals=http/1.1 preferences=h2,h2c,http/1.1 configured=h2,h2c,http/1.1
[Thu Apr 29 17:21:07.129175 2021] [core:debug] [pid 30355] protocol.c(2404): [client 117.232.103.170:24820] AH03157: selected protocol=http/1.1
[Thu Apr 29 17:21:07.169292 2021] [ssl:debug] [pid 30312] ssl_engine_kernel.c(2236): [client 117.232.103.170:49793] AH02041: Protocol: TLSv1.2, Cipher: ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
[Thu Apr 29 17:21:07.169657 2021] [ssl:debug] [pid 30355] ssl_engine_kernel.c(2236): [client 117.232.103.170:24820] AH02041: Protocol: TLSv1.2, Cipher: ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
[Thu Apr 29 17:21:07.169832 2021] [ssl:debug] [pid 30355] ssl_engine_kernel.c(383): [client 117.232.103.170:24820] AH02034: Initial (No.1) HTTPS request received for child 6 (server www.test.in:443)
[Thu Apr 29 17:21:07.170097 2021] [authz_core:debug] [pid 30355] mod_authz_core.c(818): [client 117.232.103.170:24820] AH01626: authorization result of Require all granted: granted
[Thu Apr 29 17:21:07.170103 2021] [authz_core:debug] [pid 30355] mod_authz_core.c(818): [client 117.232.103.170:24820] AH01626: authorization result of <RequireAny>: granted
[Thu Apr 29 17:21:07.170131 2021] [headers:debug] [pid 30355] mod_headers.c(900): AH01503: headers: ap_headers_error_filter()
[Thu Apr 29 17:21:07.347851 2021] [ssl:debug] [pid 30355] ssl_engine_kernel.c(383): [client 117.232.103.170:24820] AH02034: Subsequent (No.2) HTTPS request received for child 6 (server www.test.in:443), referer: https://www.test.in:81/test.php
[Thu Apr 29 17:21:07.348136 2021] [authz_core:debug] [pid 30355] mod_authz_core.c(818): [client 117.232.103.170:24820] AH01626: authorization result of Require all granted: granted, referer: https://www.test.in:81/test.php
[Thu Apr 29 17:21:07.348141 2021] [authz_core:debug] [pid 30355] mod_authz_core.c(818): [client 117.232.103.170:24820] AH01626: authorization result of <RequireAny>: granted, referer: https://www.test.in:81/test.php

请帮忙。

相关内容