Implement CGI on the httpd server in Apache

Source: Internet
Author: User

(1) CGI scripts can also be used to create Web pages

CGI: Common Gateway Interface public Gateway Interface Protocol

On the httpd server, you can use CGI to create web pages.

CGI mechanism: Convert scripts to Client browsers to identify the webpage format, namely, Content-Type: text/html

The CGI executor must be root, which is dangerous.

1. Dependent module mod_alias mode_cgi

LoadModule alias_module modules/mod_alias.soLoadModule cgid_module modules/mod_cgid.soLoadModule cgi_module modules/mod_cgi.so

Need to be enabled (before Module # delete)

2. Create a CGI script

Create a cgiscript script in the/usr/local/apache/cgi-bin/directory.

# Vim/usr/local/apache/cgi-bin/cgiscript

Script content #! /Bin/bash # cat <EOFContent-Type: text/html <pre> Thehostnameis: 'hostname' Thetimeis: 'date' </pre> EOF

3. Global configuration page access properties: Add ExecCGI

ExecCGI function: allows the mod_cgi module to execute CGI scripts

4. Test

Success ~~

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.