1

I have nginx, php5.6-fpm, setup on the default port (9000). And I have gone through several forums, SO pages and documentation to alleviate this problem, but to no avail.

The index.php file of my web-app executes as should, but all other .php files get downloaded, It appears it has to do with my rewrite-rules and not Fast Process Manager per-say, but I ca't seem to figure. Below is my site.conf

server {
listen 80 default_server;
listen   [::]:80 ipv6only=on;
server_name xx.xx.xx.xx;
root /var/www/foo.bar.com/html;


# index.php
index index.php index.html;

error_page 404 /404.php;

autoindex off;

location / {
  rewrite ^/(.*)/p/(.*)?$ /product.php?slug=$2 break;
  rewrite ^/?([A-Za-z0-9_-]+)/?$ /vendor.php?vendor=$1 break;

  if (!-e $request_filename){
  rewrite ^(.*)$ /$1.php break;
  } 

 }

 location /cart {
   rewrite ^/cart/?$ /cart.php break;
 }

 location /checkout {
   rewrite ^/checkout/?$ /checkout.php break;
 }

 location /search/ {
   rewrite ^/search/?$ /search.php break;
   rewrite ^/search/(.*)?$ /search.php?slug=$1 break;
   rewrite ^/search/brand/(.*)?$ /search.php?brandslug=$2 break;
 }

 location /brand {
  rewrite ^/brand/(.*)?$ /search.php?brand=$1 break;
 }

  location /brands {
   rewrite ^/brands/?$ /productbrands.php break;
  }

  location /404 {
    rewrite ^/404/?$ /404.php break;
  }

  location /vendors {
   rewrite ^/vendors/?$ /vendors.php break;
 }
   include  /etc/nginx/mime.types;

    # handle .php
    location ~* \.php(/|$) {
      try_files      $uri =404;
      include  /etc/nginx/mime.types;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_split_path_info ^(.+\.php)(/.*)$;
      include fastcgi_params;
      fastcgi_param  SCRIPT_FILENAME     $request_filename;
      fastcgi_param  HTTPS              off;
      include nginxconfig.io/php_fastcgi.conf;

}

  location ~ /\. {
     access_log off;
     log_not_found off; 
     deny all;
  }
  location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
     include  /etc/nginx/mime.types;
     access_log        off;
     log_not_found     off;
     expires           360d;
   }

     include nginxconfig.io/general.conf;
 }

1 Answers1

0

Please add this:

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi.conf;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/run/php/php5.6-fpm.sock;
}
AS Mackay
  • 2,831
  • 9
  • 19
  • 25
  • Did not work for me, still only executes the index page, any other linked PHP pages get downloaded. – Olubodun Agbalaya Mar 19 '19 at 11:34
  • I have written my solution on the linked question page, mine was a rewrite rule issue, apparently that can also cause nginx to download the file rather then send it along to **fcgi** @Bhupendra Dudhwal – Olubodun Agbalaya Mar 19 '19 at 21:55