I am trying to move a project to Nginx + PHP-FPM with a virtual host. But when I try to load the website, I receive a file called 'download' with the contents of the index.php.
contents of nginx.conf:
user nginx nginx; worker_processes 4; worker_rlimit_nofile 64000; error_log /var/log/nginx/error_log debug; events { worker_connections 16000; multi_accept on; use epoll; } http { log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_user_agent" ' '"$gzip_ratio"'; access_log on; disable_symlinks if_not_owner; ignore_invalid_headers on; server_tokens off; keepalive_timeout 20; client_header_timeout 20; client_body_timeout 20; reset_timedout_connection on; send_timeout 20; sendfile on; tcp_nopush on; tcp_nodelay on; include /etc/nginx/mime.types; default_type application/octet-stream; charset UTF-8; gzip on; gzip_vary on; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js image/x-icon image/bmp; server { location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/run/php-fpm.socket; fastcgi_index index.php; } } include /etc/nginx/sites-enabled/*; } contents of the vhost file:
server { listen 127.0.0.1:80; server_name yps.dev; access_log /var/log/nginx/yps.access_log main; error_log /var/log/nginx/yps.error_log debug; root /home/bobbles/projects/yps_upstream/www/public; index index.cgi index.htm index.html index.php; location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/run/php-fpm.socket; #fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } } The included fastcgi parameters:
# cat /etc/nginx/fastcgi.conf fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; the PHP-FPM pool:
[www] listen =/run/php-fpm.socket listen.owner = nginx listen.mode = 0666 user = nobody group = nobody pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 php_admin_value[error_log] = /var/log/fpm-php.www.log php_admin_flag[log_errors] = on the socket:
# ls -al /run/php-fpm.socket srw-rw-rw- 1 nginx nginx 0 Oct 12 22:12 /run/php-fpm.socket In the access logs and the error logs, there is no output except a timeout in the error log:
==> /var/log/nginx/error_log <== 2014/10/12 22:15:39 [info] 3317#0: *19 client closed connection while waiting for request, client: 127.0.0.1, server: 0.0.0.0:80 2014/10/12 22:15:39 [info] 3317#0: *20 client closed connection while waiting for request, client: 127.0.0.1, server: 0.0.0.0:80 The access log is silent.
What am I doing wrong? /var/log/fpm-php.www.log never gets created, so I assume that means that the request is never getting to php-fpm, but then what is wrong with my nginx config?
EDIT:
This is what happens when I try to access a static file from the directory:
==> /var/log/nginx/localhost.error_log <== 2014/10/12 21:16:04 [error] 3021#0: *3 openat() "/usr/share/nginx/html/email.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /email.html HTTP/1.1", host: "yps.dev" ==> /var/log/nginx/localhost.access_log <== 127.0.0.1 - - [12/Oct/2014:21:16:04 +0200] "GET /email.html HTTP/1.1" 404 410 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "3.10" ==> /var/log/nginx/yps.error_log <== 2014/10/12 21:16:23 [info] 3021#0: *4 client closed connection while waiting for request, client: 127.0.0.1, server: 0.0.0.0:80 apparently the request is simultaneously being passed to the yps virtualhost, and not.