CentOS - nginx - no input file specified

December 14, 2013 16.7k views
I followed this tutorial (https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-6) and everything worked perfectly. However when I want to change my site's root, I get the message 'no input file specified'. Compared to the tutorial I change 2 lines: location / { root /home/username/www/laravel/public; ... } And location ~ \.php$ { root /home/username/www/laravel/public; ... } I want my root to be there because I want to be able to access my webapp with ftp. Any ideas what's going wrong? Should be something small I guess?
11 Answers
Please pastebin your nginx config.Try looking in the error logs for pointers on what's going on:
tail /var/log/nginx/error.log
Ok I have a couple of lines like this one:
[error] 9594#0: *9 FastCGI sent in stderr: "Unable to open primary script: /home/webstudions/www/laravel/public/info.php (No such file or directory)" while reading response header from upstream, client:, server: _, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://", host: "www.appstudions.be"

but doing:
$ cd /home/webstudions/www/laravel/public/
$ ls

my nginx config: http://pastebin.com/amnzFgUk
Hmm. What's the output of
stat /home/webstudions/www/laravel/public/info.php
Your server_name directive looks problematic. Change it to your domain name or your server's IP address. Also, do you have one of these files index index.php index.html index.htm in the /home/webstudions/www/laravel/public directory?

"... I want to be able to access my webapp with ftp."

FTP is very insecure. SFTP is easier to use (b/c you do not have to install & configure and FTP server) and is much more secure. See How To Use Filezilla to Transfer and Manage Files Securely on your VPS or How To Use SFTP to Securely Transfer Files with a Remote Server.
by Justin Ellingwood
SFTP is a secure way to transfer files between local and remote servers. Much more secure than FTP, this protocol uses an SSH tunnel to establish a connection and uses encryption to transfer files in an interactive session.
stat /home/webstudions/www/laravel/public/info.php
Gives the following output:
File: `/home/webstudions/www/laravel/public/info.php'
Size: 22 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 262167 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 500/webstudions) Gid: ( 500/webstudions)
Access: 2013-12-14 13:14:21.683000223 +0000
Modify: 2013-12-14 13:14:21.683000223 +0000
Change: 2013-12-14 14:14:43.779999877 +0000
Changing my server_name wasn't necessary for the tutorial to work and changing it now doesn't make a difference either.
It just changes the error message to this:
9634#0: *6 FastCGI sent in stderr: "Unable to open primary script: /home/webstudions/www/laravel/public/info.php (No such file or directory)" while reading response header from upstream, client:, server: www.appstudions.be, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://", host: "www.appstudions.be"

In the folder was no index.php, only info.php. Adding it doesn't solve the problem.

I know FTP is not secure. I setup sftp using this tutorial: https://www.digitalocean.com/community/articles/how-to-configure-vsftpd-to-use-ssl-tls-on-a-centos-vps and that's working correctly!
by Justin Ellingwood
FTP was a popular file sharing mechanism for network connected computers in the past. However, its usage has fallen out of favor due to inherent security flaws. In this guide, we will discuss how to use SSL/TLS to improve the security of your FTP sessions if you must continue to use this protocol.
"Unable to open primary script..."

Might be a permissions problem. What's the output of
ls -l /home/webstudions/www/laravel/

make sure the public directory is web visible.
The command has the following output:
drwxr-xr-x 2 webstudions webstudions 4096 Dec 14 15:13 public
It would make sense that it is a permission problem because going to appstudions.be gives a 403 while there is a index.php in the public directory now.
appstudions.be/info.php still gives "no input file specified."
Ok awesome I fixed it. The problem was indeed permission related and this post helped me fix it: http://stackoverflow.com/questions/6795350/nginx-403-forbidden-for-all-files

The directory /home/webstudions had the wrong permissions.
chmod -R 755 /home/webstudions
solved the problem.

Thanks a lot for your help!

any one got answer for this because i m also in a same issue
"no input file specified"

thanks for reply @kamaln7

issue was in php-fpm and nginx configuration file.
root path was not specified where my all php files was stored......

Have another answer? Share your knowledge.