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

sunzeal nginx-forum at nginx.us
Wed Aug 12 02:37:41 UTC 2015


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



More information about the nginx mailing list