Anda di halaman 1dari 12

Chromic Design

Design With A Chrome


• Home
• About
• Portfolio
• Contact
• Sitemap
Subscribe
« Post Navigation »
Equal Height Division Using Javascript And CSS »
Setting Up Perl and CGI For Wamp Server WAMP(P)
May 06 2009
Posted by admin
I work on Perl and CGI recently for my college project and so I decided to write a few steps on
setting up Perl and CGI with Wamp Server. I hope this might be useful.
Step1:
First you need to download Wamp Server from www.wampserver.com and install Wamp Server
on your machine. The default installation directory is ‘C:\wamp” and here I am using the default
options for installation. To complete the installation you have to set the host name for your mail
server and your email address, here you can leave the default option again. That will do no harm.
The current Wamp Server will install Apache 2.2.11, PHP 5.2.9-2 + PECL, MySQL 5.1.33,
SQLitemanager and PhpMyadmin.
Step2:
Now you have to download ActivePerl (currently 5.10.0) from www.activestate.com and install
it. The default installation directory is “C:\Perl“, but for simplicity and ease of use I use different
directory. I create a new folder name “perl” inside “C:\wamp\bin“. So I install Active Perl in
“C:\wamp\bin\perl” directory. The next thing you need to do is configure the Apache web server
to execute Perl and CGI script.
Step3:
This is the most important part here. You need to edit the Apache configuration file. Now go to
“C:\wamp\bin\apache\Apache2.2.11\conf” directory and open “httpd.conf” file. Edit the
httpd.conf file as below.
1. Inside httpd.conf, look for the line that says “<Directory “c:/wamp/www/”>“, just a few lines
below this you’ll find the line that says “Options Indexes FollowSymLinks“. Add “Includes
ExecCGI” in the line just next to FollowSymLinks, thus it look like this
view plaincopy to clipboardprint?

1. Options Indexes FollowSymLinks Includes ExecCGI

Options Indexes FollowSymLinks Includes ExecCGI


This will enable CGI script inside your www folder.
2. Now look for the line “AddHandler cgi-script .cgi“, this line is commented out. You need to
enable this by un-comment this line, to do that remove the # character at the beginning of this
line. This will add handler for files with .cgi extension. If you want to use .pl file extension in
your server add “AddHandler cgi-script .pl” just below the above line. Now you will be able to
execute CGI and Perl script with .cgi and .pl, extension.
Lines to add
view plaincopy to clipboardprint?

1. AddHandler cgi-script .cgi


2. AddHandler cgi-script .pl

AddHandler cgi-script .cgi


AddHandler cgi-script .pl
3. To add directory index file, look for the line “DirectoryIndex index.php index.php3 index.html
index.htm“. Add index.cgi and index.pl in this line.
Lines to add
view plaincopy to clipboardprint?

1. DirectoryIndex index.php index.php3 index.html index.htm index.cgi index.pl

DirectoryIndex index.php index.php3 index.html index.htm index.cgi index.pl


Alternative: If you do not want to waste your time doing the above 3 steps, you can download
the edited configuration file httpd.conf here. Replace the one inside your apache directory with
this one.
Step4:
Your server is now configured and ready to run perl and cgi script. Next thing you might need to
do is to configure perl to use mysql database. You need to download and install mysql driver to
enable database connection through your perl script. You have to grab the driver from the
ActivePerl package repository. However, mysql driver module is not available in the default
ActivePerl Package Repository. So, you need to add additional repository and install from that
repository. Follow the steps below:
1. Open command prompt [type cmd in run], then type “ppm repo add uwinnipeg” and press
enter.
2. After the “uwinnipeg” repository is added successfully, you can install DBD-mysql by typing
this command “ppm install DBD-mysql” and hit enter.

Note: The ActivePerl default package repository contains DBD-mysqlPP module. If you install
that one, you will get an error in your SQL SELECT query and especially when you use the
WHERE clause. Your localhost will hang if you run this kind of query with the WHERE clause,
so to get it work you need to install the package that I mentioned above only.
Tags: CGI, Perl, Wamp
Posted in MySQL, Tips and Tricks, Tutorials, Web Design | 38 Comments »
38 Responses to “Setting Up Perl and CGI For Wamp Server WAMP(P)”
1. Setting Perl and CGI in Wamp Server 2.0 « Zahid Bin Abdur Rouf Says:
May 12th, 2009 at 3:57 PM
[...] Setting Perl and CGI in Wamp Server 2.0 Posted May 12, 2009 Filed under: Perl and
CGI | I found a useful link that will help you in running a perl and cgi script ( files with
extension .pl or .cgi ). It has got step by step explaination of the installation . I was
succesful in running the cgi in my PC. I hope you might get lucky too.
http://www.chromicdesign.com/2009/05/setting-up-perl-for-wampp.html [...]

2. rinfelc Says:
May 19th, 2009 at 10:52 PM

Thumps up !!!
3. Exercise 9: Web form design and processing: A basis for e-commerce interaction « Alex
Ramsey :: ITC565 Business Applications Development Says:
June 15th, 2009 at 1:07 PM
[...] Chromic Design, Setting Up Perl and CGI For Wamp Server. [...]

4. Swapnil Says:
July 4th, 2009 at 4:27 PM
Very Very good to know and helpful for me
Thank you

5. slacker Says:
July 21st, 2009 at 10:54 PM
thank you mean . very good article

6. venkat Says:
August 12th, 2009 at 12:35 PM
Thank you very much.very good article

7. Jeroen Says:
August 29th, 2009 at 11:37 PM

Thanx for the info it worked!


8. Mahboob Says:
September 18th, 2009 at 3:50 AM
very nice and to the point, thanks a lot.
9. perl execution - Hot Scripts Forums Says:
October 2nd, 2009 at 8:18 AM
[...] Setting Up Perl and CGI For Wamp Server WAMP(P) | Chromic Design [...]

10. hemi Says:


October 2nd, 2009 at 8:25 PM
thank u, that really helped me a lot

11. matrix Says:


October 27th, 2009 at 2:30 PM
Hi Everyone,
I followed above all steps to configure perl but i am unable to execute .pl & .cgi file
extension in the wamp2.0 server.
i am getting error: Internal server error…
Components:
wamp2.0
ActivePerl-5.10.1.1006-MSWin32-x86-291086.msi
So please help me to solve this problem.

12. Asakura Says:


November 20th, 2009 at 6:24 AM
thanks for the explicit walkthrough helped me quite a bit.

13. Shamit Kumar Tomar Says:


November 26th, 2009 at 10:59 PM
@matrix,
I solved the same problem as yours. Here’s how to do it:
Let’s write Hello World script for Perl. I copied it from Wikipedia that has this script:
#!/usr/bin/perl
print “Hello, world!\n”;
But it gives 500:Internal Server Error. This is because, this script tells WampServer to
look into /usr/bin/perl for perl.exe but out perl.exe is in c:/wamp/bin/perl/bin/. So, we
have to use a script like this:
#!c:/wamp/bin/perl/bin/perl
print “Hello, world!\n”;
So, insert this #! commented line at top of your every script and it will work fine without
giving HTTP 500 error.
Enjoy@Perl. This is my first day on Perl.

14. madhav Says:


December 9th, 2009 at 2:49 PM
i got 500 internal server error

15. Zach Browne Says:


December 27th, 2009 at 4:20 AM
Great explanation, worked flawlessly. I was trying to get Warrick –
http://warrick.cs.odu.edu, a website archive re-builder working with WAMP Server and
this was the ticket. Thanks, great job. Very thorough and easy to follow.
Zach Browne

16. Brett The Tech Guy Says:


January 12th, 2010 at 8:56 AM
Thank you very much for posting this tutorial, it seemed to point me in the right
direction!
I did find you can combine these lines into one:
1. AddHandler cgi-script .cgi
2. AddHandler cgi-script .pl
AddHandler cgi-script .pl .cgi
I also found you can type:
Options Indexes FollowSymLinks +ExecCGI
Lastly you definitely need to declare the path as
#!c:/wamp/bin/perl/bin/perl
If you don’t have the right path you’ll receive 403 Permissions Denied

17. Sakmoro Says:


March 21st, 2010 at 12:04 AM
Hi,
I got a big problem, the server isn’t willing to go Online anymore… What can i do to fix
this problem!!

18. Mukesh Says:


March 27th, 2010 at 6:00 PM
my cgi and perl code will not execute
19. Gaurav Gupta Says:
April 3rd, 2010 at 5:51 PM
Very gud article man… it helped me alot.

20. sreeja Says:


April 6th, 2010 at 9:03 PM
Even after following the steps , I’m not able to run cgi scripts . it’s opening the program.
where should i save the cgi files?in c:/wamp/www or in
c:/wamp/bin/apache/apache2.2/cgi-bin ?
pls somebody help me out..

21. Alice Patel Says:


April 15th, 2010 at 1:18 PM
First of all thanks for good article.
And also “Brett The Tech Guy” for right direction

22. Manoj Says:


May 16th, 2010 at 9:20 AM
Hey man…
thanks a lot for this article.. this has helped me a lot
cheerrzzz man…

23. Bruce Says:


June 28th, 2010 at 7:16 PM
Thanks for tutorial, didn’t work for me, but this did in case anyone else has the same
issues I did: http://www.youtube.com/watch?v=_j-gugt9Xcw

24. Melli Says:


July 5th, 2010 at 10:33 AM
I just wanted to say, this is probably one of the best guides on the web for this task. I did
run into some problems configuring the httpd.conf file though. Its a good idea to make a
copy of the orginal httpd.conf file case you do run into any problems. The syntax can be
tricky and might require a few tries.
I suggest changing one line at a time, then re-starting the Apache server. This way you
can track any problem you may run into. This way you will know which line is giving
you the problem. You can also use the error log on the WAMPserver console. The
Apache.org also have some very useful notes on this subject.
http://httpd.apache.org/docs/1.3/misc/FAQ.html#CGIoutsideScriptAlias
As an overview, there are 3 things happening here. First, is the Perl install itself. Second,
you must tell Apache where to look for the .pl/cgi files you want to run. Brett’s response
posted above pretty much covers the things not mentioned in the original posting about
the httpd.conf file. Lastly, those same files must tell Apache where (#! path/to/perl.exe)
the Perl interpreter is located. You can do a system search for(perl.exe) to be sure. make
sure you include the .exe on the perl.exe.
If you are a beginner like me, I recommend creating a simple “Hello World.pl” program
once you install actveperl to test the install, then try running it on the server itself. I
wasn’t able to get the browser in activeperl to work (something about privacy issues), so I
just used the PSPad editor I had used to write my PHP code. Place the Hello.cgi file in
the directory listed in the httpd.conf file. I used:
http://www.cgi101.com/book/ch1/text.html to get me started with my perl. Again, it
important that your test program has the exact path to perl.exe on the first line of the
program.
It took a few tries but I cannot say how good it felt to finally see… “Hello World!”
ps
also make sure the alias modules and the cgi modules are installed and enabled too.

25. toufiq Says:


July 31st, 2010 at 7:38 PM
thank u for the post

26. Locus Says:


August 6th, 2010 at 9:51 AM
Now how to host and run website? Setup and Access databases ?

27. admin Says:


August 6th, 2010 at 11:10 AM
Thank you all for writing your comments. I will try to resume writing on my blog again
after a long pause due to my studies.
@Locus: I will try to write on this one. Thanks
@Melli: Thanks for the plus tutorial.

28. Scott Says:


August 12th, 2010 at 9:06 PM
Thanks for the info, this has saved me a lot of time. It has to feel great to know your blog
has helped people for over a year!

29. Albert Says:


September 10th, 2010 at 5:28 PM
Thanks for the tutorial! It helped me get Python working where none of the Python
tutorials did. I’ll probably use it for Perl too once I’m over my Python phase…

30. Hire PHP Developers Says:


October 20th, 2010 at 12:27 AM
Hi dear writer this is the best info for me as i am new for wamp server development.
Thanks

31. rakesh Says:


November 25th, 2010 at 12:41 PM
Thanks for providing this tutorial for setting up the Perl/CGI in my WAMP environment.

32. PerrineC Says:


November 29th, 2010 at 4:34 AM
thanks a lot !!!
very good !! =)

33. Hao Pham Says:


December 1st, 2010 at 12:38 PM
Hi,
I installed WAMP and ActivePerl with your steps but I got “505 Internal server error”
message?

34. darachi Says:


December 5th, 2010 at 3:05 AM
thanks for the kitchen madam

35. Aaron Says:


December 28th, 2010 at 12:10 PM
I had trouble with the perl location in my test.cgi giving a 500 Internal server issue. Since
Perl is in my path just putting the following worked
#!perl
print “Content-type: text/html\n\n”;
print “Hello World\n”;

36. oasisfleeting Says:


January 10th, 2011 at 6:59 AM
print “Content-type: text/html\n\n”;
This is a content-type header that tells the receiving web browser what sort of data it is
about to receive — in this case, an HTML document. If you forget to include it, or if you
print something else before printing this header, you’ll get an “Internal Server Error”
when you try to access the CGI program.

37. magnushung Says:


January 15th, 2011 at 1:51 PM
Very good explanation works great

38. Chrisilk Says:


January 17th, 2011 at 6:17 AM
Love my wamp server,
thanks for the help getting this to work
Leave your Comment
Top of Form

Name (required)

Mail (will not be published) (required)

Website

229

Bottom of Form
Top of Form
Search here...

Bottom of Form

• Log in
• Authors
• Archive
• Categories
• Tag Cloud
Log in
• Log in
• Register
• Comments (RSS)
Authors
• admin
Archive
• May 2009
• March 2009
• July 2008
• June 2008
• May 2008
Categories
• Flash
• Javascript
• Joomla
• MySQL
• News
• Tips and Tricks
• Tutorials
• Web Design
• Wordpress
• XHTML & CSS
Tag Cloud
CGI CSS Equal Height Sidebar Firefox Firefox 3.0 released Flash Javascript Joomla Module MySQL Perl phpMyAdmin Recent
Image Module RS Gallery Wamp Web Browser Web Designing Wordpress Wordpress 2.6 Released Word Wrap

Recent Comments
• Bed Guard on WordPress Blogroll Icon
• Chrisilk on Setting Up Perl and CGI For Wamp Server WAMP(P)
• magnushung on Setting Up Perl and CGI For Wamp Server WAMP(P)
• oasisfleeting on Setting Up Perl and CGI For Wamp Server WAMP(P)
• Aaron on Setting Up Perl and CGI For Wamp Server WAMP(P)
• darachi on Setting Up Perl and CGI For Wamp Server WAMP(P)
• Hao Pham on Setting Up Perl and CGI For Wamp Server WAMP(P)
• PerrineC on Setting Up Perl and CGI For Wamp Server WAMP(P)
Feed Subscription
Top of Form

Enter your email address:

http://feeds.feedb ChromicDesign en_US Subscribe

Delivered by FeedBurner
Bottom of Form

Recent Posts
• Setting Up Perl and CGI For Wamp Server WAMP(P)
• Equal Height Division Using Javascript And CSS
• Floating DIV Above Embedded Flash Object
• Renaming Multiple MySQL Tables Within A Few Seconds
• RSGallery Simple Tweak
Back to Top
Chromic Design is proudly powered by WordPress » Entries (RSS) and Comments (RSS).
Chromic Design © 2009-2009 : Designed by Alan Pachuau

Anda mungkin juga menyukai