How to use the "php_admin_value" flag in virtualhost via PHP-FPM on a specific Virtual Host?

Asked

Viewed 357 times

1

I decided to replace Apache2handler with PHP-FPM on my server. After this change, I tried running sudo apache2ctl configtest and I got the following mistake:

AH00526: Syntax error on line 53 of /etc/apache2/apache2.conf: Invalid command 'php_admin_value', Perhaps misspelled or defined by a module not included in the server Configuration Action 'configtest' failed. The Apache error log may have more information.

I know it is possible to make this adaptation through the file www.conf PHP FPM, but the point is I need it to work for a specific virtualhost, not for everyone.

Example:

#/etc/apache2/sites-avaliable/projeto_x.conf

<Directory /home/servidor/projeto_x>
    php_admin_value open_basedir /home/servidor/projeto_x
AllowOverride All
</Directory>

How can I do this configuration via PHP FPM for a specific Vhost?

1 answer

1

NOTE: I do not know if I understood right, maybe this right, if not comment to delete the wrong answer, or if I can delete this line.

1 - Create a group and a user for this host (will serve to identify which site/ system receives this host)

I used 'test' as an example.

2 - Create an exlusive conf file for this site/project

sudo vim /etc/php5/fpm/pool.d/teste.conf

And in this file:

[teste]
user = teste
group = teste
listen = /var/run/php5-fpm-teste.sock
listen.owner = www-data
listen.group = www-data
php_admin_value[disable_functions] = comando1,comando2
php_admin_flag[allow_url_fopen] = off
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /

3 - Restart php-fpm

sudo service php5-fpm restart

4 - By now you must be running a 'test' process, use the command below to find out:

ps aux |grep teste
  • I think your answer is correct, since in FPM PHP does not run with Apache, but runs via "communication", so there is no way to configure "phpflags" directly via Virtualhosts, you have to configure in FPM. I haven’t tested your answer yet, but it’s very likely to be the right way to FPM.

  • I believe you are correct too, I used this because in the same system I needed to lock and release the shell_exec, only divided into two hosts that are not well hosts, and disabled in one and the other not, it worked right.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.