1

I have been tearing my hair out trying to get this working but no matter what I do I can't get .pl files to execute in the cgi-bin of my virtual directory. I have been searching for solutions for the past 4 hours and have tried everything I have come across, and nothing works for me. Perl files are executing perfectly for my default site, just not for my virtual host. The only mopdified file in my Apache2 configuration is the /etc/apache2/sites-available/default file, and currently it is as follows (except for the sitename):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
   </Directory>

    <Directory /var/www/cgi-bin>
            Options +ExecCGI
            AllowOverride All
            AddHandler cgi-script cgi pl
            Order allow,deny
            allow from all
    </Directory>


#       ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#       <Directory "/usr/lib/cgi-bin">
#               AllowOverride All
#               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#               Order allow,deny
#               Allow from all
#       </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>


<VirtualHost *:80>
ServerAlias subdom.mysite.com
DocumentRoot /var/www/subdom
    <Directory /var/www/subdom/cgi-bin>
            Options +ExecCGI
            AllowOverride All
            AddHandler cgi-script cgi pl
            Order allow,deny
            allow from all
    </Directory>

</VirtualHost>

Any and all help is very much appreciated.

user1222302
  • 31
  • 2
  • 7
  • What's getting written to the apache `access` and `error` logs? Is at least one of the logs being updated each time you try to execute the script? – dwarring Feb 21 '12 at 05:26
  • I've resolved the issue myself in the end. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ # Changed to ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ # Was missing the last forward slash. – user1222302 Feb 21 '12 at 08:55

2 Answers2

0

This sounds and looks familiar:

In my case, I made a mistake with my ScriptAlias directive. I uncommented the original one, but forgot to configure a new one.

As soon as I correctly changed and saved my sites-available/default config file from this:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">

.. to this:

ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">

.. and reloaded apache2, it just worked: it stopped displaying my scripts as text, and started running them as a script. Also, it no longer displayed /var/www/cgi-bin as a directory in the browser, but now correctly displays the error:

Forbidden 
You don't have permission to access /cgi-bin/ on this server.
Raoul
  • 1,876
  • 1
  • 14
  • 14
0

I think it is a typo: You need a period before pl.

AddHandler cgi-script .cgi .pl

Also check this: How do I configure Apache 2 to run Perl CGI scripts?

Community
  • 1
  • 1
user1126070
  • 5,059
  • 1
  • 16
  • 15