AH01071:出现错误“主要脚本未知

AH01071:出现错误“主要脚本未知

Debian Linux 8.10、Apache 版本 2.4.10、FPM/FastCGI。

我已经创建了第一个虚拟主机。几个小时后,我就可以让它工作了。然后我创建了另一个虚拟主机,配置几乎相同 => 我在浏览器中收到“文件未找到”和 404。

查看 Apache 错误日志:

AH01071: Got error 'Primary script unknown' 

我将配置文件与可以运行的 vhost 进行了并排比较,没有发现太大的差异。

/etc/php5/fpm/pool.d/152.......94.conf

[152........94]
user = vhostthatNOTworks
group = vhostthatNOTworks
listen = 8002
pm = dynamic
pm.max_children = 9999
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 5
php_admin_value[upload_tmp_dir] = /home/vhostthatNOTworks/tmp
php_admin_value[session.save_path] = /home/vhostthatNOTworks/tmp

但在工作虚拟主机上,listen = 8000

在坏的 vhsot 上:listen = 8002

此值已由 virtualmin 设置。我不知道为什么会有差异,以及它是否重要?

/etc/apache2/apache2.conf(删除了注释):

Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

可以正常运行的vhost的.conf:

<VirtualHost 188.165.53.208:80>
SuexecUserGroup vhostthatworks vhostthatworks
ServerName vhostthatworks.fr
ServerAlias www.vhostthatworks.fr
ServerAlias webmail.vhostthatworks.fr
ServerAlias admin.vhostthatworks.fr
DocumentRoot /home/spip31/public_html
ErrorLog /var/log/virtualmin/vhostthatworks.fr_error_log
CustomLog /var/log/virtualmin/vhostthatworks.fr_access_log combined
ScriptAlias /cgi-bin/ /home/vhostthatworks/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/spip31/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType application/x-httpd-php .php
</Directory>
<Directory /home/vhostthatworks/cgi-bin>
allow from all
AllowOverride All         Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.vhostthatworks.fr
RewriteRule ^(.*) https://vhostthatworks.fr:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.vhostthatworks.fr
RewriteRule ^(.*) https://vhostthatworks.fr:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8000
</FilesMatch>
</VirtualHost>
<VirtualHost 188.165.53.208:443>
SuexecUserGroup vhostthatworks vhostthatworks
ServerName vhostthatworks.fr
ServerAlias www.vhostthatworks.fr
ServerAlias webmail.vhostthatworks.fr
ServerAlias admin.vhostthatworks.fr
DocumentRoot /home/spip31/public_html
ErrorLog /var/log/virtualmin/vhostthatworks.fr_error_log
CustomLog /var/log/virtualmin/vhostthatworks.fr_access_log combined
ScriptAlias /cgi-bin/ /home/vhostthatworks/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/spip31/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
</Directory>
<Directory /home/vhostthatworks/cgi-bin>
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.vhostthatworks.fr
RewriteRule ^(.*) https://vhostthatworks.fr:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.vhostthatworks.fr
RewriteRule ^(.*) https://vhostthatworks.fr:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
SSLEngine on
SSLCertificateFile /home/bilp/SSL/domain.crt
SSLCertificateKeyFile /home/bilp/SSL/domain.key
SSLCertificateChainFile /home/bilp/SSL/intermediate.pem
SSLCACertificateFile /home/bilp/SSL/root.cer
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
<Directory /home/vhostthatworks/public_html>
Options +Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType application/x-httpd-php .php
</Directory>
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8000
</FilesMatch>
</VirtualHost>

无法正常工作的 vhost 的 .conf:

<VirtualHost *:80>
SuexecUserGroup "#1003" "#1003"
ServerName vhostthatNOTworks.fr
ServerAlias www.vhostthatNOTworks.fr
ServerAlias webmail.vhostthatNOTworks.fr
ServerAlias admin.vhostthatNOTworks.fr
DocumentRoot /home/spip31/public_html
ErrorLog /var/log/virtualmin/vhostthatNOTworks.fr_error_log
CustomLog /var/log/virtualmin/vhostthatNOTworks.fr_access_log combined
ScriptAlias /cgi-bin/ /home/vhostthatNOTworks/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/spip31/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
</Directory>
<Directory /home/vhostthatNOTworks/cgi-bin>
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.vhostthatNOTworks.fr
RewriteRule ^(.*) https://vhostthatNOTworks.fr:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.vhostthatNOTworks.fr
RewriteRule ^(.*) https://vhostthatNOTworks.fr:10000/ [R]
AddType application/x-httpd-php .php
AddType application/x-httpd-php5.6 .php5.6
<Directory /home/vhostthatNOTworks/public_html>
Options +Indexes +SymLinksifOwnerMatch +ExecCGI
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType application/x-httpd-php .php
</Directory>
RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8002
</FilesMatch>
</VirtualHost>
<VirtualHost 188.165.253.141:443>
SuexecUserGroup "#1003" "#1003"
ServerName vhostthatNOTworks.fr
ServerAlias www.vhostthatNOTworks.fr
ServerAlias webmail.vhostthatNOTworks.fr
ServerAlias admin.vhostthatNOTworks.fr
DocumentRoot /home/spip31/public_html
ErrorLog /var/log/virtualmin/vhostthatNOTworks.fr_error_log
CustomLog /var/log/virtualmin/vhostthatNOTworks.fr_access_log combined
ScriptAlias /cgi-bin/ /home/vhostthatNOTworks/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/spip31/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
</Directory>
<Directory /home/vhostthatNOTworks/cgi-bin>
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.vhostthatNOTworks.fr
RewriteRule ^(.*) https://vhostthatNOTworks.fr:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.vhostthatNOTworks.fr
RewriteRule ^(.*) https://vhostthatNOTworks.fr:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
php_admin_value engine Off
SSLEngine on
SSLCertificateFile /home/bilp/SSL/domain.crt
SSLCertificateKeyFile /home/bilp/SSL/domain.key
SSLCertificateChainFile /home/bilp/SSL/intermediate.pem
SSLCACertificateFile /home/bilp/SSL/root.cer
<Directory /home/gloriette_bilp/public_html>
Options +Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI
allow from all
AllowOverride All     Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType application/x-httpd-php .php
</Directory>
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8002
</FilesMatch>
</VirtualHost>

显然,PHP-FPM 确实监听了端口(vhostthatNOTworks 为 8000,vhostthatNOTworks 为 8002):netstat -ltnp

tcp        0      0 0.0.0.0:8001            0.0.0.0:*               LISTEN      2308/php-fpm.conf)
tcp        0      0 0.0.0.0:8002            0.0.0.0:*               LISTEN      2308/php-fpm.conf)

有人能帮我吗?

答案1

这太愚蠢了。我认为这个错误与 Virtualmin 有关,而不是与 Apache2 有关。我只需要重新启动。Apache2 重新启动不起作用。应该与 Virtualmin 处理 Apache2 的方式有关。

来源:[已解决] AH01071:出现错误“主要脚本未知\n”

答案2

我已重新启动服务器并且它已正常运行。

感谢 Lucas 和 Gerard 的帮助。

相关内容