Here, we will take PhP5 as an example to introduce the installation and configuration of PHP and Apache in windows.
I. program download
You can download the php5.2.4zip package from here and Apache from here.
Ii. Program Installation
1. Apache installation is relatively simple. Double-click the downloaded installer to install Apache on our computer;
2. decompress the downloaded PHP package (with the zip extension) to the C root directory, and rename the directory "php ".
3. Program Configuration
1. Copy php5ts. DLL to the Windows path. Preferably in the Windows System directory
OS |
Path |
Windows 9x/me |
C:/Windows/System |
For Windows NT/2000 |
C:/winnt/system32 |
Windows NT/2000 Server Edition |
C:/winnt40/system32 |
Windows XP |
C:/Windows/system32 |
2. Set the PHP configuration file PHP. ini. The compressed 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;
3. Copy the selected INI file to the C:/Windows directory under Windows/9x/ME/XP;
4. Configure PHP in Apache. There are two ways to make PHP work under Windows Apache. One is to use CGI binary files, and the other is to use Apache module DLL. Either way, you must first stop the Apache server and then modify the httpd. conf file 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:
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 an Apache module, we must move it to winnt/system32 (Windows NT/2000) or Windows/system32 (Windows XP ), overwrite the original file (if any). For PhP5, 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 on Apache in a module:
; 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_2.dll"
Addtype application/X-httpd-PHP. php
Iv. Test
After such configuration, We have installed PHP and Apache servers. After installation, you also need to test whether our installation is correct.
1. Test Apache
Open IE and enter localhost in the address bar. If the Apache page appears, it means that Apache works properly.
2. Test PHP
We can write a PHP page to test whether PHP is correctly installed and configured.
<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: 80/hello. 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.