The following uses PhP5 as an example to describe how to install and configure Apache and PhP5 in windows.
1. Download the installer
Apache can be downloaded from http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/
PHP can be downloaded from http://www.php.net.
Ii. Installer
1. Apache installation is relatively simple. We have a Windows installation program from the website. We can double-click it to run it, in this way, Apache is deployed on our computer.
2. We should note that the zip package must be downloaded when downloading PHP, rather than the installer. decompress the downloaded PHP package to the root directory of drive C and change the decompressed folder to PhP.
Three configurations
1 It is best to ensure that php5ts. dll is available regardless of the Interface (CGI or SAPI) used. Therefore, you must put this file in the Windows path. The best location is the Windows System directory:
C:/Windows/System for Windows 9x/me
C:/winnt/system32 for Windows NT/2000 or C:/winnt40/system32 for Windows NT/2000 Server Edition
C:/Windows/system32 for Windows XP
2. The next step is to set up a valid PHP configuration file, PHP. ini. The package contains two INI files: php. ini-Dist and PHP. ini-recommended. We recommend that you use PHP. ini-recommended because this file optimizes the performance and security of the default settings.
Copy the selected INI file to the directory that PHP can find and change it to PhP. ini. By default, PHP searches for PHP. ini in the Windows directory:
3. In Windows 9x/ME/XP, copy the selected INI file to % WINDIR %, usually C:/windows.
In Windows NT/2000, copy the selected INI file to % WINDIR % or % SystemRoot %. Generally, C:/winnt or C:/winnt40 corresponds to the server version.
4. php settings in Apache
There are two ways to make PHP work on Apache in windows. One is to use CGI binary files, and the other is to use Apache module DLL. Regardless of the method, you must first stop the Apache server and then edit httpd. conf to configure Apache and PHP to work together.
To use a CGI binary file, insert the following command into the httpd. conf configuration file of Apache to set the CGI binary file:
Install PHP in CGI Mode to Apache 2.0:
ScriptAlias/PHP/"C:/PHP /"
Addtype application/X-httpd-PHP. php
Action application/X-httpd-PHP "/PHP/php.exe"
If we want to use PHP as the module of Apache 2.0, we must move php4ts. DLL to winnt/system32 (Windows NT/2000) or Windows/system32 (Windows XP), overwrite the original file (if any). For PHP 5, this file is php5ts. DLL. Then we need to insert the following two lines into httpd. conf so that our PHP can be installed as the PHP-module of Apache:
Install PHP in modules to Apache 2.0:
; For PHP 4 do something like this:
Loadmodule php4_module "C:/PHP/php4apache2. dll"
Addtype application/X-httpd-PHP. php
; For PHP 5 do something like this:
Loadmodule php5_module "C:/PHP/php5apache2. dll"
Addtype application/X-httpd-PHP. php
After such configuration, We have installed our PHP and Apache servers. We can perform a simple test:
1. Test Apache:
Open the browser and enter localhost in the address bar. If the Apache page appears, it means that Apache works properly.
2. Test PHP settings:
We can simply compile a PHP page. We can use a text editor and enter the following code:
<HTML>
<Head>
<Title>
Hello
</Title>
</Head>
<Body>
<? PHP echo "Hello, PHP";?>
</Body>
</Html>
Save the file as hello. PHP, put it in the Apache htdocs directory (we can also. in the conf file), and then input http: // localhost/hello in our browser. PHP. If you can correctly display hello, PHP indicates that our PHP configuration can work normally.
In this way, we can also design our PHP site.