Configuring OS X for Web Development

Started by sukishan, Aug 22, 2009, 07:15 PM

Previous topic - Next topic

sukishan

Configuring OS X for Web Development
Perl
To begin adding dynamics to your local Website(s), one of the primary tools you might use is Perl. This is included in the standard OS X install and requires only a few short steps to enable cgi scripts to run on your localhost.

In the /Library/WebServer/CGI-Executables/ directory, you'll find some included test scripts. By default, an alias to this directory can be found in Apache's httpd.conf file as cgi-bin. To enable scripts to also be available to individual users on the system, you will need to also find and uncomment the following line in httpd.conf:

# AddHandler cgi-script .cgi

Note that you can also add an additional line as that shown above, but with a .pl extension, to support using .pl files with, or in place of, the .cgi extension.

As a security warning, I should mention that this does allow cgi to be executed anywhere Apache serves documents. This may not be an issue for localhost testing, but carefully think out your security strategy if you will be enabling Internet access to any of these local sites on your system.

To test your CGI capability, load one of the test scripts in your browser, i.e. http://127.0.0.1/cgi-bin/test-cgi (provided by Apple in the CGI-Executables directory). If you receive a forbidden error, it is due to permissions not being set. All CGI scripts need execution rights, the most common being 755. This can be done by using the Terminal to the location of the CGI script and running CHMOD 755 filename.cgi, or in this case, test-cgi. In this case we will open the Terminal and issue the following commands:

CD /Library/WebServer/CGI-Executables
sudo chmod 755 test-cgi

Once you have successfully executed a test script, you can either place Perl scripts in the CGI executables directory (remember to set your permissions), or, if you have enabled scripts to be run in the Users/shortname/Sites folders, you can place them there.
A good beginning makes a good ending

Don Bonomini

These problems are too esoteric, I would like to study slowly  :educated :educated