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 ?

2

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.