Report this

What is the reason for this report?

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

Posted on August 4, 2014

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?


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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>
		Define ENABLE_USR_LIB_CGI_BIN
	</IfModule>

	<IfModule mod_cgid.c>
		Define ENABLE_USR_LIB_CGI_BIN
	</IfModule>

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

Finally, you must restart Apache:

sudo service apache2 restart

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.