Running CGI programs in Apache

Source: Internet
Author: User

CGI is the site of a variety of background programs, the program can be run through the web, CGI can be written by C, can also be written by Shell,python

How to run various CGI programs in Apache, such as Shell Perl and other programs

1. Add scriptalias/cgi "/usr/local/httpd/cgi-bin/" in Apache Master profile httpd.conf and restart httpd

service httpd  restart

2. Prepare a CGI program:

vi   /usr/local/httpd/cgi-bin/test.sh
#!/bin/sh
echo ‘Content-Type: text/html‘
echo
echo "this is cgi"
pwd
echo 
ls
echo
#set
date
ls  /tmp

The Access address is:

http://ip/cgi/test.sh

You can also write a Perl CGI program:

Another example of a Perl program

vi   /usr/local/httpd/cgi-bin/test2.pl  
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "Hello, World.";

Running CGI programs in Apache

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.