Welcome! Log In Create A New Profile

Advanced

Enabling PHP for all server blocks

Posted by abxccd 
Enabling PHP for all server blocks
December 10, 2012 12:50AM
I have successfully set up PHP to work with my nginx server using this location block:

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

The problem is that I have a lot of vhosts (server blocks for other websites) in their own config files. These are then placed in a folder called sites-enabled, which are loaded by nginx.

To enable PHP for all my vhosts, I need to put the above snippet into all the config files. Is there anyway I can ask nginx to interpret all PHP files using PHP without having to put the location block into all the server blocks?

Thank you :)
Re: Enabling PHP for all server blocks
December 12, 2012 02:17AM
You could put this block in a config file located in /etc/nginx/conf.d and include it in every vhost. So you wouldn't need the whole block in every configuration. Just one line: the include. :)
Re: Enabling PHP for all server blocks
December 12, 2012 03:29AM
Great idea! Thanks! :)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 264
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