RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Web Development with Perl - CGI - Hello World Example

Next couple lines describes simplest process of getting started with Perl and CGI on Linux system in particular Debian Linux. Although the following steps are performed on a Debian Linux system they should be valid for all other distributions expect the step of Apache web server installation. First we need to install Apache Web server:

# apt-get install apache2

for RPM based distribution this step could involve yum

# yum install apache2

If you did not get any major errors the apache2 web server should be up and running at this point. Therefore we can navigate to /usr/lib/cgi-bin directory

# cd /usr/lib/cgi-bin

and create a following function based CGI program named hello.cgi:

 
#!/usr/bin/perl -T 
use strict; 
use CGI ':standard'; 
print header; 
print start_html('Hello World'); 
print h1('Hello World'); 
print end_html(); 
exit; 

Here is an Object-Oriented alternative of the above program:

 
#!/usr/bin/perl -T 
use strict; 
use CGI; 
my $cgi = new CGI; 
print $cgi->header; 
print $cgi->start_html('Hello World'); 
print $cgi->h1('Hello World'); 
print $cgi->end_html(); 
exit; 

At this stage we need to make our new CGI program executable:

# chmod 755 /usr/lib/cgi-bin/hello.cgi

All is now ready to launch our first CGI based web page by navigating our browser to and IP address of the apache server. In my case I'm running Apache locally so I use a localhost:

http://localhost/cgi-bin/hello.cgi

Share this linux post:

Submit Web Development with Perl - CGI - Hello World Example in Delicious Submit Web Development with Perl - CGI - Hello World Example in Digg Submit Web Development with Perl - CGI - Hello World Example in FaceBook Submit Web Development with Perl - CGI - Hello World Example in Google Bookmarks Submit Web Development with Perl - CGI - Hello World Example in Stumbleupon Submit Web Development with Perl - CGI - Hello World Example in Technorati Submit Web Development with Perl - CGI - Hello World Example in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download