Php4.23 install instances on IIS and apache2 in Windows XP

Source: Internet
Author: User
Tags sapi

Introduction: This is a detailed page of php4.23 installation instances on IIS and apache2 servers under Windows XP. It introduces the related knowledge, skills, and experience of PHP, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325320 'rolling = 'no'>

Nbsp; recently, many friends in the Forum asked me about the PHP installation process in Windows XP. Recently, I successfully installed php4.23 in a modular manner on my own machine. As many friends need it, I will take the most common IIS and Apache server as an example to write out the PHP installation process in Windows XP. I hope it will be helpful to those who want to install PHP. Unless otherwise specified, the following sections also apply to Win2000.
I. Overview:
During installation, you must first understand two different PHP installation modes: CGI executable and modular installation. In the cgimode, if the client requests a PHP file, the webserver calls php.exe to explain the file, and then returns the result to the client in the form of a webpage. In modularization, PHP is started and run together with the Web server. From a certain point of view, the PhP4 installed in the Apache module has better security and execution efficiency and speed than the CGI Mode.

2. Software preparation:
The saying goes, "you must first sharpen your tools to do something better." To run php on your machine, you must first prepare the required software.

(1) Web Servers

First, you need a web server to support the running of PHP. Here we will introduce the two most common and used servers.
1. IIS (Internet infomation server)
IIS must be familiar to everyone. In window2000, IIS is installed by default. You can open it through "start-> Settings-> Control Panel-> Administrative Tools-> Internet information service. If you have not installed it, you can install it through "add and delete components" in windows. There are many introductions on IIS installation.
 
2. Apache
Apache is also a very good Web ServerProgramIt is also my favorite Web server. It is not only small, flexible, but also very stable in the use process, there will be no inexplicable errors (IIS is relatively much worse), and more importantly, it also supports installing PHP into a module. Therefore, I strongly recommend that you use Apache to install PHP. Apache has two common versions: Version 1.36 and version 2. We recommend that you use apache2, you can download to the latest version on the Apache official website, you can also download to the author in this site (http://www.hooday.com) related download topic to write this articleArticleVersion (apache2.040 ).
Apache Official Website: http://www.apache.org

(2) PHP Program

Latest PHP ProgramCodeYou can go to its official website to renew. Of course, you can also download it from the download section on this site.

Okay. The software is ready. Let's start our PHP installation Journey :)
Note: The following installation processes are subject to php4.23 and apache2.040.

Iii. IIS installation:

1. decompress the downloaded PHP installation package to the root directory of your C drive (select the C root directory disk for later debugging convenience, you can also select a different directory ), after decompression, you should be able to get a directory similar to "php-4.2.3-Win32", change the directory name to "php ".
2. open the decompressed PHP Directory and you will find a directory named "php. ini-Dist file. This is the PHP configuration file. You need to rename it to "php. ini ", and then copy it to the system directory (If your system is attached to drive C, it is" C: \ Windows "under XP, and" C: \ WINNT "under Windows2000 ").
In the past, many articles about PHP installation files mentioned that PHP should be modified. in INI, the values of "extension_dir" and "doc_root" have not been changed and no errors have been made during PHP installation. It seems that these two parameters are not necessary. Of course, you can modify it if you are not at ease. Change doc_root to the root directory of your server, and change 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 website" icon, select Properties, open the default website attribute selection, and then select the "main directory" tab, as shown in:

 

Click the "Configure" button, and you will see a new tab, which is a defined document type. Click "add" to add "% S % s" to the absolute path of your php.exe In the executable file box of the dialog box, where "C: \ PHP \ php.exe % S % s ", in the extension text box, write the suffix you want the PHP program to process. Here we write ". PHP ", the following options can be set by default. For example:

 

4. All right. Now, try to save the following code into a PHP file with the suffix, and put it in your virtual directory for access to see if the result is normal.
<? PHP
Phpinfo ();
?>
You may encounter the following output:

Security alert! The php cgi cannot be accessed directly.
This php cgi binary was compiled with force-CGI-redirect enabled. This means that a page will only 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, see 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 running in IIS in CGI Mode, and this item is not opened in your PHP configuration file. If you see the above warning, you need to open your php. INI file, and then find "CGI. force_redirect = 1 ", remove the semicolon in front of this sentence, and change 1 to 0. Now, refresh your page, if there is no accident, the result on your screen should be similar to the screenshot below. At this point, the installation process of PHP on IIS has been completed. Note that the line in the figure shows that PHP is running in CGI Mode. (Click to enlarge)

 

 

4. install Apache:

We used a brand new version of Apache apache2 this time. It was still troublesome to install PHP in Apache before. Now, on The apache2 platform, we can easily install PHP in a modular way, the premise is that the PHP version must be later than 4.0. Of course, php3 is rarely used now. So this time we will only introduce how to install PHP in Apache in a modular way. If you want to know how to load PHP in CGI Mode in Apache, can refer to another article on this site "PHP + Apache in Win9x installation and configuration" (http://www.hooday.com /? N = readarticle & A = 34 ). Let's take a look at the modular installation of PHP.

1. run the downloaded apache2 Installation File to install Apache. During the installation process, you will be prompted to enter the host name, Administrator mailbox, and other mailboxes. The information can be modified after installation, therefore, you can rest assured that the input. When selecting the installation path, I suggest you select the installation path as the root directory of drive C. After "Next" step by step, you will find that Apache is easily installed.
Now let's look at the right side of your taskbar. There should be an icon similar to this small icon. This is the service manager of apache2, which is not available in apache1.x. Note the status of this image. If there is a green triangle, it indicates that your server has been installed successfully. If it is red, it indicates that your Apache has not been installed successfully, you need to further find the root cause of failure. The most common error is port conflict. Apache uses port 80 by default. If your port 80 is occupied by another program (such as IIS, the instance cannot be started. In this case, you can click Start> program> Apache HTTP Server 2.0.40> Configure Apache Server> edit the Apache httpd. conf configuration file "opens an Apache configuration file, which can be opened in a text editor. Then you will find the words similar to "Listen 80" in around 120th lines of this file. Now, you only need to change the port 80 to the port you want. Of course, you should not forget to add the port when browsing in the browser.
Here, your Apache should have a green light. Let's test whether it is working. Open your browser and enter "http: // localhost/" in the address bar (If your port is not 80, add ": Port Number" next to it "), I don't know if you have seen the Apache welcome page. I didn't see it in this step. I don't know why. apache2 does not seem to have a default boot page. If you do not see it, try adding the file name "index.html. En" to the end. If the following page appears, it means that Apache is working properly.

 

 

2. Now that Apache has been installed, you can see how to integrate it with PHP.
The first two steps are the same as the IIS steps described above. They are also extracted, copied to the C root directory, renamed, and PHP. copy INI to the system folder. If necessary, modify the values of "extension_dir" and "doc_root. I have already made it very clear. I will not talk about it more.
The next step is the most important step, which is also the core step of modular installation. You should check carefully.
Open the configuration file (HTTP. conf), you can click "start-> Program-> Apache HTTP Server 2.0.40-> Configure Apache server-> edit the Apache httpd. conf configuration file "open.

 

Or open the conf directory under your Apache installation directory and you will find a file named HTTP. conf, which can be opened in any text editor. In about 121st lines of this file, you should be able to find the "loadmodule" text, followed by a string of paths. This is the module to be loaded by Apache by default. Similarly, we can also add a sentence after it to let him load the PHP module.
In fact, it is so simple. You just need to add the following sentence: "loadmodule php4_module C:/PHP/SAPI/php4apache2. DLL ", here we need to explain that" php4_module "is the name of the module, and the following path is changed with your PHP installation directory. These three strings are separated by space characters.

 

Next, there is another step, which is ignored by many installation failures. At the beginning, the author did not start Apache after adding the above sentence. After several experiments, we found that the "php4ts. dll" under your PHP installation directory must be copied to the System32 directory of the Windows system. Otherwise, it cannot be started.
Now, try again to see if everything is normal. Now let's review the installation process in Apache.

(1) Add "loadmodule php4_module C:/PHP/SAPI/php4apache2. dll ".
(2) Copy "php4ts. dll" to the System32 directory.

Yes, it's that simple. php is already running on your machine. You can view this by double-clicking the Apache Server icon in the taskbar. Is to load PHP module and not load PHP module comparison:

 

3. Try again.
Save the following code as the info. php file and place it in the htdocs directory under your Apache installation directory.
<? PHP
Phpinfo ();
?>
Then, enter http: // localhost/info in the browser. PHP (If your port is not 80, add ": Port Number" after localhost/). Is it displayed on a screen similar to the following. If yes, congratulations, you have successfully installed PHP in modular mode. Note that it is different from the CGI Module in IIS after installation.

 

The above content in the Apache section may not be quite clear to friends who are not familiar with Apache configuration. However, as long as you follow the steps mentioned above, there should be no major problems. If you do not know which part you want to change makes Apache unable to start, you can switch to the conf folder under the Apache installation directory and. delete the conf file, and then delete the default Apache configuration file httpd. default. change conf to HTTP. conf. If you want to learn more about Apache configuration, you can refer to another article on this site "Apache server configuration Raiders" (http://www.hooday.com /? N = readarticle & A = 94 ).

Iv. Postscript
PHP installation is a simple task, especially the modular installation of PHP later. If you have time, try it on your own so that you can experience the joy of success.
Finally, I wish you a smooth installation of PHP.

 

More articles about php4.23 installing instances on IIS and apache2 servers in Windows XP

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/325320.html pageno: 14

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.