Building Chinese Web Sites using PHP - Version 2.14, by Dr. Herong Yang
Configuring Apache for PHP CGI Scripts
This section describes how to configure Apache server to support PHP CGI scripts.
With both PHP 5 and Apache 2 installed on my Windows system, I continued to configure the Apache server to support PHP CGI scripts:
1. Open the Apache configuration file, \local\apache\conf\httpd.conf, in a text editor
2. First I have to define a CGI script directory alias, mapping an Apache document directory to a real directory where php-cgi.exe is located. Go to alias_module section and add one line:
<IfModule alias_module> ... ScriptAlias /cgi-bin-php/ "/local/php/" </IfModule>
3. Now I need to add an access control section for this directory as:
<Directory "/local/php/"> AllowOverride None Options None Order allow,deny Allow from all </Directory>
4. Next, I have to define a new MIME type to support the .php file extension. Go to mime_module section and one line:
<IfModule mime_module> ... AddType application/x-httpd-php .php </IfModule>
5. The last setting is to tell Apache to serve the new MIME type with php-cgi.exe located in the directory alias /cgi-bin-php/: At the root level below the LoadModule section, define an "Action" entry:
#LoadModule ssl_module modules/mod_ssl.so Action application/x-httpd-php "/cgi-bin-php/php-cgi.exe"
6. The configuration changes are done. Now restart the Apache server by clicking Start > All Programs > Apache Server 2.2.4 > Control Apache Server > Restart.
Another way to integrate Apache with PHP is to set PHP as a load module. This is more efficient than the CGI script interface. But for my personal testing purpose, the CGI script interface is good enough.
Last update: 2015.
Table of Contents
PHP Installation on Windows Systems
►Integrating PHP with Apache Web Server
Downloading Apache 2.2.4 Binary for Windows
Installing Apache 2.2.4 on Windows Systems
Publishing HTML Documents as Web Pages
►Configuring Apache for PHP CGI Scripts
Publishing PHP Scripts as Web Pages
charset="*" - Encodings on Chinese Web Pages
Chinese Characters in PHP String Literals
Multibyte String Functions in UTF-8 Encoding
Input Text Data from Web Forms
Input Chinese Text Data from Web Forms
MySQL - Installation on Windows
MySQL - Connecting PHP to Database
MySQL - Character Set and Encoding
MySQL - Sending Non-ASCII Text to MySQL
Retrieving Chinese Text from Database to Web Pages