Mobile app version of vmapp.org
Login or Join
Sarah324

: Index.pl getting downloaded instead of executing on Ubuntu 12.04 and Apache 2.2.22 I have installed Apache 2.2.22 on Ubuntu 12.04. But in browser when I type localhost, it gives index.pl file

@Sarah324

Posted in: #Apache2 #Ubuntu

I have installed Apache 2.2.22 on Ubuntu 12.04. But in browser when I type localhost, it gives index.pl file to download instead of executing it. What I tried:
1. chmod 755 index.pl
2. Adding line DirectoryIndex index.pl index.html to etc/apache2/site-available/example.com, which finally looks like below.

I have done these things before on Windows machine. But the directory structure is different in Windows and Ubuntu. Httpd.conf file is blank in Ubuntu. And while searching through directories I found no. of files similar to configuration file. So I am confused where exactly I have to make configuration changes.

Update:
My index.html has meta tag as follows: meta http-equiv="refresh" content="0; URL='cgi-bin/index.pl'". Index.html file resides in var/www/example.com/public_html folder. In this folder I created folder cgi-bin with index.pl file in it. The browser when typed localhost give following error: 404 /cgi-bin/index.pl was not found on this server. And configuration file called example.com (etc/apache2/sites-available) has following line: ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
DocumentRoot /var/www/example.com/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/example.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# This line was added by me
DirectoryIndex index.html index.pl
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
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>


Update:Below is changes which I made after following krowe's suggestions, and it worked.

ScriptAlias /cgi-bin/ /var/www/example.com/public_html/cgi-bin/
<Directory "/var/www/example.com/public_html/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
AddHandler cgi-script .cgi .pl
Allow from all
</Directory>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sarah324

1 Comments

Sorted by latest first Latest Oldest Best

 

@Karen161

Add this line to your /etc/apache2/apache2.conf file:

AddHandler cgi-script .cgi .pl


And put your scripts in /usr/lib/cgi-bin/ .

Ubuntu separates its server configuration from its site configuration. Look in your /etc/apache2/sites-available directory for the virtual host configurations. Then create links to those in /etc/apache2/sites-enabled to enable them.

Restart your server after changing any of this: sudo service apache2 restart

You should be able to access it from: example.com/cgi-bin/index.pl
Also, I would not use a DirectoryIndex index.html index.pl line at all. Just specify your exact cgi file when needed.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme