Question

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

  • Posted on August 4, 2014
  • khinelayAsked by khinelay

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?

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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