17

After updating my vps, I get the follow error:

Failed to start apache : Starting httpd: Syntax error on line 31 of /etc/httpd/conf.d/php.conf: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration [FAILED]

Enable modules on PHP:

[PHP Modules] bz2 calendar Core ctype curl date dom ereg exif fileinfo filter ftp gd gettext gmp hash iconv imap intl ionCube Loader json libxml mbstring mcrypt mhash mysql mysqli openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar readline Reflection session shmop SimpleXML sockets SPL sqlite3 standard suhosin tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib [Zend Modules] the ionCube PHP Loader

Line relative to error:

php_value session.save_handler "files"

What does the error mean and how can I fix it?

Scott Pack
  • 15,097
David E.
  • 171

8 Answers8

14

I recently ran into this exact problem using Plesk 9.5 on CentOS.

I cannot say for sure whether it was caused by an update to Plesk, or not. The customer doesn't think any changes were made recently, but Apache failed to start with this error.

After an assesment of the system to ensure it wasn't due to a breach, I did some troubleshooting and determined that mod_php had been removed from the Apache config. After checking Plesk settings, every vhost on the box was using FastCGI and SuExec.

When using FastCGI and SuExec, you cannot change PHP directives in php.conf (FastCGI) and .htaccess (SuExec).

The customer had originally commented out the offending lines, but this broke session support for everything. The only way I was able to resolve it was to manually add mod_php back to httpd.conf.

Add the following line to the section with the other LoadModule's. Make sure the path (../modules/) matches the rest of the modules in there. Chances are good that it already exists on your system and was simply removed from the config during the update.

bash# vi /etc/httpd/conf/httpd.conf
LoadModule php5_module ../modules/libphp5.so

bash# apachectl restart

This caught me off guard, and I cannot say for sure it is the upgrade that caused the issue or whether this is the best fix. I am open for comment, but highly advise against commenting out the php directives in /etc/httpd/conf.d/php.conf as it will break stuff.

David Houde
  • 3,240
7

Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

The Apache httpd-2.4 can failed with above error if you by mistake configured it to use other mpm module than prefork (as only prefork mpm works fine with php on Linux (CentOs7/RHEL7). Correcting Apache httpd configuration to use prefork mpm will solve the issue.

  1. /etc/httpd/conf.modules.d/10-php.conf

    LoadModule php5_module modules/libphp5.so

  2. /etc/httpd/conf.modules.d/00-mpm.conf

    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

4

As commented by David previously, this is likely because the PHP mod has been disabled from Apache2.

To me, it appeared as an error when (re)starting Apache:

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

Then, inside journalctl -xe:

AH00526: Syntax error on line 31 of /etc/apache2/sites-enabled/host.conf Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

This happened when upgrading from Ubuntu 17.10 to 18.04 (and in consequence from PHP7.1 to 7.2), which apparently disabled libapache2-mod-php* completely.

On Ubuntu, the following should fix it:

sudo a2enmod php7.2
sudo systemctl restart apache2
ywarnier
  • 143
1

This could happen if you configured Apache to use other MPM than mod_prefork. Check what module is in use by httpd -V command. It should show you something like:

...
Server MPM: prefork
...

If it's not, check

/etc/httpd/conf.modules.d/00-mpm.conf

like described here and make sure the next line is present in it and uncommented:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

In case you need to use other module than mod_prefork you will have to comment or delete these lines.

0

Just comment those lines out.

I had

#php_value session.save_handler "files"
#php_value session.save_path    "/var/lib/php/session"

Then run the "reconfigure if your in Plesk, then restart apache" seemed to work fine. Had this happen after plesk update #53 10mins ago.

Scott Pack
  • 15,097
Jimmy
  • 1
0

Before running the upgrade from Atomic make a backup of file php.conf. Then after the upgrade completes overwrite the new file with the old one.

Scott Pack
  • 15,097
David E.
  • 171
0

I had the similar problem, realized that php5 module was commented, which means could not load and in phpmyadmin conf it was giving me errors because of having php_admin_value which probably was working with php5_module and it was not in place. I went to httpd.conf and uncommented:

LoadModule php5_module "c:/wamp/bin/php/php5.5.12/php5apache2_4.dll"
Nickool
  • 133
0

Edit: After implementing my comments below, I found that there was another reason I was running into this issue. The server has PHP-FPM implemented. Part of the implementation of PHP-FPM meant that /etc/httpd/conf.d/php.conf was disabled (i.e. renamed to php.conf.bak). The recent update brought in a new php.conf. As a result the PHP-FPM configuration was conflicting and causing the errors mentioned. The fix was to simply rename php.conf to something like php.conf.bak.feb2019. As a result, php.conf does not get loaded and therefore there is no conflict with php-fpm.

/// Before edit: /////

The solution for me was a combination of the answers provided here.

I noticed this error after updating an Oracle Linux 7 server that hand't been updated in a long

As suggested by @dasharathmasirkar, @davidhoude @alexlanger, the problem stems from mpm prefork config being overridden after the update.

To address this:

check /etc/httpd/conf.modules.d/00-mpm.conf and ensure that the following line is uncommented:

# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Also, make sure that the other worker mpm is commented-out so it does not conflict:

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
# LoadModule mpm_worker_module modules/mod_mpm_worker.so

Then restart apache: apachectl restart

ymdahi
  • 103