When you see the error Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
, this typically occurs when Apache's PHP module isn't properly loaded. The php_value
directive is specific to the PHP Apache module (mod_php), and this error suggests Apache can't process PHP configuration directives.
First, verify your current PHP handler with:
# Check installed PHP modules
httpd -M | grep php
# Alternative check for Apache 2.4+
apachectl -M | grep php
If you don't see php5_module
or php7_module
in the output, this confirms the module isn't loaded.
Option 1: Enable mod_php
For traditional PHP setups:
# For CentOS/RHEL:
sudo yum install mod_php
# For Debian/Ubuntu:
sudo apt-get install libapache2-mod-php
Then restart Apache:
sudo systemctl restart httpd # or apache2
Option 2: Switch to PHP-FPM
If you're using PHP-FPM, you'll need to modify your virtual host configuration. Replace the php_value
directives with:
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
For the specific error with session.save_handler
, you can either:
- Move this setting to php.ini:
session.save_handler = files
- Or use
php_admin_value
instead if using PHP-FPM
If the issue persists, check:
# Verify PHP module installation
ls /etc/httpd/modules/ | grep php
# Check module loading order
grep -r "LoadModule php" /etc/httpd/
Example complete configuration for PHP-FPM users:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
ErrorLog /var/log/httpd/example.com-error.log
CustomLog /var/log/httpd/example.com-access.log combined
</VirtualHost>
If you're using CloudLinux or cPanel, you might need:
sudo /usr/local/cpanel/bin/rebuild_phpconf --available
When you see the error message Invalid command 'php_value'
in your Apache logs after a server update, it typically indicates that the PHP module isn't properly loaded in your Apache configuration. The specific error occurs because Apache doesn't recognize PHP directives when the PHP module isn't active.
First, let's verify your PHP modules and Apache configuration:
# Check loaded PHP modules
php -m
# Check Apache loaded modules
apachectl -M | grep php
The error appears because:
- The PHP Apache module (mod_php) isn't loaded
- You're using php_value directives in your Apache config without the proper module
- Your PHP configuration might have changed during the update
For traditional PHP setups with Apache:
# Install mod_php (example for CentOS/RHEL)
yum install mod_php
# Or for Debian/Ubuntu
apt-get install libapache2-mod-php
# Then restart Apache
systemctl restart apache2
If you're using PHP-FPM, you'll need to modify your configuration:
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
And move your PHP settings to php.ini instead of using php_value in Apache config.
After making changes, verify with:
apachectl configtest
systemctl restart apache2
Instead of using php_value in Apache config files, consider:
- Using .user.ini files in your web directories
- Setting values in php.ini directly
- Using ini_set() in your PHP code when appropriate
Here's a proper Apache virtual host configuration when using PHP:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# For mod_php
<IfModule mod_php7.c>
php_value session.save_handler "files"
php_value session.save_path "/var/lib/php/sessions"
</IfModule>
</VirtualHost>