Problems Executing CGI scripts on Apache2

Pretty much a complete Linux/Apache newbie here, I am in the process of moving a site from a shared host to a Linode VPS. It's all been going smoothly until I starting trying to move my Moveable Type blog which runs using a series of CGI scripts. I am running Ubuntu 10.04 and Apache2. After hours of messing about I got a PERL hello world script (hello.cgi) to execute from a the web browser in the root HTML directory. Here's the script:

#!/usr/bin/perl -w
use strict;
print "Content-Type: text/html\n\nHello world!";

I got this working by adding the following to the /etc/apache2/sites-available/mysitename.com file.

 <directory srv="" www="" mysitename.com="" public_html="">Options +ExecCGI
    AddHandler cgi-script .cgi</directory> 

But I want to execute CGI scripts in the /srv/www/mysitename.com/public_html/mt/ directory, so I changed the directory in the entry above to that path and when I view the hello world script in that folder via a browser I see the source for the hello.cgi script rather than the output. Clearly something isn't right. I've spent more than enough time trying to work this out myself and the time has come to ask for help. So, anyone got any suggestions? Please keep answers simple I really am just learning to tread water Linux/Apache2 wise here!

2 Replies

Did you make the scripts executable?

Yes, I chmod 755 the /srv/www/mysitename.com/public_html/mt/hello.cgi script. Tried 777 too, no luck then either.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct