Use ApacheServer to configure php and cgi servers

Source: Internet
Author: User
Tags ultraedit
More and more webmasters need to know how to configure their own php and cgi servers in windows to debug cgi and php programs locally. We can use Apache (for windows) to solve this problem: The following articles about installing and configuring ApacheServer in a single Windows environment are compiled by myself. If you are in Windows Apache

More and more webmasters need to know how to configure their own php and cgi servers in windows to debug cgi and php programs locally.

We can use Apache (windows version) to solve this problem: The following articles about installing and configuring Apache Server in a single Windows environment are compiled by myself. If you are testing your website in a Windows single-host environment, we recommend that you refer to it.

It mainly includes installing and configuring Apache Server, using Perl CGI scripts, and using PHP scripts.

-- For some content, see Apache Server System Administrator Manual.

  1. installation in Windows

Of course, you must first have an Apache installation program. Visit http://www.apache.org/dist. Here is a list of Apache image sites worldwide. find the one closest to you. If you are in China, we suggest you go to the software house to check it out. The file name of A pacheinstaller is apache_1_3_x.win32.exe. Run it on your machine.

The installer will prompt you to modify the default directory C: \ Program Files \ Apache Group \ Apache for Apache installation. To facilitate future configuration and maintenance, we recommend that you install it in the root directory, for example, C: \ Apache. Then, you will be prompted to select the installation type. we recommend that you select "cuz tom". In this way, you will know what to install. Specific projects include Application File, Source Code, Apache Manual, Additional Modules, and Icons), Repuired Directories (required directory ). You can decide how to install it based on your situation.

If everything goes well (there should be no problem at this time), the installation will be completed soon. Apache will automatically complete some basic configuration, you can use the UltraEdit-32 (or other text editing software) to open the c onf \ httpd. conf file for a general understanding.

II. configure Apache Server

The first step here is the basic configuration so that your Apache Server can run as you wish.

Open the conf \ httpd. conf file with a UltraEdit-32 (or other text editing software.

1. find ServerName. Your domain name is defined here. In this way, when the Apache Server is running, you can access your site in the browser. If there is # above, remember to delete it, which is the comment mark of conf.

2. find ServerAdmin. Enter your email address here. If you use it only on a single machine, it doesn't matter if you don't change it.

3. search. There is an option below. remove All the following parameters and add an All (case sensitive! The same below .); Then there is an Allow Override statement, which also removes All the following parameters and adds an All.

4. find DocumentRoot. This statement specifies the path of your website, that is, the directory on your home page. You can use the default one or specify one by yourself, but remember, do not end this sentence? Quot ;/". Note that "\" of the directory is written as "/" in Apache Server "/".

5. find the DirectoryIndex. This is the first homepage displayed on your site.
After these changes, you can start Apache Server. Did you see your home page? If not, follow the steps above to modify it carefully.

III. added support for Perl CGI scripts

To make your Apache Server support CGI scripts, you must first install Perl for Win32. The installation process is not detailed. Assume that Perl is installed in the C: \ Perl directory. Open the httpd. conf file.

1. find ScriptAlias/cgi-bin/"C:/Apache/cgi-bin /". Delete the previous # and point the path in "" to the directory where you store the CGI script, that is, the CGI script in this directory can be executed.

2. search. Point the path in "" to the directory where your CGI script is stored, which must be the same as the above. Change the Options and Allow Override parameters to All.

3. find AddHandler cgi-script. cgi. Delete the previous # and Add. pl.
Note: in the CGI script, the Perl interpretation path is changed :#! C: \ perl \ bin \ perl. Otherwise, a 500 error occurs.

4. added support for PHP scripts

Similarly, you also need to install the Windows version of PHP. Suppose the installation is in the C: \ php directory.

Add the following to the httpd. conf file:
ScriptAlias/php/"c:/php /"
AddType application/x-httpd-php3. php3. php. phtml
Action application/x-httpd-php3 "/php/php.exe"

Your PHP script can be placed anywhere on the site (except cgi-bin ).

Now, your Apache Server supports both CGI and PHP.

How are you doing. Good luck!

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.