Welcome! Log In Create A New Profile

Advanced

Config to apply specific PHP values to specific WP directory

Posted by plutocrat 
Config to apply specific PHP values to specific WP directory
February 17, 2023 02:23AM
Hi,
Running a WP site under nginx. There is a requirement to increase the script timeout value (max_execution_time) as an operation on the site is timing out. I'd rather not increase that value for all parts of the site, as it increases the risk of DDoS attacks, so what I'd like to do is only increase it for the wp-admin directory, where users will be logged in and can be held accountable.

Current PHP config stanza is:

location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
if (!-e $document_root$document_uri){return 404;}
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
add_header "Access-Control-Allow-Origin" $http_origin;
}
(sorry, can't work out how to format code)
So would the correct modification. be as follows?

location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
if (!-e $document_root$document_uri){return 404;}
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
location /wp-admin/ {
fastcgi_read_timeout 600;
fastcgi_param PHP_VALUE "max_execution_time=180;";
}
add_header "Access-Control-Allow-Origin" $http_origin;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready