Error from PHP log: Invalid command 'php_flag'

Post Reply
Posts: 2
Joined: Mon Sep 06, 2021 1:01 pm

I get this error:

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

It brings 500 server error when I visit URL

It is caused by my htaccess which Was working until I installed myvesta. What should I edit in PHP.ini to make this work ( I don't want to mess things up)

Htaccess code:

Code: Select all

ErrorDocument 404 /404/index.php
<Files "settings.json">  
  Order Allow,Deny
  Deny from all
php_flag  display_errors 1
php_flag  display_startup_errors 1
php_value  error_reporting 2047
User avatar
Site Admin
Posts: 932
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 8 times
Been thanked: 6 times

You can't use php_ flags in .htaccess since PHP is not in Apache but in PHP-FPM.
You can just remove those lines from .htaccess and set those values to PHP-FPM pool.d conf files - viewtopic.php?f=18&t=54

First, check what PHP version you are running on the domain.

In your SSH run:

Code: Select all

sudo /usr/local/vesta/bin/v-get-php-version-of-domain
The output will be, for example:

Code: Select all

Now we know the location of our PHP-FPM pool.d conf, it's: /etc/php/8.0/fpm/pool.d/

Let's edit your PHP-FPM pool.d conf:

Code: Select all

sudo mcedit /etc/php/8.0/fpm/pool.d/
Find the last line that begins with php_admin_flag
After that line, add:

Code: Select all

php_admin_flag[display_errors] = 1
php_admin_flag[display_startup_errors ] = 1
php_admin_value[error_reporting] = 2047
Press F2 on your keyboard and confirm saving.

Press ESC twice on your keyboard to exit the editor.

In the end, restart your PHP-FPM by running:

Code: Select all

sudo systemctl restart php8.0-fpm
(NOTE: it may be some other PHP version, depending on what PHP version your domain is using)
Post Reply