Can't get php-fpm with Nginx to work
Server: CentOs x86_64
/etc/php-fpm.d/webuser1.conf
[webuser1]
listen = 127.0.0.1:9001
listen.allowed_clients = 127.0.0.1
user = webuser1
group = webuser1
pm = dynamic
pm.max_children = 15
pm.start_servers = 3
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 2000
request_slowlog_timeout = 5
slowlog = /home/webuser1/tmp/logs/webuser1.slow.log
php_admin_value[error_log] = /home/webuser1/tmp/logs/webuser1.error.log
php_admin_flag[log_errors] = on
/etc/nginx/conf.d/web1.conf
server {
listen 80;
server_name c64p1.v.lab.gavika.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/webuser1/www/public;
index index.html index.htm index.php;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
In Nginx logs, I have:
2013/05/18 15:21:52 [error] 2943#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.122.1, server: c64p1.v.lab.gavika.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "c64p1.v.lab.gavika.com"
How can I get this to work?
Solution 1:
You have placed your root
directives in the wrong places.
root
should be defined in the server
block, not in each location
block. This is one of the most common nginx misconfigurations.
To resolve the issue, remove all of the root
directives from each location
block, and place the correct root
directive within the server
block, not within any location
.