Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I need to make PHP execution longer, and whatever else might be a problem. I thought I'd already done so but I'm still getting gateway timeouts from my recent wordpress install. The php-fpm pool has the following configuration

[john]
user = john
group = john

listen = 127.0.0.1:9002
listen.owner = www
listen.group = www

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

php_admin_value[max_execution_time] = 300
php_admin_value[max_input_time] = 120

The syntax is okay but with scripts timing out in about 30 seconds I wonder what else I have missed. It might be overkill but I'm in a hurry and will learn later, feel free to explain, but if someone could tell me all the values I could increase to hit this problem with brute force and solve it that would be great.

share|improve this question
    
Do you have a proxy/load balancer in front of you web server? Gateway timeout is a typical error generated by proxy or load balancer (HAProxy, Pound, etc) –  lg. Sep 2 '13 at 12:10

2 Answers 2

up vote 0 down vote accepted

In /etc/php5/fpm/pool.d/www.conf add this line:

request_terminate_timeout = 180

Also, in /etc/nginx/sites-available/default add the following line to the location block of the server in question:

fastcgi_read_timeout 180;

The entire location block looks like this:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_read_timeout 180;
    include fastcgi_params;
}

Now just restart php-fpm and nginx and there should be no more timeouts for requests taking less than 180 seconds.

share|improve this answer

I'd start by setting max input and execution time manually in your php.ini instead of trying to override any setting on php-fpm or nginx.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.