I just install Ubuntu 13.10 and I am trying to install Apache. But when I tried to run a perl file in cgi-bin, the browser showed only plain text.
My default.conf of Apache is below:
AddHandler cgi-script .cgi .pl
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +Indexes +ExecCGI +MultiViews +SymLinksIfOwnerMatch
#Order allow,deny
Require all granted
Allow from all
</Directory>
This is my perl cgi file:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n";
print "<title> PERL CGI</title>\n";
print "<body>";
print "hello perl-cgi!!!!!!!";
print "</body>";
print "</html>\n";
I have turned on the Handler in mime.conf The file is in /usr/lib/cgi-bin, and I run it as http not file:///. I have also installed mod_perl. I am new to Apache. I have searched for several hours, try endless Apache configurations, read Apache document but still cannot solve it. Is it because the "+ExecCGI" code has some problem? I saw another person also meet similar problem after updating Ubuntu 12.04 to 13.10. Maybe Ubuntu is the problem? Please help. The Apache configuration and Ubuntu permission almost drive me mad.
Let's make it executable by typing a sudo chmod +x /var/www/cgi-bin/loggedin.sh and hit enter. We need to turn on an SELinux Boolean to allow CGI scripts. Type in clear and then type in sudo setsebool -P httpd_enable_cgi 1 and hit enter. Now let's restart Apache.
Try with this command:
sudo a2enmod cgi
Then restart apache!
I encountered this problem when trying to setup bugzilla in Ubuntu 14.04 @Andrew's answer was helful and so was @Kevin's links.. so other than enabling cgi, ensure that perl's module for apache2 is installed. You can do this by:
sudo apt-get install libapache2-mod-perl2
This will automatically enable the module as well as restart apache server. If not do that manually.
Don't have enough rep to upvote both of you, so thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With