0

I'm inexperienced in Linux systems and now trying to configure Nginx + Nodejs server. First of all trying to make it work and configure fast-cgi php for phpMyAdmin. When I use the default "/usr/share/nginx/html" directory. Everything is working fine, but when I change the root directory to "/home/ftpuser/web/public", I got "no input file specified" error in the browser. Hovewer my test page is a simple html...

My nginx config file is the following:

server {

      listen  80 default_server;

  server_name _;

      #root /home/ftpuser/web/public;
      root /usr/share/nginx/html;
      index index.html index.htm index.php;

      location / {

        try_files maintenance.html $uri $uri/index.html $uri/index.php;

      }

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

      location @node {
    error_page 405 = @backend;
        add_header X-Cache "HIT from Backend";
        proxy_pass http://212.24.106.170:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        #proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
      }
}

I have no clue what is wrong. I just guessing maybe it is something permission issue? Does anyone has an idea what is the problem?

UPDATE:

Based on nginx error.log, it is a pretty permission issue:

[crit] 32338#0: *1 stat() "/home/ftpuser/badgirlz/public//index.html" failed (13: Permission denied), client: 78.92.44.152, server: _, request: "GET / HTTP/1.1", host: "domain.com"

I have made the following:

chown -R nginx:nginx /home/ftpuser/web/public
chmod -R 755 /home/ftpuser/web/public

However it is still not solved the issue...

Zsoca
  • 358
  • 1
  • 5
  • 16
  • Did you look at eg. [NGINX - No input file specified. - php Fast/CGI](http://stackoverflow.com/questions/21377321/nginx-no-input-file-specified-php-fast-cgi) already or the other SO Q&A pages popping up, when one "searches" fo say "nginx no input file specified" ;-) ? – Dilettant Jun 22 '16 at 21:57
  • It's not working and anyway as I wrote, I have simple html file in the other directory, so even if there would be a php problem it should work for simple html page, but I got the above message. That's the strange thing... – Zsoca Jun 22 '16 at 22:12
  • ... ok maybe then: [Nginx 403 forbidden for all files](http://stackoverflow.com/questions/6795350/nginx-403-forbidden-for-all-files) ... otherwise I'd suggest to use stat/ls -l on the folder, and check the nginx logs ... maybe update the question ... HTH – Dilettant Jun 22 '16 at 22:18
  • It seems like nginx cannot read the file so it defaults to $uri/index.php which cannot be read by php-fpm either. Could this be an SELinux issue? – Richard Smith Jun 23 '16 at 09:05
  • I don't think so. When I type 'getenforce' it's returned with 'Disabled'. So SELinux is disabled if I'm correct. – Zsoca Jun 23 '16 at 17:19

1 Answers1

0

Take a look on your logs:

[crit] 32338#0: *1 stat() "/home/ftpuser/badgirlz/public//index.html" failed (13: Permission denied),

and

chown -R nginx:nginx /home/ftpuser/web/public chmod -R 755 /home/ftpuser/web/public

You're changing permission for the wrong folder I believe. Try:

chown -R nginx:nginx /home/ftpuser/
chmod -R 755 /home/ftpuser/

Take a look here for more info about file permissions on Linux, it may help you.

Valentin
  • 89
  • 2