A client called us around 1:30 AM this morning, and told us that his website went down all of a sudden. We checked the website and here’s the error that we saw:
No Input File Specified
Hmmm…
It was probably the first time that we saw this error and so we started by debugging the index.php file under the root directory of the website, by adding a die(); at the beginning, but our code didn’t execute and we still saw the same error. Usually, there are 4 reasons why an index.php change isn’t reflected on the actual website:
- Apache doesn’t have write permissions on the index.php file. We checked the permissions and they were owned by the suPHP user and they were 644. So, nothing was wrong there!
-
The website is showing a cached version of the index.php file. We added the debug code at the very beginning of the file, so caching shouldn’t be even triggered. We also wiped out the contents of the cache folder just for good measure. Still, the same problem!
-
We are working on the wrong file. We checked, double checked, and triple checked that it was the correct index.php file. So, we were confident that we were working on the right file.
-
There is a quirk in the .htaccess file. We renamed the .htaccess file to .htaccess.old and we moved it outside the website’s directory (some environments will use the renamed file unless they can no longer access it). Nothing has changed! The “No Input File Specified” error was still there.
We then re-checked the index.php file, as this problem might happen if there is a space somewhere before the opening <?php tag or after the ending ?> tag, but nothing was there. We even created another index.php and moved the old one elsewhere. This didn’t fix the problem, but it helped us identify the problem: While moving the file outside the public_html directory, we noticed that the directory had the following permissions:
drwxr-x--- 27 755 nobody 4096 Feb 13 1:20 public_html/
Hmmm… This means that the public_html directory had a permission of 0700 (while being owned by the nobody user). This in turn means that Apache can’t even read the index.php file because it just can’t read anything in the parent directory.
In order to solve the problem, we changed the permissions on the public_html directory by issuing the following commands while in the Linux shell:
chmod 755 /home/[user]/public_html
chown -R [user] public_html
chgrp -R [user] public_html
Note: [user] should be your cPanel username for that website (without the brackets).
That fixed the problem!
But what caused the problem?
At first we didn’t know, but then our client revealed to us that it was his host that caused the problem, while trying to solve another problem!
If you have the same problem on your website, then check the permissions on both the index.php file and the public_html directory. The problem most likely lies there. If it isn’t, or if you’re not a big fan of touching the permissions, then please contact us. We will fix the problem for you in no time and for a very, very affordable fee!