We can run the scripts which resides in our home directories on browser. It is not a difficult job just need to change some files of the server. In case of Apache server follow these steps:
Step 1: Activate the User's public_html Directory with userdir
Create a directory(folder) called public_html in your home directory. For this command is:
$ mkdir public_html
make sure you are not using sudo as a starting word of command.
set the permissions of this folder to
$ chmod 755 -R public_html
Step 2: There are only two commands we need to enter to activate the User directory feature and then
one command to reload the configuration files. commands are
$ cd /etc/apache2/mods-enabled/
$ sudo ln -s ../mods-available/userdir.load
$ sudo ln -s ../mods-available/userdir.conf
$ sudo /etc/init.d/apache2 restart
The last command includes an absolute path, so it doesn't matter where you execute it from.
The second and third two "ln" commands assume we are in the directory /etc/apache2/mods-
enabled. What we need to do is create two symbolic links (soft links, symlinks) in the stated
directory pointing to the corresponding module in /etc/apache2/mods-available.
On your home system, restarting apache will give you a warning "apache2: Could not reliably
determine the server's fully qualified domain name, using 127.0.1.1 for ServerName" simply
because you are at home and don't have a fully qualified domain name. No problem.
Step 3: Open up a browser and type http://localhost/~USER_NAME, where "USER_NAME" is your
actual username. for example the output would be like
Step 4: Now change the httpd.conf file of apcahe server to run the CGI scripts from user directory.
open terminal and type command:
$ cd public_html
$ mkdir cgi-bin
$ chmod 755 cgi-bin
The above first command is being used to go in public_html folder(directory) and second
is being used for creating a new directory called cgi-bin which would contain the cgi scripts.
Last one is used to set permissions. Now, Open the configuration file of apache server using
below command.
$ sudo gedit /etc/apache2/httpd.conf
and add below code in it, then save the file.
ScriptAlias /cgi-bin/ /home/toor/public_html/cgi-bin/
<Directory /home/toor/public_html/cgi-bin/>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
SetHandler cgi-script
Order allow,deny
Allow from all
</Directory>
toor is USER_NAME and cgi-bin is directory in the public_html folder that would contain the
CGI scripts. Now, restart the server as
$ sudo /etc/init.d/apache2 restart
I hope you will able to run the cgi-scripts through browser :) :D