Nginx: Resolving “No input file specified” error

nginx logoIf you are using nginx with php-cgi and have followed the standard procedure to set it up, you might often get the “No input file specified.” error. What happens here is that, when nginx receives the request to serve a non-existent php file, it passes the request to php-cgi. Php-cgi, while trying to processs the request, finds that the php file does not exist at all. Hence it sends a “No input file specified.” message with a “404 Not Found” header.

Although, it’s not technically an error, we can catch the request for the non-existent php file and show a custom 404 page.

First, find out the version of nginx you are using.

[code language=”bash”]nginx -V[/code]

You’ll get an output like this :

[code language=”bash”]nginx version: nginx/0.7.65
TLS SNI support enabled
configure arguments: –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –pid-path=/var/run/nginx.pid –lock-path=/var/lock/nginx.lock –http-log-path=/var/log/nginx/access.log –http-client-body-temp-path=/var/lib/nginx/body –http-proxy-temp-path=/var/lib/nginx/proxy –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –with-debug –with-http_stub_status_module –with-http_flv_module –with-http_ssl_module –with-http_dav_module –with-http_gzip_static_module –with-http_realip_module –with-mail –with-mail_ssl_module –with-ipv6 –add-module=/build/buildd-nginx_0.7.65-2~bpo50+1-i386-1taiV6/nginx-0.7.65/modules/nginx-upstream-fair[/code]

If php-cgi is running on port 9000, you’ll have something like this in your vhosts file :

[code]location ~ \.php$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME ….
……………………………..
……………………………..
}[/code]

Since nginx versions less than 0.6.36 doesn’t have the try_files directive, we’ll have two versions of the code.

For nginx 0.6.36+
We’ll use try_files here to catch and display an error page.

[code]location ~ \.php$ {
try_files $uri /path/to/404.htm;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME ….
……………………………..
……………………………..
}[/code]

For older versions :

[code language=”bash”]location ~ \.php$ {
fastcgi_intercept_errors on;
error_page 404 /path/to/404.htm;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME ….
……………………………..
……………………………..
}[/code]

This will display the chosen 404 page for non-existent php files instead of the unhelpful “No input file specified.” message.

Finding the Lubuntu 10.04 torrent

I’ve been meaning to try out Lubuntu for quite some time, but was thwarted by the lack of a torrent. If you didn’t know, Lubuntu is an Ubuntu variant using the lightweight LXDE desktop environment, like Kubuntu uses KDE or Xubuntu uses XFCE. It hasn’t been officially approved as a part of the Ubuntu family yet, but judging from the favourable reviews it has been getting, that day might not be far away. Lubuntu is supposed to be much lighter than Xubuntu, which I’m currently using and seems like it is all that.

Anyway, the official Lubuntu.net page doesn’t show a torrent or metalink download option. Search for a torrent serves up the Lubuntu beta2 torrent or custom Lubuntu distributions created by enthuciasts. I finally got the official torrent from the mailing list archive.

Without further ado, here’s the torrent downlad link :

http://people.ubuntu.com/~gilir/lubuntu-10.04.iso.torrent

Hope this saves you a little frustration.

Storing and reusing Ubuntu updates

Suppose you have two computers running the same version of Ubuntu and you have downloaded and installed the updates on one of the computers. Since you are having a rather expensive or maybe, a limited internet connection, you do not wish to download the updates again for the other computer.

Updates downloaded by aptitude are stored in the directory /var/cache/apt/archives. You’ll find the package files in .deb format(Debian software package format). If these updates are copied to the same directory on the other computer, aptitude will automatically recognise those files and use them as necessary while updating. You can copy the files using a flash drive or write them to a CD if you wish to.
You can copy the packages using this command :
[bash]sudo cp /var/cache/apt/archives/* /path/to/flash/drive[/bash]

Now connect the flash drive to the other computer and copy the files to the /var/cache/apt/archives/ directory there.
After this, you need to update your package information and install the updates found.
Run :
[bash]sudo apt-get update && sudo apt-get upgrade[/bash]

All the required updates will be installed from the /var/cache/apt/archives/ directory(if available). You can also install new packages, and they will not be downloaded if they are available locally.

Mounting ext4 partitions in Debian Lenny

As of Debian 5.04 (Lenny), Debian doesn’t support mounting ext4 partitions out of the box, or rather, we should say, using conventional methods.

Trying to mount an ext4 partition using the mount directive yields the error :

mount: unknown filesystem type 'ext4'

The roundabout way of doing it is setting a test_fs flag on the partition using the tune2fs utility.

su -
tune2fs -E test_fs /dev/hda1
mount -t ext4dev /dev/hda1 /place/to/mount/

Replace hda1 with the name of the ext4 partition you want to mount.

I’ve had some (Pulse)Audio problems

Like many others, my speakers stopped working after I upgraded to Lucid Lynx. The usual solution of purging, reinstalling PulseAudio didn’t work for me, nor was my volume muted.

I finally got it working by removing PulseAudio and not installing it afterwards. AlsaMixer works just fine for me. However, I some times get the feeling that the sound quality might have deteriorated a bit, but it might just be me worrying too much.

This post is for those with a similar problem. If the usual solutions don’t work for you, try removing PulseAudio. That just may be it.