This clearly does not deserve a separate article on Habré, but the error may affect a large number of people, so I decided to write.
http://php.net/manual/en/configuration.file.php#configuration.file.changelog :
7.0.0 Hash marks (#) are no longer recognized as comments.
It would seem that this? Admins on the test server will detect errors in the configs and correct them quickly. But here comes one unpleasant feature of php-fpm: it refuses to start up with an incorrect php-fpm.conf
, but it will quietly start up with an incorrect php.ini
, ignoring all of its settings and using default values. The error will not be visible in the console, as it is swallowed by the service startup script, and will not be written to the php-fpm log.
If php.ini
was copied from the fifth version, and the more strict seventh parser reads it with errors - php-fpm will silently work with default values. For example, if there were used #
for comments and such a comment contains an opening bracket. Without an opening bracket, he still perceives such comments normally, despite the announcement in the changelog.
The maximum upload file size is post_max_size=8m
, expose_php
enabled, the version of PHP used in the X-Powered-By
header is used, the empty disable_functions
used to disable the potentially unsafe functions is display_errors
, display_errors
will become 1 and visitors will see the full feature page on error pages, and many more just fun
PHP maintainers in Ubuntu try to bypass this feature with the help of a crutch:
/etc/systemd/system/multi-user.target.wants/php7.0-fpm.service: ... ExecStartPre=/usr/lib/php/php7.0-fpm-checkconf ... /usr/lib/php/php7.0-fpm-checkconf: ... errors=$(/usr/sbin/php-fpm7.0 --fpm-config "$CONFFILE" -t 2>&1 | grep "\[ERROR\]" || true); ...
But the crutch does not work:
root@xenial:~# /usr/sbin/php-fpm7.0 --fpm-config /etc/php/7.0/fpm/php-fpm.conf --test PHP: syntax error, unexpected '(' in /etc/php/7.0/fpm/php.ini on line 6 [14-Sep-2016 14:24:46] NOTICE: configuration file /etc/php/7.0/fpm/php-fpm.conf test is successful root@xenial:~# /usr/lib/php/php7.0-fpm-checkconf; echo $? 0
The php7.0-fpm package from the popular ppa: ondrej / php , from which PHP 7 is usually installed on servers with ubuntu trusty or precise, does not contain such a check at all.
Total: if you are upgrading from PHP 5 to PHP 7, make sure that it did not ignore the settings in php.ini and did not start with the default values.
PS
» Ppa ticket: ondrej / php
» Php7.0-fpm in ubuntu xenial
UPD: At the request of comments posted a bug to the developers of PHP: 73099
Source: https://habr.com/ru/post/310136/
All Articles