Ricky Spanish
New Member
I created another thread about nginx and decided to use dotdeb to install it. Now I am trying to get php to work and all I get is a 502 error. I already had nginx installed so I skipped the first part but I followed this guide: https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-debian-7
This is my /etc/nginx/sites-available/default file:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# 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_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
But if I go to http://my-ip-address/phpinfo.php it just downloads the page. I've restarted nginx and php5-fpm services. I have Googled and looked at other documentation and guides and I cant figure this out.
In the DigitalOcean tutorial it says:
This is my /etc/nginx/sites-available/default file:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# 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_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
But if I go to http://my-ip-address/phpinfo.php it just downloads the page. I've restarted nginx and php5-fpm services. I have Googled and looked at other documentation and guides and I cant figure this out.
In the DigitalOcean tutorial it says:
But does not specify what it is that may need to be changed.Change the correct lines in “location ~ \.php$ {“ section
Last edited by a moderator: