0

I'm using Ubuntu 13 and I've installed nginx and php5-fpm; before that I had PHP5 and apache installed; which I removed

/etc/php5/fpm/pool.d/www.conf

user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /

nginx config file :

upstream php {
    server unix:/var/run/php5-fpm.socket;
}

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.html index.htm index.php;

# Make site accessible from http://localhost/
server_name localhost;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}


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;
}
}

When I try

http://local.host/info.php

It downloads the info.php file instead of executing the file

But when I try:

http://my.ip.address/info.php

it shows the phpinfo() function

where is the problem ?

yivi
  • 42,438
  • 18
  • 116
  • 138
k961
  • 577
  • 1
  • 5
  • 19
  • I'd say you have 2 servers with the same root, try to add the `local.host` to the `server_name` and reload nginx and see if it still happens – Mohammad AbuShady Aug 05 '14 at 07:54
  • Possibly related: http://stackoverflow.com/q/23443398/2010467 Possible cross-post: http://askubuntu.com/q/507025/40581 – Benjamin Aug 08 '14 at 15:54

2 Answers2

0

You could try changing you config a bit:

server {
   listen 80;
   server_name localhost;

   root /usr/share/nginx/html;
   index index.html index.htm index.php;

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

}

and your www.conf:

listen = localhost:9000
;listen = /var/run/php5-fpm.sock
CrazySabbath
  • 1,274
  • 3
  • 11
  • 33
0

Change line to server_name localhost local.host 127.0.0.1; (are you sure http://local(dot)host is not a typo?)

Check /etc/hostnames and if it differs from above, add it in too. Also check that you dont have another entry server{ ... } entry that listens to same port 80.

Check the folder /etc/nginx/sites-enabled/, the default filename also contains server{...} parameters. The http{...} block is found in /etc/nginx/nginx.conf and sometimes may contain the server{...} block.

Alvin K.
  • 4,329
  • 20
  • 25