Running Perl in apache


I set up apache with redhat 9.0 yesterday. The probelm is when I try to run perl/cgi all it does is show me my source code. How do I fix this?


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.

You need to indicate in the apache configuration files that the files that you are looking at are in fact, cgi scripts.  There a few steps for this:

1. If you have DSO (dynamic Share object) support enabled, there should be lines that look like this in the httpd.conf file:

LoadModule cgi_module         libexec/


AddModule mod_cgi.c

2.  For the directory that allows CGI scripts, you should have the ExecCGI option enabled, which will look something like:

<Directory /full/path/to/cgi/directory>
Options ExecCGI
order allow, deny
allow from all

3. Within your virtualhost statement, you should have a 'ScriptAlias' statement that looks like:

ScriptAlias /cgi-bin/ /full/path/to/cgi/directory/

(with the trailing slash).

4. You need to indicate to the server that certain file extensions need to be handled by the CGI handler with a statement like this:

AddHandler cgi-script .cgi .pl

... if you need to make any adjustments to add these items, you'll need to restart your Apache server.

PaulmulAuthor Commented:
I have done all that. This is the error I am getting

httpd failed. The error was: Starting httpd: httpd: Could not determine the server's fully qualified domain name, using for ServerName

Do you have a ServerName statement for the virtual host?  Can you post your virtualhost section here?
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

PaulmulAuthor Commented:
I have added a servername since I posted that. I think the probelm is my IP address, I don't know it and in turn it is not regocnizing my machine. How do I get my IP, I was told ifconfig -a but My machine says commmand not found.

The error I am getting now is httpd failed. The error was: Starting httpd: [FAILED]

I think it has something to do with not having proper IP address.
you could simply use 'ping' to ping somewhere else, like ebay:


It will say something like:

PING ( from <youripaddress>: 56(84) bytes of data.

where <youripaddress> is your computer.
PaulmulAuthor Commented:
That doesn't give my address, just the server that I ping.
It doesn't have a 'from' section like above?

ifconfig is usually located in the /sbin directory - try:

/sbin/ifconfig eth0

(THINKING OUTLOUD) If you are using virutal hosts, you would have had to have specified an IP address to 'listen' to... that's probably part of why your cgi script isn't working properly

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
PaulmulAuthor Commented:
Ok, I found my IP address and now it all works. The problem is I've killed my internet access (Currently using windows) If you have any idea how I did that and how I can fix it I would be very greatful. Thanks for helping with the other stuff though.

PaulmulAuthor Commented:
When I wrote (currently using windows) I mean I am using windows as I killed my internet access on Linux.
I understand what you mean - you're posting from a different computer because your linux box currently cannot access the internet.

do you have a file called /etc/sysconfig/network?  In there, it should say:


as well as give the gateway address and device...

Also, look at /etc/resolv.conf - it should give the name servers that you are using to resolve external domain names.
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
Apache Web Server

From novice to tech pro — start learning today.