3

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!

Solution Found:

<VirtualHost *:80>
  ServerName www.sitename.com
  ServerAdmin general@sitename.com
  ServerAlias sitename.com
  DocumentRoot /srv/www/mysitename.com/public_html/
  ErrorLog /srv/www/mysitename.com/logs/error.log
  CustomLog /srv/www/mysitename.com/logs/access.log combined
  AddHandler cgi-script .cgi .pl
</VirtualHost>

<Directory /srv/www/mysitename.com/public_html/>
    AllowOverride All
    Order allow,deny
    Allow from all
    Options All +SymLinksIfOwnerMatch +FollowSymLinks +ExecCGI -Indexes -MultiViews
</Directory>

<Directory /srv/www/mysitename.com/public_html/mt/>
    AllowOverride All
    Order allow,deny
    Allow from all
    Options All +SymLinksIfOwnerMatch +FollowSymLinks +ExecCGI -Indexes -MultiViews
</Directory>
nemmy
  • 753
  • 1
  • 6
  • 19

1 Answers1

3

Have you added mod-perl?

Add these lines

AddType perl-script .pl
AddHandler perl-script .htm

specify a DirectoryIndex

(outside the Directory block)

Are you using vhosts too? I wouldn't normally do things the way you're doing them to be honest.

tumbler
  • 86
  • 3
  • Yes, mod-perl is added. Not sure what effect DirectoryIndex would have on the problem I am seeing. No idea what vhosts is (told you I am a newbie :) ) – nemmy Dec 23 '10 at 22:42