# Apache Server and CGI

**URL:** https://boards.straightdope.com/t/apache-server-and-cgi/200482
**Category:** Factual Questions
**Created:** [September 9, 2003, 9:47am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482 "2003-09-09T09:47:22Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 9, 2003, 9:47am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/1 "2003-09-09T09:47:22Z")

</div>

I’ve been running Apache (1.3) for a while now to host files on the web off of my machine, since I have a static IP address and all. Recently I’ve been wanting to start hosting CGI scripts in Perl…

I’ve got the Apache httpd.conf file set up as per the documentation to run CGI scripts; however, when I try to access a .cgi or a .pl file on my machine, I’m given an HTTP 403 (Error Forbidden to View) page.

I’m guessing this has something to do with the script not being set for execute permissions, but how do I go about doing that on XP? All I can seem to find is how to do it via CHMOD on a linux machine, but how can I change the file permissions on XP to allow execution?

Thanks!

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 9, 2003, 9:52am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/2 "2003-09-09T09:52:39Z")

</div>

Oh, and before anyone asks… yes, I have Perl installed. 🙂

---

<div class="post-metadata">

### Author: ![kferr](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@kferr](https://boards.straightdope.com/u/kferr)
#### Post date: [September 9, 2003, 11:12am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/3 "2003-09-09T11:12:43Z")

</div>

Go to the directory where your scripts are, right click on one, select properties and look at the Security tab. Make sure they have Read & Execute permission.

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 9, 2003, 7:39pm UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/4 "2003-09-09T19:39:47Z")

</div>

> [@](#):
>
> Go to the directory where your scripts are, right click on one, select properties and look at the Security tab. Make sure they have Read & Execute permission.

I don’t have a Security tab. :-/

---

<div class="post-metadata">

### Author: ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)
#### Post date: [September 9, 2003, 7:47pm UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/5 "2003-09-09T19:47:52Z")

</div>

I’ve never run a Windows server, so I’m no help there. But I have a workaround you can try: from another computer, access your site with an FTP client like WS\_FTP and change the file permissions to CHMOD 755 from that.

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 9, 2003, 7:55pm UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/6 "2003-09-09T19:55:24Z")

</div>

I’d try that, only I have no idea how to access this computer from another using an FTP client.

---

<div class="post-metadata">

### Author: ![Bill\_H](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@Bill\_H](https://boards.straightdope.com/u/Bill_H)
#### Post date: [September 9, 2003, 10:56pm UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/7 "2003-09-09T22:56:58Z")

</div>

I know it’s long, but could you post your httpd.conf? or a pointer to it? It can be a tricky thing to make work, especially the first time.

Also, I recommend you move to v. 2.0. (I’m assuming that’s available for Windows; I don’t see why it wouldn’t be). Many improvements, especially on the security front.

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 9, 2003, 11:10pm UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/8 "2003-09-09T23:10:23Z")

</div>

httpd.conf:

> [@](#):
>
> ServerType standalone  
> ServerRoot “C:/Program Files/Apache Group/Apache”  
> PidFile logs/httpd.pid  
> ScoreBoardFile logs/apache\_runtime\_status  
> Timeout 300  
> KeepAlive On  
> MaxKeepAliveRequests 100  
> KeepAliveTimeout 15  
> MaxRequestsPerChild 0  
> ThreadsPerChild 50
> 
> ClearModuleList  
> #AddModule mod\_vhost\_alias.c  
> AddModule mod\_env.c  
> AddModule mod\_log\_config.c  
> #AddModule mod\_mime\_magic.c  
> AddModule mod\_mime.c  
> AddModule mod\_negotiation.c  
> #AddModule mod\_status.c  
> #AddModule mod\_info.c  
> AddModule mod\_include.c  
> AddModule mod\_autoindex.c  
> AddModule mod\_dir.c  
> AddModule mod\_isapi.c  
> AddModule mod\_cgi.c  
> AddModule mod\_asis.c  
> AddModule mod\_imap.c  
> AddModule mod\_actions.c  
> #AddModule mod\_speling.c  
> AddModule mod\_userdir.c  
> AddModule mod\_alias.c  
> #AddModule mod\_rewrite.c  
> AddModule mod\_access.c  
> AddModule mod\_auth.c  
> #AddModule mod\_auth\_anon.c  
> #AddModule mod\_auth\_dbm.c  
> #AddModule mod\_auth\_digest.c  
> #AddModule mod\_digest.c  
> #AddModule mod\_proxy.c  
> #AddModule mod\_cern\_meta.c  
> #AddModule mod\_expires.c  
> #AddModule mod\_headers.c  
> #AddModule mod\_usertrack.c  
> #AddModule mod\_unique\_id.c  
> AddModule mod\_so.c  
> AddModule mod\_setenvif.c  
> Port 80  
> ServerAdmin dharkey@virginia.edu  
> ServerName 199.111.227.172  
> DocumentRoot “C:/webserver”  
> \<Directory c:/webserver\>  
> Options FollowSymLinks +ExecCGI  
> AllowOverride All  
> \</Directory\>
> 
> \<Directory “C:/webserver”\>  
> Options Indexes FollowSymLinks MultiViews +ExecCGI  
> AllowOverride All  
> Order allow,deny  
> Allow from all  
> \</Directory\>
> 
> \<IfModule mod\_userdir.c\>  
> UserDir “C:/webserver/users/”  
> \</IfModule\>
> 
> \<IfModule mod\_dir.c\>  
> DirectoryIndex index.html index.htm index.shtml index.cgi index.pl  
> \</IfModule\>
> 
> AccessFileName .htaccess  
> \<Files ~ “^.ht”\>  
> Order allow,deny  
> Deny from all  
> Satisfy All  
> \</Files\>
> 
> UseCanonicalName On
> 
> \<IfModule mod\_mime.c\>  
> TypesConfig conf/mime.types  
> \</IfModule\>
> 
> DefaultType text/plain
> 
> \<IfModule mod\_mime\_magic.c\>  
> MIMEMagicFile conf/magic  
> \</IfModule\>
> 
> HostnameLookups Off
> 
> ErrorLog logs/error.log
> 
> LogLevel warn
> 
> LogFormat “%h %l %u %t “%r” %\>s %b “%{Referer}i” “%{User-Agent}i”” combined  
> LogFormat “%h %l %u %t “%r” %\>s %b” common  
> LogFormat “%{Referer}i -\> %U” referer  
> LogFormat “%{User-agent}i” agent
> 
> CustomLog logs/access.log common
> 
> ServerSignature On
> 
> \<IfModule mod\_alias.c\>
> 
> ```
> Alias /icons/ "C:/Program Files/Apache Group/Apache/icons/"
> 
> &lt;Directory "C:/Program Files/Apache Group/Apache/icons"&gt;
> Options Indexes MultiViews +ExecCGI
> AllowOverride All
> Order allow,deny
> Allow from all
> &lt;/Directory&gt;
> 
> &lt;Directory "C:/webserver"&gt;
> Options Indexes FollowSymlinks MultiViews +ExecCGI
> AllowOverride All
> Order allow,deny
> Allow from all
> &lt;/Directory&gt;
> 
> ScriptAlias /cgi-bin/ "C:/webserver/cgi-bin/"
> 
> &lt;Directory "C:/webserver/cgi-bin"&gt;
> AllowOverride All
> Options None +ExecCGI
> Order allow,deny
> Allow from all
> &lt;/Directory&gt;
> 
> ```
> 
> \</IfModule\>
> 
> \<IfModule mod\_autoindex.c\>
> 
> ```
> IndexOptions FancyIndexing
> AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
> 
> AddIconByType (TXT,/icons/text.gif) text/*
> AddIconByType (IMG,/icons/image2.gif) image/*
> AddIconByType (SND,/icons/sound2.gif) audio/*
> AddIconByType (VID,/icons/movie.gif) video/*
> 
> AddIcon /icons/binary.gif .bin .exe
> AddIcon /icons/binhex.gif .hqx
> AddIcon /icons/tar.gif .tar
> AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
> AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
> AddIcon /icons/a.gif .ps .ai .eps
> AddIcon /icons/layout.gif .html .shtml .htm .pdf
> AddIcon /icons/text.gif .txt
> AddIcon /icons/c.gif .c
> AddIcon /icons/p.gif .pl .py
> AddIcon /icons/f.gif .for
> AddIcon /icons/dvi.gif .dvi
> AddIcon /icons/uuencoded.gif .uu
> AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
> AddIcon /icons/tex.gif .tex
> AddIcon /icons/bomb.gif core
> 
> AddIcon /icons/back.gif ..
> AddIcon /icons/hand.right.gif README
> AddIcon /icons/folder.gif ^^DIRECTORY^^
> AddIcon /icons/blank.gif ^^BLANKICON^^
> 
> DefaultIcon /icons/unknown.gif
> 
> ReadmeName README
> HeaderName HEADER
> IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
> 
> ```
> 
> \</IfModule\>
> 
> \<IfModule mod\_mime.c\>
> 
> ```
> AddType application/x-tar .tgz
> AddEncoding x-compress .Z
> AddEncoding x-gzip .gz .tgz
> AddLanguage da .dk
> AddLanguage nl .nl
> AddLanguage en .en
> AddLanguage et .ee
> AddLanguage fr .fr
> AddLanguage de .de
> AddLanguage el .el
> AddLanguage he .he
> AddCharset ISO-8859-8 .iso8859-8
> AddLanguage it .it
> AddLanguage ja .ja
> AddCharset ISO-2022-JP .jis
> AddLanguage kr .kr
> AddCharset ISO-2022-KR .iso-kr
> AddLanguage nn .nn
> AddLanguage no .no
> AddLanguage pl .po
> AddCharset ISO-8859-2 .iso-pl
> AddLanguage pt .pt
> AddLanguage pt-br .pt-br
> AddLanguage ltz .lu
> AddLanguage ca .ca
> AddLanguage es .es
> AddLanguage sv .sv
> AddLanguage cs .cz .cs
> AddLanguage ru .ru
> AddLanguage zh-TW .zh-tw
> AddCharset Big5 .Big5 .big5
> AddCharset WINDOWS-1251 .cp-1251
> AddCharset CP866 .cp866
> AddCharset ISO-8859-5 .iso-ru
> AddCharset KOI8-R .koi8-r
> AddCharset UCS-2 .ucs2
> AddCharset UCS-4 .ucs4
> AddCharset UTF-8 .utf8
> 
> &lt;IfModule mod_negotiation.c&gt;
> LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
> &lt;/IfModule&gt;
> 
> AddHandler cgi-script cgi pl
> 
> AddHandler server-parsed .shtml
> 
> ```
> 
> \</IfModule\>
> 
> ErrorDocument 500 /errors/500.html  
> ErrorDocument 404 /errors/404.html  
> ErrorDocument 402 /errors/402.html
> 
> \<IfModule mod\_setenvif.c\>
> 
> ```
> BrowserMatch "Mozilla/2" nokeepalive
> BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
> 
> BrowserMatch "RealPlayer 4\.0" force-response-1.0
> BrowserMatch "Java/1\.0" force-response-1.0
> BrowserMatch "JDK/1\.0" force-response-1.0
> 
> ```
> 
> \</IfModule\>

Perl is located in C:\PERL\BIN  
Apache is located in C:\PROGRAM FILES\APACHE GROUP\APACHE\

Thanks!

---

<div class="post-metadata">

### Author: ![Bill\_H](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@Bill\_H](https://boards.straightdope.com/u/Bill_H)
#### Post date: [September 10, 2003, 12:01am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/9 "2003-09-10T00:01:00Z")

</div>

Try this:

Go into View File Types and set up .pl and .cgi files to run the application Perl.

Also, try this putting this **test.pl** perl script in cgi-bin and running it, to ensure this isn’t an issue of a script errors:

```auto

#!C:\PERL\BIN\perl.exe
print "Content-type: text/html

";
print "<!doctype html public \"-//W3C//DTD HTML 4.0 Transitional//EN\">
";
print "<html><head><title>Perl Test</title></head>";
print "<body><h1>bang!</h1>test test</body></html>";

```

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 10, 2003, 12:05am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/10 "2003-09-10T00:05:19Z")

</div>

Ahhh… your example worked. Wonder why mine aren’t. :-/

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 10, 2003, 12:07am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/11 "2003-09-10T00:07:03Z")

</div>

**DOH!** I figured it out.

My PERL headers were

#!C:\PERL\BIN

Fixed. 🙂 Thanks, Bill!

---

<div class="post-metadata">

### Author: ![Bill\_H](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@Bill\_H](https://boards.straightdope.com/u/Bill_H)
#### Post date: [September 10, 2003, 12:27am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/12 "2003-09-10T00:27:47Z")

</div>

No problem. 1% of the first years revenues oughta cover it.

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 10, 2003, 12:30am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/13 "2003-09-10T00:30:10Z")

</div>

New problem…

The scripts are running fine for me, but when anyone other than myself (on a different machine) tries to access the server via [http://199.111.227.172/](http://199.111.227.172/) (or run, for example, [http://199.111.227.172/cgi-bin/test.pl](http://199.111.227.172/cgi-bin/test.pl), they get this message:

**Cannot find server**  
The page cannot be displayed  
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

Suggestions?

---

<div class="post-metadata">

### Author: ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)
#### Post date: [September 10, 2003, 1:18am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/14 "2003-09-10T01:18:06Z")

</div>

Check your server’s IP address. I suspect that might be your local connection’s IP address (or a local network IP address if you have a router and a local network set up), not your internet IP address.

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 10, 2003, 1:20am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/15 "2003-09-10T01:20:31Z")

</div>

That’s the only IP address I can find… where would I look?

ipconfig:

Connection-specific DNS suffix: Virginia.EDU  
IP Address: 199.111.227.172  
Subnet Mask: 255.255.252.0  
Default Gateway: 199.111.224.1

---

<div class="post-metadata">

### Author: ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)
#### Post date: [September 10, 2003, 1:33am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/16 "2003-09-10T01:33:46Z")

</div>

I see it’s a university network? Chances are you’re connected to their network which in turn provides a connection to the internet, yes? They may have a firewall in place that prevents outside connections. contact the university’s IT people; perhaps they can provide a solution, like a different IP address for you to use, or something.

---

<div class="post-metadata">

### Author: ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)
#### Post date: [September 10, 2003, 1:40am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/17 "2003-09-10T01:40:01Z")

</div>

A traceroute gives:

> [@](#):
>
> Name: d-199-227-172.bootp.virginia.edu  
> IP Address: 199.111.227.172  
> Location: 38.025N, 78.500W  
> Network: NETBLK-VERNET-CIDR

So, the IP address is resolving, but there’s no web content at that address.

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 10, 2003, 1:41am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/18 "2003-09-10T01:41:33Z")

</div>

> [@](#):
>
> So, the IP address is resolving, but there’s no web content at that address.

Is this something that I can fix…?

---

<div class="post-metadata">

### Author: ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)
#### Post date: [September 10, 2003, 1:42am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/19 "2003-09-10T01:42:06Z")

</div>

Ooo…I had a thought. If you have a username on the university network, try affixing /~_username_ after the IP address. It’s a long shot, but hey.

---

<div class="post-metadata">

### Author: ![Civil\_Defense](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@Civil\_Defense](https://boards.straightdope.com/u/Civil_Defense)
#### Post date: [September 10, 2003, 1:43am UTC](https://boards.straightdope.com/t/apache-server-and-cgi/200482/20 "2003-09-10T01:43:24Z")

</div>

> [@](#):
>
> Ooo…I had a thought. If you have a username on the university network, try affixing /~username after the IP address. It’s a long shot, but hey.

In my config, or in the browser URL? For me, doing this in the browser URL results in a 404 not found.

[Next page](https://boards.straightdope.com/t/apache-server-and-cgi/200482.md?page=2)
