Running PERL Scripts

This has been a long term issue for me. I was hoping that when I setup VMPro it would go away, but I expect it is an issue of I just don't know how to do this.

I am trying to run a PERL application 'Trouble Ticket Express'. I want to be able to access it via url http://mysite.com/ttx/ttx.cgi I tried to copy the files to /home/site/public_html/ttx and also /home/site/cgi-bin/ttx I can get it to show the text of the script, but not execute the script. What steps am I missing? (I know this is probably a stupid question)

Status: 
Closed (fixed)

Comments

Copying it to cgi-bin/ttx.cgi is the right thing to do, as CGI scripts will not be run from the public_html directory.

Do you still see this problem if you copy to cgi-bin ? The URL to access it will be : http://mysite.cgi/cgi-bin/ttx.cgi

Howdy -- by default, scripts in the DocumentRoot aren't executable.

For them to execute, you'd generally put them into the cgi-bin directory, make sure the script itself has the execute permission set (chmod +x ttx.cgi), then access it with:

http://yoursite.com/cgi-bin/ttx.cgi

Now, some folks like to be able to run cgi scripts from within their DocumentRoot. While that's considered a security risk, many feel it to be an "acceptable risk".

If that's the case for you, what you'd need to do is edit the VirtualHost section of your Apache config for this domain, and in the "Options" line, add the "ExecCGI" option. After you restart Apache, it should be able to execute.

OK,

What is best practice if I may have more than one PERL application. The ttx program contains 30+ files. Should I use directories under the cgi-bin folder, if so do I have to make configuration changes to get the script to work in that folder (/cgi-bin/ttx/)

The alternative is to configure Apache to run .cgi files as CGI scripts, so that you can put the application under the public_html directory. To do this, do the following :

1) Login to Virtualmin, and select your domain from the left menu

2) Open the Services menu, and click on Configure Website

3) Click on the link for your domain's HTML directory, like /home/whatever/public_html

4) Click on the 'MIME Types' icon

5) In the 'Content handlers' section, select cgi-script from an empty menu, and enter .cgi into the field next to it

6) Click Save, and then 'Apply Changes'

Joe's picture
Submitted by Joe on Wed, 06/17/2009 - 16:39 Pro Licensee

Should I use directories under the cgi-bin folder, if so do I have to make configuration changes to get the script to work in that folder (/cgi-bin/ttx/)

Yes, and no changes are needed. Everything in cgi-bin, including sub-directories is included.

You can then add either ScriptAlias or Rewrite directives to make the apps appear on /ttx/ etc.