fedora 27 httpd 500错误

我只是将我的fedora从26升级到了27。我注意到的第一件事是我用于testing的本地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文件的虚拟主机没有这样的问题。 我不明白什么是错的。

这是问题。

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

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

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

简单的解决方法是将.htaccess中的所有php_value设置移动到与.htaccess文件相同的目录中的名为.user.ini的文件中。

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

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

.user.ini文件只能被读取一次。

这意味着任何.user.ini文件的更改都需要popupFPM。

弹跳 – 停止+重新启动…所以…

 service php7.1-fpm restart