2

Everything was working fine, but I did a lot of modifications and then I could get only a blank page. It was a fresh install of NGINX so I decided to delete files in /etc/nginx and to reinstall it.

apt-get purge nginx nginx-common nginx-full
apt-get install nginx nginx-common nginx-full

Now PHP files won't load and strangely I can't access the file 'test.html' which is in the document root directory (/usr/share/nginx/html).

nginx version: nginx/1.10.3

cat /etc/nginx/sites-available/default

server {
       listen 88 default_server;

       root /usr/share/nginx/html;

       index index.php index.html;

       access_log /var/log/nginx/default-access_log;
       error_log /var/log/nginx/default-error_log;

       location / {
               try_files $uri $uri/ /index.php?$args;
       }

       location ~ \.php$ {
               #try_files $uri =404;
               fastcgi_index index.php;
               fastcgi_pass php5-fpm-sock;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include /etc/nginx/fastcgi_params;
       }

cat /etc/nginx/conf.d/php5-fpm.conf

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

It's running on port 88 and I can access my NGINX web server default page by going to http://1.2.3.4:88, but if I try http://1.2.3.4:88/test.html I get "404 Not Found".

Directory listing of document root:

root@Ubuntu-14LTS-NY1:~# ll /usr/share/nginx/html
total 20
drwxr-xr-x 2 root     root 4096 May  4 16:03 ./
drwxr-xr-x 4 root     root 4096 May  4 16:02 ../
-rw-r--r-- 1 root     root  612 Jan 31 10:01 index.html
-rw-r--r-- 1 root     root   20 May  4 15:54 index.php
-rwxrwxrwx 1 www-data root   22 May  4 16:01 test.html*

And http://1.2.3.4:88/index.php opens a downloaded dialog box, instead of being displayed.

And I have the following in my /etc/php5/fpm/php.ini:

cgi.fix_pathinfo=0

I haven't modified /etc/nginx/nginx.conf.

I have found a lot of discussions on NGINX with downloading php files and I tried a lot of suggestions but I am still stuck and don't know what to do.

Bill
  • 126
  • 12
London Smith
  • 197
  • 3
  • 8
  • 1
    check error logs – Alexey Ten May 05 '17 at 11:57
  • Oh yes, I should have had that reflex! I had in `error.log`: `2017/05/05 09:15:52 [emerg] 22587#22587: bind() to [::]:88 failed (98: Address already in use)`. So I killed the 2 nginx processes which were still running whereas I had stopped the nginx service. Now everything is working again :) – London Smith May 05 '17 at 13:22
  • @LondonSmith Please answer your own question, then accept the answer in 24 hours or when allowed. Otherwise people will come in and try to help, only to find the question is answered. – Tim May 05 '17 at 19:09

1 Answers1

1

I should have had the reflex of checking for errors in the nginx log file /var/log/nginx/error.log

I had in error.log:

2017/05/05 09:15:52 [emerg] 22587#22587: bind() to [::]:88 failed (98: Address already in use). 

So I killed the 2 nginx processes kill -9 PROCESSID which were still running whereas I had stopped the nginx service.

Now everything is working again :)

London Smith
  • 197
  • 3
  • 8