NGINX FASTCGI/PHP - Primary script unknown while reading response header from upstream, client -


i have development box each user has www folder in home dir. nginx hosting dirs http://ip address/username. , works great. want php working in same fashion.

/etc/nginx/sites-available-default:

server {         listen 80 default_server;         listen [::]:80 default_server ipv6only=on;         #root /usr/share/nginx/html;         #index index.html index.htm;         # make site accessible http://ip address/         server_name ip address;         #location ~ ^/(.+?)(/.*)?$ {         location ~ ^/(.+?)(/.*)?$ {                 # first attempt serve request file,                 # directory, fall displaying 404.                 #try_files $uri $uri/ =404;                 # uncomment enable naxsi on location                 # include /etc/nginx/naxsi.rules                 alias /home/$1/www$2;                 index  index.html index.htm index.php;                 include /etc/nginx/php.fast.conf;                 autoindex on;         } 

php.fast.conf file:

location ~ \.php$ {         fastcgi_split_path_info ^(.+?\.php)(/.*)?$;         fastcgi_pass unix:/var/run/php5-fpm.sock; #       fastcgi_pass 127.0.0.1:9000;         fastcgi_index index.php; #       fastcgi_param script_filename $document_root$fastcgi_script_name;         fastcgi_param script_filename /home/$1/www$2$fastcgi_script_name;         include /etc/nginx/fastcgi_params;  } 

as can see have tried few variations seem continue receive following error in log: *1 fastcgi sent in stderr: "primary script unknown" while reading response header upstream, client.

when attempting render simple php info page page displays "file not found"

other info: server = ubuntu 14.x latest nginx digital ocean droplet

thanks in advance.

server {         listen 80 default_server;          root /var/www/html;          # add index.php list if using php         index index.php index.html index.htm index.nginx-debian.html;          server_name _;          location ~* \.php$ {             fastcgi_pass unix:/var/run/php5-fpm.sock;             fastcgi_split_path_info ^(.+\.php)(/.+)$;             try_files $fastcgi_script_name =404;              fastcgi_param script_filename $document_root$fastcgi_script_name;             set $path_info $fastcgi_path_info;             fastcgi_param path_info $path_info;              fastcgi_index index.php;             include fastcgi_params;         }          location / {                 # first attempt serve request file,                 # directory, fall displaying 404.                 try_files $uri $uri/ =404;         }          location ~* ^/(.+?)/www(/.*|/|)$ {                 root /home;                 index index.php index.html;                  fastcgi_pass unix:/var/run/php5-fpm.sock;                  # regex split $uri $fastcgi_script_name , $fastcgi_path                 fastcgi_split_path_info ^(.+\.php)(/.+)$;                  # check php script exists before passing                 try_files $fastcgi_script_name =404;                  fastcgi_param script_filename $document_root$fastcgi_script_name;                  # bypass fact try_files resets $fastcgi_path_info                 # see: http://trac.nginx.org/nginx/ticket/321                 set $path_info $fastcgi_path_info;                 fastcgi_param path_info $path_info;                  fastcgi_index index.php;                 include fastcgi_params;         }          location ~* ^/(.+?)(/.*|/|)$ {                 index index.php index.html;                 try_files $uri $uri/ @home;         }          location @home {                 rewrite ^/([^/]+?)$ /$1/www/ last;                 rewrite ^/(.+?)(/.*|/)$ /$1/www$2 last;         }  } 

the cons of config, can't use uri /<anything_you_want>/www.

maybe helps. it's weird, non-optimized , ugly config.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -