Error Start Apache "php value"

72,968

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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.

Share:
72,968
David E.
Author by

David E.

Updated on September 18, 2022

Comments

  • David E.
    David E. almost 2 years

    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?

  • David E.
    David E. about 11 years
    Hi, I'am not using Plesk, using Zpanel. What I need reconfigure? Thanks
  • Jimmy
    Jimmy about 11 years
    I basically removed those lines and then an apache restart may fix it. But i had to re-configure the vhost in plesk. It is just a button, not sure the equivalent in cpanel.
  • symcbean
    symcbean about 11 years
    This is a bit disturbing. This is part of the core php - you need to jump through hoops at compile time to disable session support. And according to the manual, they are both changeable in PHP_INI_ALL (but it might be worth trying php_admin_value). Does your session handler work? Are you using mod_php?
  • David Houde
    David Houde about 11 years
    Just had this happen. Commenting out the offending lines will allow Apache to start, but removes session support among other things. Chances are mod_php was disabled. I am using Plesk also.
  • Nickool
    Nickool over 8 years
    Thank you! I went to httpd.conf and I saw that the line LoadModule php5_module pathfilename had been commented out,I just removed the # and everything is back to normal.
  • Chris Jenks
    Chris Jenks almost 6 years
    I obtained this error after an upgrade from Ubuntu 16.04 to 18.04.1. I don't know the cause and there is no modules directory, instead a mods-available and mods-enabled directory. I added symlinks for php7.2.conf and php7.2.load to mods-enabled pointing to mods-available and then apache2 was able to start.
  • Pradeep Sanjeewa
    Pradeep Sanjeewa almost 4 years
    Hi David, it resolved the issue and introduced a new one. "Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP" How can I resolve this?