CGI concept, Perl, php, c

Dear Expert,

Today I study perl and cgi usage and concept and just want to ask some question  after goolge serach some infomation at following link

Question-1) I know php , and I am able to run any php program in my Linux server by php command
and I also able to run my php at my IE broswer on XP just typing
I just want to clarify. Because my hosting company already installed CGI program on my server so that my users and I are able to run  perl, php, c language on  IE or any  browsers  through CGI program on my server   THe CGI program is  handling users(client-side) on browser's request through post and get request and execute
any script program in server such as php, perl, c..etc.  

Question-2 CGI program is language program, what type of  language is  C or others? Could I take
a look of CGI program look like in editor ?

Question-3  Why I don't have cgi-bin directory at my linux server if I am able to run php script on my IE browser? Or it doesn't matter to have cgi-bin directory or not because it is not related to whether I have installed
CGI program or not, and cgi-bin is just directory to store related program or script ?

Quesiton-4, On my Cpanel I got one icon that is cgi center . Is the cgi center means there is a lot of
script program similar to php prgram that can run on any browser for users throught CGI program on server ?

Finally question), people say  Perl is out-dated lanauge for web traffice application because today now
they are using  php lanauge to replace perl. Is it right ? So I don't  need to do  starting study on Perl and
so I just need to  concentrate on php that is already good enough ? but why I Awstat web stat software is
still using Perl ?

Please advise

LVL 13
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


First i think is important to understant what is CGI , it stands for Common Gateway Interface,

In short definition could be defined as way how external programs could interact with HTTP requests.

Trying to answer you same order

Q1)  You are also able to run any CGI script if configured on server by command line or browser
ex. $ ./myscript.cgi, by browser http:/

Scripts could recive or send data, you should study and review about benefits and disadvantages about tunning a script as cgi.

Q2) CGI is not language program, how could it look in an editor?, well that dependes on the individual programming language your using in the script. and which languages are configured to be allowed to run as CGI at server.

These CGI programs can be a PERL Script, Shell Script, C or C++ program, even PHP, etc.
You could tell which one si been used and syntaxis expected by reading first line that calls the proper interpreter or compiler.

gcc -o Cfile.cgi

Q3) it depends on your http server configuration, it could be configured to run in a specific folder, or whole site, its all about how CGI is configured

Q4) Correct, depend on script you could configure it for your needs and install them according to your server instructions to be able to use them

Final question) Well in my personal opinion this is more about personal preferences in programming languages.  i think its always good to learn languages and specialize in some or just in one, its also about needs, beneficts and disadvantages.

And following your line i could say that Phyton is going to replace PHP, ill state this diferent, maybe not the proper way but just for example. PHP is easier than Perl thats why most people use it, or just ask yourself, why arent you coding and making server side scripts in C language? for me is powerfull.

Hope this was helpfull to you what is CGI


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
duncanb7Author Commented:
Now it is better after looking the wiki doc for CGI

Please correct me if it is mistake on what my understand or say  as follows
CGI is  a method defined by RC3875 to interpret web browser URL to run web server program such
as perl or php and stdout program output data back to wbe browser.
The following is CGI program or script to run perl program and output all
environment varaible. "pl" extentsion of is stand for perl
 ##  printenv—demo CGI program which just prints its environment
 print "Content-type: text/plain\n\n";
 foreach $var (sort(keys(%ENV))) {
   $val = $ENV{$var};
   $val =~ s|\n|\\n|g;
   $val =~ s|"|\\"|g;
   print "${var}=\"${val}\"\n";

So last question:
Why I can run my php program on my IE browser when I type for example, Is it because my server already  installed CGI program or script
for php program to execute my php program ?

Yes, you could say is a way to allow programs to output to web browsers, how ever remember is not limited to PHP o PERL.

For your question, its how  PHP is configured on the Http server.

You can request because  the PHP interpeter has been compiled inside the Http server

also take a look at this

In the above link youll have an interesting reading about, in summary of keynotes:

There are two ways to configure Apache to use PHP:
Configure Apache to load the PHP interpreter as an Apache module
Configure Apache to run the PHP interpreter as a CGI binary

As a HTTP module PHP is runing in the same process that was created.
Runing as CGI you create a process each time you run a php script

Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

You´ve got some error in this.
In case your web server has PHP, perl, python or whatever language compiled in, you won´t need to access it via CGI. Apache call this mod_perl, mod_php or whatever.

To understand the last two sentences you need to know that running apache with mod_php will execute your php program within the boundaries and limits of this apache process. User permissions as well as memory usage limits, etc. from apache will limit this php process, too. This can be useful to not allow flooding your webserver.
Running your program in a CGI environment will make apache hand over POST and GET vars to the php program and execute it outside of its own process, wait for it to complete and then return its values (html code) to the client. It is quite clear that last case is slower, since php is an interpreted language and your program is compiled every time before execution, while mod_php may precompile and cache the program.
Question-1)  While it is possible to invoke a PHP script via CGI, most PHP code is embedded in HTML and run by the embedded PHP interpreter in the web server.

Question-2)  CGI is not a programming language.  It is an interface.  It's a little like an API.

Question-3)  /cgi-bin was the traditional location for CGI programs, but it depends on your webserver configuration.  It is also common to use a file association.  For example, any file ending in .pl is treated as a CGI program.

Quesiton-4)  Yes, although some of them would be quite outdated.

Finally question)  For web apps, Perl has definitely fallen out of favour with PHP being the most common.  However, there are still a lot of Perl apps out there, particularly for non-web purposes.

awstats was written many years ago (I think it was before PHP was invented), hence Perl was the best language for it.
duncanb7Author Commented:
Better understanding

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.