Enabling CGI/Perl scripts in Ubuntu Apache 2

Apache 2 in Ubuntu is configured to work with .pl/.cgi scripts by default. But it won’t work as cgi module is not loaded. To activate CGI scripts, you need to run

sudo a2enmod cgi
sudo service apache2 restart

Apache configuration used for localhost in my PC is

userName@fwhlin:~$ cat /etc/apache2/sites-available/000-default.conf
        ServerAdmin webmaster@localhost
        SetEnv APP_ENV "dev"

        DocumentRoot /home/userName/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /home/userName/www/>
                Options All 
                AllowOverride All
                Require all granted
                Order allow,deny
                allow from all

        ScriptAlias /cgi-bin/ /home/userName/www/cgi-bin/

        <Directory "/home/userName/www/cgi-bin/">
                AllowOverride None
                Require all granted
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        AddHandler cgi-script .cgi .pl

        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


# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Posted in Apache