I need to set a different timeout and execution time for a third party server that needs to import the products and prices on my database.

Right now, they are telling me the php script is timing out. This is due to my configuration on php.ini. I'd like to be able to keep that configuration for everyone as I think that's the right configuration. But I also need them to be able to execute the script.

I guess there must be a way to do this either on nginx or php-fpm configurations. Anyone knows how?


You can use the second php-fpm backend and depending on source IP pass the request to new one. These are some examples.

  1. The php-fpm config wikth required memory limit and execution timeout:
listen = # use new TCP port/socket
php_admin_value[memory_limit] = xxM
php_admin_value[max_execution_time] = xx
  1. By using ngx_http_geo_module and if directive pass to second backend:
geo $import {
 default                0;
 64.95.xx.xx            1;
 80.84.xx.xx            1;

server {
  listen 80;
  server_name example.com;
  location ~ \.php$ {
    include       fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    if ($import) {
    fastcgi_pass;      #default php-fpm backend
| improve this answer | |

You can use the function "set_time_limit()" in your scripts to set the time limit for php script execution.


seconds = The maximum execution time, in seconds. If set to zero, no time limit is imposed.

so you should be able to do this for 15 minutes: set_time_limit(900);

or this for no limit: set_time_limit(0);


| improve this answer | |

Your Answer

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

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