1 Download the installer
Apache can be downloaded from /dyn//httpd/binaries/win32/
PHP can be downloaded from.
2. Installer
1. The installation of Apache programs is relatively simple. We have downloaded a Windows installation program from the website. We can directly double-click to run it, so that we can facilitate Apache to install home on our computer.
2. What we need to pay attention to here is that when downloading PHP, you must download the zip package, rather than download the Installer. Unzip the PHP package we downloaded to the root directory under the C disk, and rename the extracted folder to php.
Three configuration
1. It is best to ensure that it is available regardless of the interface (CGI or SAPI) used, so this file must be placed 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 a valid PHP configuration file. The zip package includes two ini files, -dist and -recommended. -recommended is recommended because this file optimizes the default settings for performance and security.
Copy the selected ini file to a directory that PHP can find and rename it to . PHP is searched in the Windows directory by default:
3 Copy the selected ini file to %WINDIR% under Windows 9x/ME/XP, usually c:\windows.
Copy the selected ini file under Windows NT/2000 to %WINDIR% or %SYSTEMROOT%, usually c:\winnt or c:\winnt40 corresponding to the server version.
4 PHP settings in Apache
There are two ways to make PHP work in Apache under Windows. One is to use CGI binary files, and the other is to use Apache module DLLs. Regardless of that approach, you must first stop the Apache server and edit it to configure Apache and PHP to work together.
If we want to use CGI binary files, we need to insert the following directive into Apache's configuration file to set up the CGI binary files:
PHP is installed in CGI to Apache 2.0:
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/"
If we want to use PHP as a module of Apache 2.0, we must move to winnt/system32 (Windows NT/2000) or windows/system32 (Windows XP), overwrite the original file (if any). For PHP 5, this file is . Then we want to insert the following two lines into , so that our PHP is installed as Apache's PHP-Module:
PHP is installed in Apache 2.0 as a module:
; For PHP 4 do something like this:
LoadModule php4_module "c:/php/"
AddType application/x-httpd-php .php
; For PHP 5 do something like this:
LoadModule php5_module "c:/php/"
AddType application/x-httpd-php .php
After this configuration, we installed our PHP and Apache servers. We can simply test it:
1. Test Apache:
We open the browser and enter localhost in the address bar. If the Apache page can appear, it means that our Apache is working normally.
2. Test PHP settings:
We can simply write a PHP page, and we can use a text editor to enter the following code:
<html>
<head>
<title>
hello
</title>
</head>
<body>
<?php echo "hello,php"; ?>
</body>
</html>
Then save the file as, place it in the htdocs directory of Apache (we can also change this directory in the file), and then enter http://localhost/ in our browser. If hello can be displayed correctly, php means that our PHP configuration can work normally.
In this way, we can also design our PHP site in the future
Apache can be downloaded from /dyn//httpd/binaries/win32/
PHP can be downloaded from.
2. Installer
1. The installation of Apache programs is relatively simple. We have downloaded a Windows installation program from the website. We can directly double-click to run it, so that we can facilitate Apache to install home on our computer.
2. What we need to pay attention to here is that when downloading PHP, you must download the zip package, rather than download the Installer. Unzip the PHP package we downloaded to the root directory under the C disk, and rename the extracted folder to php.
Three configuration
1. It is best to ensure that it is available regardless of the interface (CGI or SAPI) used, so this file must be placed 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 a valid PHP configuration file. The zip package includes two ini files, -dist and -recommended. -recommended is recommended because this file optimizes the default settings for performance and security.
Copy the selected ini file to a directory that PHP can find and rename it to . PHP is searched in the Windows directory by default:
3 Copy the selected ini file to %WINDIR% under Windows 9x/ME/XP, usually c:\windows.
Copy the selected ini file under Windows NT/2000 to %WINDIR% or %SYSTEMROOT%, usually c:\winnt or c:\winnt40 corresponding to the server version.
4 PHP settings in Apache
There are two ways to make PHP work in Apache under Windows. One is to use CGI binary files, and the other is to use Apache module DLLs. Regardless of that approach, you must first stop the Apache server and edit it to configure Apache and PHP to work together.
If we want to use CGI binary files, we need to insert the following directive into Apache's configuration file to set up the CGI binary files:
PHP is installed in CGI to Apache 2.0:
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/"
If we want to use PHP as a module of Apache 2.0, we must move to winnt/system32 (Windows NT/2000) or windows/system32 (Windows XP), overwrite the original file (if any). For PHP 5, this file is . Then we want to insert the following two lines into , so that our PHP is installed as Apache's PHP-Module:
PHP is installed in Apache 2.0 as a module:
; For PHP 4 do something like this:
LoadModule php4_module "c:/php/"
AddType application/x-httpd-php .php
; For PHP 5 do something like this:
LoadModule php5_module "c:/php/"
AddType application/x-httpd-php .php
After this configuration, we installed our PHP and Apache servers. We can simply test it:
1. Test Apache:
We open the browser and enter localhost in the address bar. If the Apache page can appear, it means that our Apache is working normally.
2. Test PHP settings:
We can simply write a PHP page, and we can use a text editor to enter the following code:
<html>
<head>
<title>
hello
</title>
</head>
<body>
<?php echo "hello,php"; ?>
</body>
</html>
Then save the file as, place it in the htdocs directory of Apache (we can also change this directory in the file), and then enter http://localhost/ in our browser. If hello can be displayed correctly, php means that our PHP configuration can work normally.
In this way, we can also design our PHP site in the future