0

I am using Apache 2 server.
Can anyone please tell me where to put cgi files in ubuntu
Please explain the steps to execute the cgi scripts through the browser?

0
0

Create a directory '/var/www/http/cgi-bin'
Place your script 'program_name.cgi' there
in browser: http://localhost/cgi-bin/program_name.cgi
If it is not working, you should enable executing cgi scripts in apache config file

0

This seems to work on Ubuntu14:

sudo bash
cat <<'E' > /etc/apache2/conf-available/mycgis.conf
ScriptAlias /helloworld "/var/www/cgi/helloworld.pl"
E
a2enconf mycgis            #enables the new mycgis.conf file
a2enmod cgi                #enables the cgi module (unless already enabled)
service apache2 restart    #after conf change restart is needed
mkdir /var/www/cgi
cat <<'E' > /var/www/cgi/helloworld.pl     #a simple cgi script
#!/usr/bin/perl
print "Content-Type: text/html\n\nHello world!\n";
E
chmod +x /var/www/cgi/helloworld.pl        #make it executable
curl 127.0.0.1/helloworld                  #test it (or use a browser)
3
  • Can you explain what these commands are going? Also, OP asked WHERE the CGI scripts were installed, and while this script appears to set things you, without explanation you may leave OP no more learned than before. Please, just a small amount of explanation will make your answers much, much better. – music2myear Jan 20 '17 at 22:18
  • You can put cgi scripts wherever you want as long as you tell apache about it. The man command more often than not explains plenty. – Kjetil S. Jan 21 '17 at 19:23
  • Thanks for the info. Man can be helpful (RFTM and all that) but is often also overwhelming and will contain information extraneous to the desired function. Adding explanatory information to your post makes it easy on the OP and makes your answer more helpful. – music2myear Jan 23 '17 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.