я хочу измениться fastcgi_param
только для определенных маршрутов, как описано ниже:
server {
# (...)
# PHP entry point for main application
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 1024 4k;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Changed memory_limit for that path
location ^~ ^/rewritten_path {
# Change memory_limit only for all routes: example.com/rewritten_path/...
fastcgi_param PHP_VALUE "memory_limit=1024M \n max_execution_time=18000";
# Allow /index.php$is_args$args
try_files $uri $uri/ /index.php$is_args$args;
}
# (...)
}
Вы можете определить новое значение, используя fastcgi_param
в другом location
блок, но вам нужно будет включить полный контекст, все остальные fastcgi_param
заявления и fastcgi_pass
заявление.
Было бы проще использовать переменную в существующем location
блок. Вы можете определить переменную, используя map
. Видеть этот документ для подробностей.
Например:
map $request_uri $php_value {
default "memory_limit=756M \n max_execution_time=18000";
~^/rewritten_path "memory_limit=1024M \n max_execution_time=18000";
}
server {
...
location ... {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
include fastcgi_params;
...
fastcgi_param PHP_VALUE $php_value;
...
}
}