josstech
By:
josstech

info.php starts to download instead of opening

May 13, 2014 3.5k views
HI , I setting up LEMP on Ubuntu 14.04 by using this tutorial , https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 I am also hosting 2 domain name on a single droplet . I have successfully setup Nginx virtual host . Any idea why does info.php download rather than opening. Can you guys guide me on how to troubleshoot the issue .
3 Answers
Hi Joss!

Could you post your Nginx configuration? The location block should look something like:


location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}


HI Andrew ,
please see below my Ngix configuration .

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
try_files $uri =404;
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;

is it correct ? looks the same to me , I am not sure . What do you think Andrew.
You need to uncomment the lines, as in delete the # at the beginning of each line. So it should look like this:
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000


location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

try_files $uri =404;
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
  • @kamaln7
    This is not correct:

    location ~ \.php$ {
           # With php5-cgi alone:
           fastcgi_pass 127.0.0.1:9000;
           # With php5-fpm:
           fastcgi_pass unix:/var/run/php5-fpm.sock;
    }
    

    Either cgi or fpm, not both of them

    Correct would be:

    location ~ \.php$ {
           # With php5-cgi alone:
           fastcgi_pass 127.0.0.1:9000;
           # With php5-fpm:
           #fastcgi_pass unix:/var/run/php5-fpm.sock;
    }
    

    OR

    location ~ \.php$ {
           # With php5-cgi alone:
           #fastcgi_pass 127.0.0.1:9000;
           # With php5-fpm:
           fastcgi_pass unix:/var/run/php5-fpm.sock;
    }
    
Have another answer? Share your knowledge.