I am trying to run Nginx from the source code in the user folder of my shared host with a debian-style directory structure. I get an error when trying to start the server:
[emerg] invalid number of arguments in "try_files" directive in /home/.../nginx/conf/sites-enabled/default:11
The link to which it refers is to protect PHP execution from the Nginx trap page. Here are my configuration files:
nginx.conf:
worker_processes 1; events { worker_connections 1024; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; client_max_body_size 5m; include /home/hittingsmoke/nginx/conf/mime.types; default_type application/octet-stream; gzip on; gzip_disable \"msie6\"; include /home/hittingsmoke/nginx/conf/sites-enabled/*; }
... and sites-available / default:
server { listen 12513; root /home/hittingsmoke/nginx/html/; index index.php index.html index.htm; server_name _; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/home/hittingsmoke/php-5.3/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; include fastcgi_params; }
I can not find anything wrong with my configurations. My setup is almost identical to the working installation in the Ubuntu box in which I am running. What am I doing wrong?
EDIT: with further testing, this only happens when I use the installation available for sites with inclusion in nginx.conf. If I copy / paste the contents of my sites - available / by default to my nginx.conf, everything works fine.
EDIT2: As already mentioned, if I deleted the try_files from the vhosts file, it again crashes with the same error on fastcgi_params. Here is the contents of my fastcgi_params file. It is by default:
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;
EDIT3: I made a small mistake. This is fastcgi_param, not fastcgi_param * s *, where the contiunes error after removing the try_files directive.
source share