Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Setting Up and Using CGI

Setting Up and Using CGI
Thread Tools
tavilach
Mac Elite
Join Date: Jan 2004
Location: Berkeley, CA
Status: Offline
Reply With Quote
Jun 22, 2006, 05:36 PM
 
I need to execute CGI files on my localhost, and I've never done that before.

I read this article and tried to browse to localhost/cgi-bin/, but I don't have permission, and I don't know how to get permission. My account is an administrator account.

I also don't have permission to edit the httpd.conf file to try to adjust anything!

Please help! Thanks .
"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." -Archimedes
     
jay3ld
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Jun 22, 2006, 09:30 PM
 
1. This should be in web design were you would get better and more posts.

2. Even as an administrator you can't do everything. Places are locked to keep new users/admins out of stuff they dont need to touch which could cause something to go wrong. The way I edit my httpd.conf is I open it in text edit. When im done I save it to the desktop. Then more it to the httpd folder and it asks to over right and I do I replace and put in the admin password and its done. Restart apache (System Prefs -> sharing -> stop then start web sharing)

By Default your cgi files are put in /Library/WebServer/CGI-Executables
But you can change that in your httpd.conf this line:
ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

and then change it to what ever you want or put a # in front of it to disable it and the directory stuff below it. then create a cgi-bin in your web root folder and It should work.
You shouldn't make fun of nerds... you'll be working for one some day.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jun 22, 2006, 10:05 PM
 
I suggest learning a Unix text editor such as pico, emacs, or vi. Pico is the most simple of the lot, but also the least powerful. In your terminal, if you do a "sudo pico /etc/httpd/httpd.conf" you can authenticate to temporarily become the root user (that does have permission to edit this file), and make the changes you need.

What you need to do in your httpd.conf is set a ScriptAlias so that Apache knows which directory you want to be able to run executable CGI apps out of. Just make sure the following line is uncommented, and restart Apache if you need to:

ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

Aside from that, as long as your web server is up, you have readable and executable permission to your CGI files in /Library/WebServer/CGI-Executables, you should be set.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jun 23, 2006, 06:57 AM
 
Forgot to add, you might need an AddHandler file in your httpd.conf to know how to handle files of certain file extensions. Simply uncomment this line and restart Apache:

AddHandler cgi-script .cgi

If your script has a .pl extension (Perl), create another line right below this that says this:

AddHandler cgi-script .pl
     
tavilach  (op)
Mac Elite
Join Date: Jan 2004
Location: Berkeley, CA
Status: Offline
Reply With Quote
Jun 25, 2006, 01:14 PM
 
I have all of the following:

ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

<Directory "/Library/WebServer/CGI-Executables">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

AddHandler cgi-script .cgi

Yet, when I go to http://localhost/cgi-bin/, I get:

You don't have permission to access /cgi-bin/ on this server.

What should I do?
"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." -Archimedes
     
tavilach  (op)
Mac Elite
Join Date: Jan 2004
Location: Berkeley, CA
Status: Offline
Reply With Quote
Jun 28, 2006, 11:39 AM
 
I desperately need to install this, so any ideas would be great!
"Give me a lever long enough and a fulcrum on which to place it, and I shall move the world." -Archimedes
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 12:18 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,