Skip to main content

How to add CGI and Perl in apache

Configuring Apache to run CGI programs isn't that hard. First, you need to assign an alias for your script directory.

So you create a special location, called an alias, to the actual CGI directory. Edit your httpd.conf file and add the line below:

ScriptAlias /cgi-bin/  /usr/local/apache/share/cgi-bin/

However, this does not configure Apache to run the programs it finds in the cgi-bin directory. To actually execute programs, you need to edit the access.conf file by adding a section like this:

<Directory /usr/local/apache/share/cgi-bin>
Options ExecCGI
AddHandler cgi-script   .cgi   .pl
</Directory>

 

Here is how CGI works

CGI test

You need a web page that uses forms to call the cgi script. Create a plain text file

called testcgi.html

Here it is:
"http://www.w3.org/TR/html4/strict.dtd">
<html><head>

<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>testcgi</title>

</head><body>
<form action="cgi-bin/mycgi.cgi">
<input name="Firstname" type="text">
<input value="OK" type="submit">
</form>
<br>

</body></html>


Create a plain text file called mycgi.cgi

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "That worked\n";
exit(0);


The script will fail if it has the wrong permissions, and it needs to be in a directory called

cgi-bin

which also has the correct permissions.

Using an ftp client such as filezilla,

  • upload testcgi.html to the top-level of your account.

  • create a directory called cgi-bin

  • upload mycgi.cgi to cgi-bin

  • change the permissions of cgi-bin to 75


Browse to your home page
http://www.WhereEver-It-Is/~YourUserName/testcgi.html

You will see a form. Type xxxx into it and click the OK button.

The URL line will change to
http://www.WhereEver-It-Is/~YourUserName/cgi-bin/ 
mycgi.cgi?Firstname=xxxx

The page will display
That worked

Comments

Popular posts from this blog

Unusual websites

1. BugMeNot - instantly get disposable login details for any popular website that forces you to register. 2. DailyLit - read your favorite books by email (on your PC, mobile, etc.). 3. FranceRadio - neat MP3 Search Engine that lets you Find, Play and Download favorite MP3s for FREE. 4. Google SMS - provides mobile users with a quick access (via SMS) to a wide range of practical information and tools (i.e. business listings (pizzerias, shops, etc.), weather, movie listings, driving directions, currency converter and lots more. 5. Podlinez - listen to your favorite podcasts from any phone. Just enter the RSS feed URL for the desired podcast and get a free-toll number to access it from a phone. 6. RetailMeNot - locate fresh discount coupons for thousands of web merchants and services right from your browser toolbar. Video demo . 7. SoLow - on a daily basis SoLow auctions 4 different items (iPhones, HD Screens, etc.). Anyone with a mobile/PC can participate in the auctions by ...

7 website to Update your life other than Facebook

There are many other websites other than FB,G+,Twitter to update your social life.I will list some of them here. 1. eHow eHow teaches you wide array of skills on different topics step-by-step. The content is created by its team of writers, called experts, who create how-to guides on topics from personal hygiene to food recipes. You can learn anything from making a Raspberry Pi Alarm clock to making a scarecrow for your garde 2. http://www.wikihow.com/ WikiHow is another how-to site teaching us how to do things in an organized manner, but it has been modeled as a Wiki. At eHow, the staff themselves are paid to create the guides, but at Wikihow, eveyone can edit, modify, and delete content. So, it&rsquo;s not just about learning &mdash; you can also teach others the valuable skills 3. http://www.howstuffworks.com/ HowStuffWorks is another wonderful website to broaden your horizons, providing you with very unique and interesting information on a wide range of topics. It contains ...

BitTorrent-Powered Ad-Free YouTube Alternative

YouTube accounts for more than a billion visitors every month, but it is not a secret that it has its weaknesses, especially when it comes to monetizing controversial content . Such weaknesses can be avoided by the recently launched BitTorrent-powered alternative. https://www.bitchute.com/ BitChute has launched, offering to hand freedom back to its users. The new service has a familiar layout for a video streaming platform: it features similar video controls, view counts, tools to vote on content, and a comment section. It is known that video content hosting platforms consume the obscene amounts of bandwidth, and therefore big hosting bills usually accompany their success.  However, BitChute does not utilize central servers – instead, it uses WebTorren t, a system which allows people to share content directly from their browser, without any additional configuration or installation. In other words, the users of the platform become hosts of the videos they’re watching, thus bringing ...