Nginx serves .php files as downloads, instead of executing them -


i installing website in droplet (digital ocean). have issue install nginx php properly. did tutorial https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 when try run .php file it's downloading it... example... http://5.101.99.123/info.php it's working but... if go main http://5.101.99.123 it's downloading index.php :/

any idea?

-rw-r--r--  1 agitar_user www-data   418 jul 31 18:27 index.php -rw-r--r--  1 agitar_user www-data    21 aug 31 11:20 info.php 

my /etc/nginx/sites-available/default

server {         listen 80 default_server;         listen [::]:80 default_server ipv6only=on;          root /var/www/html;         index index.html index.htm index.php;          # make site accessible http://localhost/         server_name agitarycompartir.com;                 location ~ \.php$ {                     fastcgi_split_path_info ^(.+\.php)(/.+)$;     #               # note: should have "cgi.fix_pathinfo = 0;" in php.ini     #     #               # php5-cgi alone:     #               fastcgi_pass 127.0.0.1:9000;     #               # php5-fpm:                     fastcgi_pass unix:/var/run/php5-fpm.sock;                     fastcgi_index index.php;                     include fastcgi_params;             }                 location / {                      try_files $uri $uri/ =404;                     # uncomment enable naxsi on location                     # include /etc/nginx/naxsi.rules             } 

... others "location" commented (#)

try this:

  1. edit /etc/nginx/sites-available/default

  2. uncomment both listen lines make nginx listen on port 80 ipv4 , ipv6.

    listen   80; ## listen ipv4; line default , implied listen   [::]:80 default_server ipv6only=on; ## listen ipv6 
  3. leave server name alone

    # make site accessible (...) server_name localhost; 
  4. add index.php index line

    root /usr/share/nginx/www; index index.php index.html index.htm; 
  5. uncomment location ~ .php$ {}

    # pass php scripts fastcgi server listening on (...) # location ~ \.php$ {         try_files $uri =404;         fastcgi_split_path_info ^(.+\.php)(/.+)$;         # note: should have "cgi.fix_pathinfo = 0;" in php.ini          # php5-cgi alone:         #fastcgi_pass 127.0.0.1:9000;         # php5-fpm:         fastcgi_pass unix:/var/run/php5-fpm.sock;         fastcgi_index index.php;         include fastcgi_params; } 
  6. edit /etc/php5/fpm/php.ini , make sure cgi.fix_pathinfo set 0

  7. restart nginx , php5-fpm (if don't know how it, restart server)

i have started using linux week ago, hope on this. using nano text editor edit files. run apt-get install nano if don't have it. google on know more.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -