--python of CGI programming in the preliminary interview

Source: Internet
Author: User


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.