Welcome! Log In Create A New Profile

Advanced

Re: Should we add php-fpm for each Virtual Host or in Global Configuration ?

Anoop Alias
August 12, 2015 04:22AM
Please see http://nginx.org/en/docs/http/ngx_http_core_module.html#location

location should be in a server or location context .So you cannot define it
outside of all the server context's.

One thing you can do is define a single location block for php and include
it in every server context which will save you the trouble of adding it
everytime.

But note that in real life you may need to change the fastcgi_pass to
different pools defined in php-fpm to separate php process based on user
etc.



On Wed, Aug 12, 2015 at 8:07 AM, sunzeal <nginx-forum@nginx.us> wrote:

> This is my configuration for my Virtual Host. I am not sure, but is this
> the
> ideal way of defining things ?
>
> For every domain / sub-domain, i'm adding a location ~/.php directive.
> Should i add it in the global nginx.conf itself instead of specifying
> individually for each domain i add ?
>
> Sample Configuration :-
>
>
> server {
> listen 80;
> server_name example.com;
>
> location / {
> root /var/www/example.com;
> index index.php;
>
> }
>
>
> location ~ \.php$ {
> root /var/www/example.com/;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> # fastcgi_read_timeout 30000;
> # fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
> fastcgi_param SCRIPT_FILENAME $request_filename;
> include fastcgi_params;
> }
>
> server {
> listen 80;
> server_name www.example.net;
>
> location / {
> root /var/www/example.net/;
> index index.php;
>
> }
>
>
> location ~ \.php$ {
> root /var/www/example.net/;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> # fastcgi_read_timeout 30000;
> # fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
> fastcgi_param SCRIPT_FILENAME $request_filename;
> include fastcgi_params;
> }
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,260943,260943#msg-260943
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



--
*Anoop P Alias*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Should we add php-fpm for each Virtual Host or in Global Configuration ?

sunzeal August 11, 2015 10:37PM

Re: Should we add php-fpm for each Virtual Host or in Global Configuration ?

Anoop Alias August 12, 2015 04:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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