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

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?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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:
[import]
listen = 127.0.0.1:9001 # 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   127.0.0.1:9001;
            break;
    }
    fastcgi_pass   127.0.0.1:9000;      #default php-fpm backend
  }
  ...
}
share|improve this answer
add comment

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

Parameters:

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);

http://php.net/manual/en/function.set-time-limit.php

share|improve this answer
add comment

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.