How to configure Apache + cgi in Linux

Source: Internet
Author: User
The configuration method of Apache + cgi in Linux-Linux Enterprise Application-Linux server application information. For details, refer to the following section. This document assumes that you have installed linux (the linux version in this article is Fedora Core3) and have the root permission.

1. install apache
First download the latest version of apache http server to the apache home page, the address is http://httpd.apache.org/

This article is written in apache version 2.2.0. If you want to use this version, click: http://mirror.vmmatrix.net/apache/httpd/httpd-2.2.0.tar.gz

Install apache:
Switch to the directory where httpd-2.2.0.tar.gz is located, and then:
# Tar xvzf httpd-2.2.0.tar.gz

There is a folder httpd-2.2.0 under the directory, switch to the folder:
# Cd./httpd-2.2.0

I don't know which folder you want to install apache. Suppose you want to install apache under/usr/local/apache2 /,

Enter the following command:
#./Configure -- prefix =/usr/local/apache2
# Make
# Make install

After running these three commands, apache will be installed in your/usr/local/apache2 directory.

Switch to the directory to see what is found.
# Cd./usr/local/apache2
# Ls

The directory contains/bin,/conf,/htdocs,/cgi-bin, and so on. apache is not started yet. We start apache using the tool apachectl in the/bin directory. First, switch to the/bin directory:

# Cd./bin
Then start:
#./Apachectl start

In this case, enter http: // localhost/in the address bar to check whether the information is successful? (What I see is "It works! "), Of course, different versions will be different, depending on your/htdocs index.html content.

Replace/usr/local/apache2/htdocs/index.html with your page file.

Here, we assume that your apache server has been installed successfully. If you have any questions, please search online or contact me:
Lonestep AT gmail D. T com

2. Configure apache to execute the cgi program
By default, the cgi program must be placed in the cgi-bin directory. Let's configure the cgi program under cgi-bin to be correctly executed, the following describes how to run the cgi program in another directory.

1). We have installed apache in the/usr/local/apache2 directory and switched to the/usr/local/apache2/conf directory, which contains an httpd. conf file, edit this file:

# Cd/usr/local/apache2/conf
# Vi httpd. conf (assume that your text editor is vi. If you use other editors such as emacs, gedit, and kedit, replace vi with their commands)

Find a row, for example:
# ScriptAlias/cgi-bin/"/usr/local/apache2/cgi-bin /"

Remove '#' from the front of this line and restart apache:
# Cd./bin (or cd/usr/local/apache2/bin)
#./Apachectl restart

OK. If you put a cgi program 'test. cid' to cgi-bin

Enter http: // localhost/cgi-bin/test. cgi to check whether execution can be performed>?

If not, please send me an email

2) If you want to change the cgi directory (the default cgi-bin directory is not used ),
ScriptAlias/cgi-bin/"/usr/local/apache2/cgi-bin/" is:
ScriptAlias/SomeOtherDirectory/"/usr/local/apache2/cgi-bin /"

Then restart apache.

The above process is relatively simple. If you have encountered a problem that is not involved in this article, or different from the assumptions in this article, please first go to the Internet to find a solution.
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.