# How-to setup CGI on OSX?



## uoba (May 20, 2002)

Sorry in advance for posting this to the wrong section but the How-to forum wouldn't allow me to post a new thread there! (I guess admin will kindly move it on eventually )

Anyways, can someone kindly take some time out to explain how to get cgi up and running on OSX, I've been struggling all weekend to implement all sorts of cgi scripts for my test web server (basically very simple password scripts) not one has worked!

I have configured the Apache httpd.conf file to find and use cgi etc.

Anyone know of any obvious pitfalls to look out for?


----------



## Brewster (May 20, 2002)

I used to have trouble with cgi scripts too but I soon found out what i was doing wrong. First, make sure that the top line has /usr/bin/perl as the path to perl and make sure you have semi-colons ending the lines that they are supposed to end (basically everything except conditional clauses and some other stuff). Also make sure that you chmod it to 755 in the terminal. Finnally, the problem that always gets me is to make sure that the file is saved with unix line breaks, not mac or dos. To check, open the terminal and type 'vi /Library/WebServer/yourfile.cgi' - if it looks weird and has ^M at the ends of the line then it does not have unix line breaks. Simple text and textedit ofen save files with mac line breaks. I recomend getting BBEdit because when you got to save as, you can click on the options button and choose what kind of line breaks you want. Also try copying all of your script, opening a new simpletext window and pasting and saving it. I hope this helps.
Kevin Brewster


----------



## lethe (May 20, 2002)

the httpd.conf file supports CGI right out of the .  you can check out two simple CGI scripts in /Library/WebServer/CGI-Executables

one is a perl script the other is a shell script,and they don t do much, but they give the basic idea of what a cgi script looks like.  before any of them will work, you will have to chmod them to executable of course.


----------



## uoba (May 20, 2002)

I have seemingly done all this, chmod-ed, checked the perl direction line, edited everything in pico etc.

Anyway, my web development/programmer tells me not to bother with cgi 'cause its too slow, said to get into php instead.


----------



## vertigo (May 20, 2002)

i would tend to agree with him  
check out the php manual, it's pretty easy to learn if you've had any experience with c or perl. it's also really cool that you can escape out of HTML into a php script in the middle of your page.


----------



## uoba (May 21, 2002)

I'm finding  MySQL and PHP moe interesting for the obvious reason that the possibilities are greater. But, it'll take longer to learn!!

I've ordered a good book anyway


----------

