IP redirects to folder/index.html not www/html/index.html, cgi-bin from other location

August 4, 2014 3.2k views

I am using ec2(Ubuntu) for perl program.

  1. When I call my IP, I want to show the IP/foldername/index.html How to do that- which one is suitable for me? redirect or virtual host. because I'm using Perl and I'm afraid that my settings will conflict with another and next question is
  2. I want to run my perl script from IP/foldername/cgi-bin/myperl.pl (Now I can only run from /usr/lib/cgi-bin How to configure it?
1 Answer

For your first question, all you need to do is change DocumentRoot /var/www/html to DocumentRoot /path/to/some/folder in your existing VirtualHost

For your second question, you need to a few things to get that set up. First, run:

sudo apt-get install libapache2-mod-perl2
sudo a2enmod cgi
sudo a2enmod perl

Then you must edit /etc/apache2/conf-enabled/serve-cgi-bin.conf Change the highlighted paths to the folder hosting the Perl scripts:

<IfModule mod_alias.c>
    <IfModule mod_cgi.c>

    <IfModule mod_cgid.c>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Require all granted

Finally, you must restart Apache:

sudo service apache2 restart
Have another answer? Share your knowledge.