0
votes

This is the nginx config file in Ubuntu 16.04.4 LTS:

server {
    listen 80 default_server;

    root /var/www/html/public;
    index index.html index.htm index.php;
    server_name _;

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

        location ~ \.php$ {

                fastcgi_pass unix:/var/run/php/site.com.sock;
                fastcgi_param SCRIPT_FILENAME 
                $document_root$fastcgi_script_name;
                include fastcgi_params;
                include snippets/fastcgi-php.conf;
        }

}

When visiting the site i get: No input file specified.

/var/run/php/site.com.sock exists:

root MainTest /var/run/php ls -la /var/run/php/
total 4
drwxr-xr-x  2 www-data www-data   80 Dec 28 19:22 .
drwxr-xr-x 27 root     root     1080 Dec 28 21:54 ..
srw-rw----  1 www-data www-data    0 Dec 28 19:22 site.com.sock
-rw-r--r--  1 root     root        5 Dec 28 19:22 php7.2-fpm.pid

this is the /var/log/nginx/error.log

*7 FastCGI sent in stderr: "Unable to open primary script: /var/www/html/public/index.php (No such file or directory)" while reading response header from upstream, client: xx.xxx.xx.xxx, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/site.com.sock:", host: "xxx.xx.xxx.xxx"

index.php in /var/www/html/public/

/var/www/html/public$ ll
total 44
drwxrwxr--  3 www-data www-data 4096 Dec 28 21:49 ./
drwxrwxr-- 15 www-data www-data 4096 Dec 28 19:12 ../
drwxrwxr--  5 www-data www-data 4096 Dec 28 18:24 assets/
-rwxrwxr--  1 www-data www-data 5430 Dec 28 18:24 favicon.ico*
-rwxrwxr--  1 www-data www-data   53 Dec 28 18:24 google99e8c056471b6988.html*
-rwxrwxr--  1 www-data www-data  636 Dec 28 18:24 .htaccess*
-rwxrwxr--  1 www-data www-data 1823 Dec 28 20:12 index.php*
-rwxrwxr--  1 www-data www-data   24 Dec 28 18:24 robots.txt*
-rwxrwxr--  1 www-data www-data 5113 Dec 28 18:24 sitemap.xml*

nginx is running

root MainTest ~ service nginx status
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-12-28 21:54:07 UTC; 1h 4min ago
     Docs: man:nginx(8)
  Process: 29788 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 29697 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS)
  Process: 29798 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 29794 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 29801 (nginx)
    Tasks: 2
   Memory: 2.0M
      CPU: 31ms
   CGroup: /system.slice/nginx.service
           ├─29801 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
           └─29802 nginx: worker process                           

Dec 28 21:54:07 MainTest systemd[1]: Starting A high performance web server and a reverse proxy server...
Dec 28 21:54:07 MainTest systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
Dec 28 21:54:07 MainTest systemd[1]: Started A high performance web server and a reverse proxy server.

I have been through every line of code with detail but did not find anything, hopfuly someone will see the issue.

Thanks.

1
Stack Overflow is a site for programming and development questions. You should use another site on the Stack Exchange network for this question. - jww

1 Answers

-1
votes

Can you verify that there is an index.php in /var/www/html/public/. That is a non-standard root. Can you also verify that the user nginx is running as had access to that folder