Configure support for PHP and CGI on Windows's Apache server

  • 2020-05-14 05:23:31
  • OfStack

Now more and more personal homepage owners need to know how to configure their php,cgi servers under the windows system to facilitate local debugging of cgi and php programs.

We can do this once with Apache (windows version) : the following articles have been compiled by me on installing and configuring Apache Server on a standalone Windows environment. If you are testing your website in an Windows standalone environment, I suggest you refer to 1.

It mainly includes: installation and configuration of Apache Server; Use the Perl CGI script; Use the PHP script.

-- some contents refer to "Apache Server system administrator manual".

1. Installation under Windows

Of course, you have to have an Apache installer first. Might as well go to http: / / www apache. org/dist look. Here is a list of worldwide Apache mirror sites, find the one closest to you. If be in home, suggest you go to software room to see here. The file name of the installer 1 for A pache is apache_1_3_x.win32.exe. Think of it as your machine, and run it.

The installer will prompt you to change the default directory location for the Apache installation, C:Program FilesApache GroupApache. For future configuration and maintenance, it is recommended that you install it in the root directory, such as C:Apache. After that, you will be prompted to select the installation type, and it is recommended that you choose Cus tom (custom), so that you will know what is installed. The specific projects are Application File (application files), Source Code (source code), Apache Manual (Apache manual), Additional Modules (additional modules), Icons (ICONS), Repuired Directories (required directory). You can decide how to install it according to your situation.

If the first cut goes well (there should be no problem at this point), the installation will be completed soon. Apache will automatically do some basic configuration, you can use UltraEdit-32 (or other text editing software) to open the c onfhttpd.conf file to get a general understanding of 1.

2. Configure Apache Server

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

Open the confhttpd.conf file with UltraEdit-32 (or some other text editing software).

1. Find ServerName. Define your domain name here. That way, when Apache Server runs, you can access your site from your browser. If you have a # in front, delete it; this is the comment tag for conf.

2. Find ServerAdmin. Enter your E-Mail address here. If you only use a single machine, it doesn't matter whether you change it or not.

3. Find it. There is a sentence Options down, remove all the following parameters, and add an All (be case sensitive! The same below). ; Then there is a sentence Allow Override, which also takes out all the parameters and adds an All.

4. Find DocumentRoot. This statement specifies your site path, which is the directory where your home page is located. You can use the default, or you can specify one, but remember, there is no "/ "at the end of this sentence. Also note that the "/" of the table of contents is written as "/" in Apache Server.

5. Find DirectoryIndex. [www.etoow.com] This is the first home page of your site.
Once you've changed these, you can start Apache Server. Did you see your home page? If not, follow the steps above and modify them carefully.

3. Added support for Perl CGI scripts

To make your Apache Server support the CGI script, first install Perl for Win32 as well. The installation process is not described in detail. It is assumed that Perl is installed under the C:Perl directory. Open the httpd.conf file.

1. Find ScriptAlias/cgi-bin /" C:/Apache/ cgi-bin /". Remove the previous # and point the path in "" to the directory where you have the CGI script. That is, the CGI script in this directory can be executed.

2. Find it. Point the path in "" to the directory where you store the CGI script, as above. Change the parameters of Options, Allow Override to All.

3. Find AddHandler cgi-script.cgi. Remove the # in front and add.pl.
Note: the Perl explanation path in the CGI script is changed to: #! C: perlbinperl. Otherwise, 500 errors will occur.

4. Added support for PHP scripts

Again, you need to install the Windows version of PHP. Assume that you are installed in the C:php directory.

Add the following to the httpd.conf:


    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).

At this point, your Apache Server can support both CGI and PHP.

Well, not bad. Good luck!


Related articles: