Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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;
    }

}
share|improve this question
    
Anyways, I switched back to Apache. Nginx is not a webserver - it's proxy server. =)) –  Radio Oct 24 '12 at 9:04

1 Answer 1

up vote 1 down vote accepted

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).

share|improve this answer
    
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 –  Radio Oct 20 '12 at 20:23
    
Oops, I forgot that part. See the edited answer. –  Michael Hampton Oct 20 '12 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 '12 at 21:30
    
@HTF You should ask your own question. –  Michael Hampton Oct 22 '12 at 21:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.