Enabling CGI?

DCT Jared Smith jared at dctkc.com
Thu Jan 24 12:56:32 CST 2002


S. Dimbert:

First I will do my best to answer your question. Then I
will deliver a soliloquey.

Why do you not have access to the server conf file? If you do
not have access to the conf file, then install a server on your
own computer, and use that server. If you're at all serious
about what you're doing, you've got to be able to access the
configuration to the server. Period.

Frankly, the instructions seem perfectly clear. Here is a plainer
English version of them:

"You are going to configure the httpd.conf. If you have never
done this before, open up that file and READ through it, gaining
a sense of how information is laid out. Skim (not skip) those
parts which make no sense; your brain will absorb them, and
they will become latent reservoirs which bear fountains of
knowledge six months from now.  After you have spent
fifteen minutes looking through the file (there is plenty of inline
documentation to read within the conf file), you will see that 
there is an area, or a 'block' within which you configure the 
webroot. In the default httpd.conf, it is a block which looks 
like this:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

Right in there, add the appropriate line about ExecCGI.
Next, search for this commented line (assuming you're
using a recent version of Apache, which carries this
line by default):

     #AddHandler cgi-script .cgi

Uncomment this line by removing the '#'. That's it. You've
just enabled cgi parsing in your Apache server. Save the
file, restart Apache (see the documentation for this 
command), and your scripts should work fine.

The whole concept of restarting Apache means that you
can make changes to its configuration while it is still
running, and once you have tested the changes, then
you can restart Apache, which takes about two seconds,
meaning that if you're running a busy website, you have
no downtime during configuration changes...

NOW for the soliloquey:

Having finally gotten to the point where httpd.conf makes
sense, I understand your initial hesitance at editing that file. 

However, be not hesitant. Keep backups and be bold: 
it really is quite sensibly laid out, and everything you really need 
to know about it is extraordinarily well documented, because 
_everyone_ has been in your situation. First thing to know is that
Open Source programmers are used to writing code that
works. Broken code implies incomplete thoughts. Thus you can 
expect them out of habit to include all relevant information in the 
documentation: yes, it may be cryptic, but the answers are 
most often right in front of your nose.

Being a newbie is okay once. After that, if you call yourself a 
newbie, you simply haven't read the manual enough. Some 
people would replace all these words with "RTFM" and 
be done with it. And those folks are better than me. Stop calling 
yourself a newbie unless it's absolutely necessary; everyone 
is a newbie at something, there is no need to boast about it.

All you have to do is search Google for "apache conf cgi linux"
or something like that, and begin browsing. Within a few minutes
you will find someone who has encountered your precise 
problem, and someone else who has resolved it for them.
Now the first few times you use Google (or Codehound, or
other search engines) in this manner, you'll spend half an hour
instead of a few minutes... maybe more. You'll quickly reduce
the time spent, learning how to jump to metacrawlers when
you come up with really obscure problems.

The number one thing for newbies to learn is how to find 
relevant information quickly: that single skill (and perseverence
at that skill) is the only thing which separates a newbie from an angel. 
Facts come and go quickly; methods remain. Learning this simple 
method of learning takes a little time, yet it is useful in many areas,
not just programming, installing, and configuring computers, so
the time is worth it.

Basically, you're honing your sense of signal-to-noise, which is
useful in all situtions.

-Jared

------your letter is hereafter attached-----

<--Newbie Alert!!-->

I'm trying to install a CGI on my new Linux Intranet server. I installed it 
fine... the problem is that, when I call the .cgi file, the server returns 
the text of the file instead of the result of the script. The help files 
from the CGI installer say:

<><><>
If, when you try to load mt.cgi into your browser--or mt-load.cgi or 
mt-check.cgi during the installation process--then the problem is that your 
webserver does not have CGI scripting enabled in its configuration.

If you run your web site on a hosted provider, you will need to email the 
support for this provider and ask them to turn on CGI scripting for your 
account (or for the webserver on a whole); this is not something that you 
can configure yourself.

If you run your own webserver, or if you have access to the webserver 
configuration files--and the privileges to restart the webserver, after 
modifying the configuration--you can use these steps to enable CGI scripts 
on your webserver. The following instructions assume that you are running 
Apache.

Find the configuration file httpd.conf, and open it up in an editor.

Find the Directory or Location block that configures the webroot for the 
server.
Inside of that block, add this line:

    Options +ExecCGI

Outside of the Directory or Location block, add the line
    AddHandler cgi-script .cgi

Restart the webserver.

CGI scripts should now execute, instead of merely displaying their source.
<><><>

I have 2 problems with following these directions:

1) I am at a location different from the server and I don't have rights to 
write to /etx/httpd/conf/. But I suppose that's easy enough to fix.
2) I'm scared to change the httpd.conf file since I don't really understand 
the instructions.

I can't give y'all the address of the server since it only serves 
locally... can someone help me understand?

Thanks!

-SD




More information about the Kclug mailing list