Environment DescriptionSystem:
Linux luogw-pc 3.5.0-48-generic #72 ~precise1-ubuntu SMP Tue Mar 20:09:08 UTC x86_64 x86_64 x86_64 gnu/linux
Apache: (apt-get installation mode)
Server version:apache/2.2.22 (Ubuntu)
Server BUILT:APR 17 2014 21:49:25
Step One: Verify that the APACHE2 server is enabled for CGI
View related resources Discovery is turned on by default
/etc/apache2/sites-enabled/000-default has the following contents: scriptalias/cgi-bin//usr/lib/cgi-bin/<directory "/usr/lib/ Cgi-bin ">allowoverride noneoptions +execcgi-multiviews +symlinksifownermatchorder allow,denyAllow from all</ Directory>
means to place the CGI level in the/usr/lin/cgi-bin/directory, and then access it via the URL of the (local) http://localhost/cgi-bin/script name
Note: See a gsearch.cgi under the/usr/lin/cgi-bin
Write a demo and try test.pl.
#!/usr/bin/perlprint "content-type:text/html\n\n";p rint "Hello, World";
Oh no, I don't see the familiar Hello, world
Instinctive response, script does not have execute permission?, do it (sudo chmod +x test.pl)
Try again, OK got it
second step, try the python version of Hello, worldtest.py
#! /usr/bin/pythonprint "content-type:text/html\n\n" print "Python:" Print "Hello, world."
Run it
Summary1.ubuntu 12.04 APACH2 installed by Apt-get Install the default is to open the cgi,cgi script to store the path is/usr/lib/cgi-bin/
No need to customize the configuration, you can start a simple learning
2. The URL of the access script is the host domain name or the ip/cgi-bin/script name
3. Scripts require executable permissions
References
Http://apache.jz123.cn/howto/cgi.html