Fedora 27 httpd 500 错误

Fedora 27 httpd 500 错误

我刚刚将 Fedora 从 26 升级到 27。我注意到的第一件事是我用于测试目的的本地 Apache 服务器返回了 500 错误。

这是我的 httpd.conf 中标记我的虚拟主机的部分

<VirtualHost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin [email protected]
  ServerName  social.loc
  ServerAlias social.loc


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.php
  DocumentRoot /var/www/html/social/public_html
  <Directory "/var/www/html/social/public_html">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>


  # Custom log file locations
  LogLevel warn
  ErrorLog  /var/www/html/social/logs/error.log
  CustomLog /var/www/html/social/logs/access.log combined

</VirtualHost>

这是我的sudo systemctl 状态 httpd

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           └─php-fpm.conf
   Active: active (running) since Wed 2017-11-15 15:46:52 EET; 16min ago
     Docs: man:httpd.service(8)
 Main PID: 25238 (httpd)
   Status: "Total requests: 189; Idle/Busy workers 100/0;Requests/sec: 0.195; Bytes served/sec: 176 B/sec"
    Tasks: 214 (limit: 4915)
   CGroup: /system.slice/httpd.service
           ├─25238 /usr/sbin/httpd -DFOREGROUND
           ├─25240 /usr/sbin/httpd -DFOREGROUND
           ├─25241 /usr/sbin/httpd -DFOREGROUND
           ├─25245 /usr/sbin/httpd -DFOREGROUND
           ├─25246 /usr/sbin/httpd -DFOREGROUND
           └─25247 /usr/sbin/httpd -DFOREGROUND

Nov 15 15:46:52 localhost-localdomain systemd[1]: Starting The Apache HTTP Server...
Nov 15 15:46:52 localhost-localdomain httpd[25238]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf/httpd.conf:318
Nov 15 15:46:52 localhost-localdomain httpd[25238]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::dc3a:73be:897d:78c
Nov 15 15:46:52 localhost-localdomain systemd[1]: Started The Apache HTTP Server.

这是错误日志的最后几行:

[Wed Nov 15 15:46:01.665637 2017] [core:alert] [pid 22868:tid 140354590287616] [client 127.0.0.1:59752] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.679234 2017] [core:alert] [pid 22870:tid 140354615301888] [client 127.0.0.1:59754] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.684910 2017] [core:alert] [pid 22872:tid 140354691000064] [client 127.0.0.1:59756] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.693358 2017] [core:alert] [pid 22872:tid 140354657429248] [client 127.0.0.1:59758] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.699123 2017] [core:alert] [pid 22870:tid 140354606909184] [client 127.0.0.1:59760] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.704081 2017] [core:alert] [pid 22868:tid 140354581894912] [client 127.0.0.1:59762] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.708729 2017] [core:alert] [pid 22870:tid 140354581731072] [client 127.0.0.1:59764] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.714027 2017] [core:alert] [pid 22870:tid 140354481280768] [client 127.0.0.1:59766] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.720273 2017] [core:alert] [pid 22872:tid 140354649036544] [client 127.0.0.1:59768] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Wed Nov 15 15:46:01.725542 2017] [core:alert] [pid 22870:tid 140354598516480] [client 127.0.0.1:59770] /var/www/html/social/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

显然问题出在 .htaccess 文件的某个地方,其内容如下:

php_value auto_prepend_file /var/www/html/social/public_html/php/autoload.cfg.php

其他具有不同 .htaccess 文件的虚拟主机没有这样的问题。我不明白出了什么问题。

答案1

问题就在这里。

假设您正在运行 PHP-7.1 作为示例。

当 PHP 由 libapache2-mod-php7.1 处理时,.htaccess 中的 php_value 设置由该模块处理。

当 PHP 由 FPM 处理时,所有 PHP 都会从 Apache 代理/转发到 FPM + Apache 不再有 php_value 的处理程序。

简单的解决方法是将所有 php_value 设置从 .htaccess 移至与 .htaccess 文件位于同一目录中的名为 .user.ini 的文件中。

.htaccess + .user.ini 文件进程之间有一个主要区别。

每个请求都会读取 .htaccess 文件。

.user.ini 文件仅读取一次。

这意味着对任何 .user.ini 文件的任何更改都需要弹回 FPM。

弹跳-停止+重新启动...所以...

service php7.1-fpm restart

相关内容