Saturday, 1 June 2013

Save dialog coming up while executing main.cgi

Every time I re-install my operating system I have to setup every damn thing again. Anyways! I am writing here the problem that I faced while setting up my cgi-bin folder. After installing apache server, CGI will work fine in /usr/lib/cgi-bin folder. But I was setting up the cgi-bin folder in my home directory as I had to install a software named BAKAPLAN made by one of my friends.

If you check the BAKAPLAN github page that I have mentioned above you will find the basic instruction on how to setup cgi-bin folder in public_html folder. I followed all the instruction written in there. Still when I tried to execute my own CGIPhotoAlbum, instead of executing it, It showed me dialog box to save the file. The executable file that I was trying to run had name "main.cgi". I don't know the reason behind this. May be because I was using an extension .cgi. Maybe I had not given the appropriate permissions to the files in the cgi-bin folder.

So the first thing I did was to give permission the folder. I issued the following command.

chmod -R 755 public_html/

Execute this command when you are in your home directory. "$ cd ~"

So next thing that I thought of was to tell the apache server that .cgi is also a cgi script. This reason kindof not making any sense but just for sake my some part of brain add the following line in /etc/apache2/sites-available/default or edit if it is already there

<Directory "/home/*/public_html/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                SetHandler cgi-script
                AddHandler cgi-script .cgi
                Order allow,deny
                Allow from all

Notice the AddHandler line. That is what I added. This solved my problem. Hope it does yours too. :)