1

I have to define fastcgi_pass for every virtual host. How do I define it global-wise?

server {
    listen       80;
    server_name  www.domain.tld;

    location / {
        root   /home/user/www.domain.tld;
        index  index.html index.php;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/user/domain.tld$fastcgi_script_name;
        include        fastcgi_params;
    }

}
1
  • Anyways, I switched back to Apache. Nginx is not a webserver - it's proxy server. =))
    – Alex G
    Oct 24, 2012 at 9:04

1 Answer 1

1

Make a file that you can include wherever you need it. For instance:

cat > /etc/nginx/php-fpm <<EOF
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;
EOF

Then modify your location to include php-fpm; and fix the root directive (it should appear under server, not under location /; this is a common nginx misconfiguration).

4
  • How do I customize fastcgi_param SCRIPT_FILENAME /home/user/domain.tld$fastcgi_script_name; so it's not the same for every site? Also root specified under location in default nginx.conf-dist
    – Alex G
    Oct 20, 2012 at 20:23
  • Oops, I forgot that part. See the edited answer. Oct 20, 2012 at 20:32
  • Hi, Do you know if there is an option/variable for the fastcgi_pass directive to define different unix domain sockets i.e.: fastcgi_pass unix:/var/run/php-fpm/www.sock; would be something like: fastcgi_pass unix:/var/run/php-fpm/$fastcgi_socket;? `
    – HTF
    Oct 22, 2012 at 21:30
  • @HTF You should ask your own question. Oct 22, 2012 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .