before anything i searched everywhere and tested everything but still not working i install php5-fpm and nginx when i open localhost in browser i see this page :
Welcome to nginx!
so its working now configuring php5-fpm with nginx :
/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 = /
all other lines are commented and this is the nginx conf :
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
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# allow all;
#}
}
the problem is when i try to run php files nginx will download php file instead of executing it
PHP-FPM socket permissions
Please check that the socket has proper permissions.
Probably add
listen.mode = 0660
to yourwww.conf
if the output is different.Possibly related: nginx error connect to php5-fpm.sock failed (13: Permission denied)
nginx configuration
Is this really where your files are?
What is this block supposed to do?
I'd suggest removing
try_files $uri =404;
from thelocation ~ \.php$
block.Why is the indentation of the lines in 2 and 3 different from the rest? Note that it would affect a proper configuration, but this leaves the impression that they have been carelessly pasted together. Please provide a link to the instructions you used.
You can try EasyEngine which can setup webserver with single command
Docs/wiki: https://github.com/rtCamp/easyengine/wiki
How to setup: http://www.unixmen.com/easyengine-auto-installer-script-managing-wordpress-nginx-websites-ubuntu-debian/