Currently, I need to put
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
}
in each and every site that I need to run PHP files.
Is there a way to just put it in a “master”, so that all sites won’t have duplicate copies of the same directive?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
yes like so:
for more details see http://nginx.org/en/docs/ngx_core_module.html#include
In other words where you had:
you’d now have:
and a seperate file /etc/ningx/php-master.conf with as content
It doesn’t actually shorten the code in the serverblock much (as the included bit is just 1 line). But it still yields the advantage that you can now change your php settings in 1 place (say you move your fastcgi handler to a different port or ip)