11

I searched allot here on serverFault and found this solution...

Including this in virtual host should work:

  php_admin_flag register_argc_argv = On
  php_value max_execution_time = 1000
  php_value session.gc_maxlifetime = 15000
  php_admin_flag magic_quotes_gpc = on

But than it dawned me, I'm not using mod_php at all. I have php-fpm installed. And I really cannot find any information if my method will work, or if there is an alternative way...

So, what do I do if I've php-fpm and would like to have different settings for virtualhost?

S.

5
  • Why would you ever want magic quotes? Those are evil.
    – Nathan C
    May 24 '13 at 10:56
  • @NathanC I know, but script author was even rude enough to tell me: "Yes all requirements are needed, that is why they are requirements."
    – user113400
    May 24 '13 at 13:29
  • If only it were possible to fire that script author.
    – Nathan C
    May 24 '13 at 13:30
  • @NathanC yeah, I hate snobby developers :) only if I had time, I would develop it myself :S
    – user113400
    May 24 '13 at 13:32
  • Yes da opp 0pu66996 9 6 79
    – sbrattla
    Jun 1 '18 at 20:28
8

On php-fpm, you usually set this in the fpm pool of the domain. The pools are included from php-fpm's main conf-file, which is located on my server at /etc/php/fpm-php5.3/php-fpm.conf:

...

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ; 
;;;;;;;;;;;;;;;;;;;;

include=/var/www/*/conf/fpm-pool.conf

In the fpm-pool-config, you can set php_admin_flag and php_admin_value like this:

...

;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'. 
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
php_flag[display_errors]            = on
php_admin_value[error_log]          = /var/www/cloud/logs/php_err.log
php_admin_flag[log_errors]          = on
php_admin_value[memory_limit]       = 1024M
#php_value[max_execution_time]       = 30
php_admin_value[upload_max_filesize] = 4G
php_admin_value[post_max_size]      = 4.2G
php_admin_value[max_input_time]     = 3600
php_admin_value[max_execution_time] = 3600
5

I had a RAM-hungry server and wanted to avoid configuring multiple pools for each of the low-traffic sites I was running. I also didn't like the security concerns of directory-based .user.ini’s, so I implemented a different solution using php.ini "sections":

http://php.net/ini.sections

You can define sections of php.ini (in my case, /etc/php5/fpm/php.ini) that are either path, or host, specific. At the bottom, I have:

[HOST=host1.example.com]
auto_prepend_file = '/var/www/something'

[HOST=host2.example.net]
upload_max_filesize = 5M

I read elsewhere that if you use the host method, you must use the specific value defined in ServerName in the VirtualHost config, not any of the aliases.

P.S. This was all done on Debian Jessie 8.4

1

You can include these flags in an .htaccess file under each virtual host that you want these settings. See: http://www.php.net/manual/en/configuration.file.per-user.php

2
  • 1
    Isn't this possible only with mod_php? I've php-fpm installed.
    – user113400
    May 24 '13 at 13:30
  • From what I've read, this is the method to accomplish it with php-fpm. mod_php allows the directives to be in your httpd.conf.
    – Nathan C
    May 24 '13 at 13:31
0

For nginx use this solution:

Since PHP 5.3.3 you can use this command in your nginx-vhost-file.

Example for setting the maxlifetime of sessions:

server {
    listen 80;
    listen [::]:80;

    ...

    location ~ \.php$ {
        ...

        fastcgi_param PHP_VALUE "session.gc_maxlifetime=604800";
        fastcgi_param PHP_VALUE "session.cookie_lifetime=604800";
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy