Recently, a lot of friends asked me about the installation process of PHP under Windows XP, just recently I successfully installed the PHP4.23 in a modular manner on my own machine. Since so many friends need it, I'll take the most common IIS and Apache servers for example, write the PHP installation process under Windows XP, hoping to help a friend to install PHP. Without special instructions, the following introduction also applies to the Win2000 version.
First, overview:
Between installations, you must first understand the two different modes of PHP installation, one is the CGI mode (CGI executable), and the other is modular installation. This can be distinguished by: in CGI mode, if the client requests a PHP file, The Web server calls Php.exe to interpret the file, the results are then returned to the client in the form of a Web page, and in Modularity, PHP is started and run with the Web server, so in a way, the PHP4 installed in the Apache module has better security than the CGI mode and better Execution efficiency and speed.
Second, the SOFTWARE preparation:
The so-called "工欲善其事 its prerequisite", in order to run PHP on your machine must first prepare the required software.
A Web server
First you need a Web server to support the operation of PHP, here we choose the two most common, but also use the most of the two servers to introduce separately.
1.IIS (Internet infomation Server)
IIS presumably everyone is not unfamiliar with it, in Window2000, IIS is installed by default. You can open it by "Start-> settings-> Control Panel-> admin tools->internet Information Service." If you are not installed, you can install it by using the Windows Add Remove component. There are a lot of introductions about IIS installed on the Web, and this is no longer introduced here.
2.Apache
Apache is also a very good Web server program, and it is also the author's favorite Web server. It's not only small, flexible, but also very stable in use, without some inexplicable errors (IIS is relatively poor), and more importantly, it supports the installation of PHP into one of its modules.
Therefore, I strongly recommend you use Apache to install PHP. Now the common Apache has two versions, one is 1.36, the other is the Apache2 series version, where you are recommended to use the Apache2 version, you can download the latest version on the official Apache website.
Apache Official website: http://www.apache.org
Two PHP Program
The latest PHP code you can download on its official website http://www.php.net/downloads.php, note to choose that kind of zip package, can not choose to install the kind, in writing this, the latest version of PHP is 4.23 version, the size is 5417KB. Of course, you can also download the site in the download section. All right. The software is ready, the following is the start of our PHP installation Tour bar!
Note: The following installation process is based on the PHP4.23 version, Apache2.040.
Third, install under IIS:
1. Download the downloaded PHP installation package to your C-packing directory (this is the choice of the C root directory disk is for later modification and debugging convenient to use, you can also choose a different directory, after decompression should be able to get a similar "Php-4.2.3-win32" directory, the directory name changed to "PHP."
2. Open just decompression of the PHP directory, you will find that there is a file called "Php.ini-dist", this is the PHP configuration file, you need to rename it to "PHP.ini", and then copied to the system directory (if your system installed in the C disk, XP is "C:\ Windows ", Windows2000 is" C:\winnt ").
A lot of previous articles about PHP installation files said to modify the php.ini "Extension_dir" and "doc_root" values, but the author in the installation of PHP has not changed, nor any errors, it seems that these two parameters are not necessary. Of course, if you do not trust can also be modified. Change the doc_root to your server's root directory, and change the extension_dir to the absolute path of the Extensions folder in your PHP installation folder.
3. Open your IIS Information Service console, right-click the "Default Web Site" icon, select Properties, open the Default Web site properties selection, and then select the Home Directory tab
Click on the "Configure" button and you will see another tab out of the document type you have defined. Click the "Add" button, in the Executable text box of the Out dialog box, tap the absolute path of your php.exe, plus "%s%s", here is "C:\php\php.exe%s", and the Extension text box writes the suffix name you requested in the PHP program, where we write " . PHP, the following options are set by default.
4. Ok. Now try to save the following sections of code as a PHP file, and then put it into one of your virtual directories to visit to see if there are any normal results.
The following are the referenced contents: Phpinfo (); ?> |
Perhaps you will encounter the following output results:
The following are the referenced contents: Security alert! The PHP CGI cannot be accessed directly. This PHP CGI binary is compiled With Force-cgi-redirect enabled. This is means that a page would be Served up if the Redirect_status CGI variable is set, e.g. via an Apache Action directive. For more information as to why This behaviour exists, The manual page for CGI security. For more information about changing This behaviour or re-enabling this webserver, Consult the installation file that Came with this distribution, or visit the manual page. |
Don't worry, this is because PHP is now running in CGI in IIS, and your PHP configuration file does not open this one. If you see a warning above, you need to open your php.ini file, and then look for "Cgi.force_redirect = 1" Such a sentence, this sentence before the semicolon removed, and then the 1 to 0 on the OK, and now to refresh your just the page, if there is no accident , the result on your screen should be similar to my screenshot below. To this end, the installation of PHP on IIS is complete.