Add Apache2 Perl Support in Ubuntu 12.04

Add Apache2 Perl Support in Ubuntu 12.04

  • sudo apt-get install libapache2-mod-perl2 (if Ubuntu Server use aptitude install)
  • ( if the perl-mod is not enabled, you may use: sudo a2enmod perl )
  • mkdir ~/www/cgi-bin (it could be anywhere, just take it as an example)
  • Add the following code to /etc/apache2/sites-enabled/000-default file before </VirtualHost> line.
# Use 'ModPerl' module to process '.pl' and '.cgi' file
<Files ~ "\.(pl|cgi)$">
    SetHandler perl-script
    PerlResponseHandler ModPerl::PerlRun
    Options +ExecCGI
    PerlSendHeader On
</Files>

# Use '/home/www/cgi-bin/' as a CGI Directory
ScriptAlias /cgi-bin/ /home/www/cgi-bin/
<Directory "/home/www/cgi-bin/">
    Options ExecCGI
    AddHandler cgi-script cgi pl
</Directory>
  • Restart the apache2 service: sudo service apache2 restart
  • Test the perl environment:
  • Create file test.pl in /home/www/cgi-bin/:
#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";

for ($i=0; $i<10; $i++)
{
print $i."<br />";
}
  • Note 1: #!/usr/bin/perl -w is used to locate the perl parser which could be located by which perl.
  • Note 2: code print "Content-type: text/html\r\n\r\n"; is required to make it a valid CGI program.

chkconfig on Ubuntu 12.04 causing '/sbin/insserv: No such file or directory' Problem

chkconfig on Ubuntu 12.04 causing ‘/sbin/insserv: No such file or directory’ Problem

Problem Description:

I tried to start sshd at boot using chkconfig on Ubuntu 12.04.

As a result, I used `chkconfig --level 35 ssh on` to start it as default, however I got the following error.

/sbin/insserv: No such file or directory
/sbin/insserv: No such file or directory

How to solve:

ln -s /usr/lib/insserv/insserv /sbin/insserv