Make your Apache2.0.45 support PHP on the WIN Platform

Source: Internet
Author: User
Tags php source code sapi

Preface if you have no confidence in using Apache. Or you are using apache 2, but you cannot make it work with PHP (apache cannot parse your. php script ). Don't be afraid. After reading this article, all problems will be solved. I will summarize the steps for how to make Apache and PHP work together. In fact, this is much easier than others have said. I was surprised why no one had written a guide to this issue so that everyone could better understand and use Apache 2.0. Based on my personal interests, I analyzed Apache 2.0. In particular, in order to obtain the latest Apache server, this article uses version 2.0.45. Now, upgrading servers to Apache 2.0 is much safer than upgrading Microsoft's IIS, and there are a lot of useful tools. In this article, I will show you how to configure your httpd. conf file so that your server can process. php and. phps scripts. Next we will configure apache 2 together. When we request the. php page, the source code or prompt download will not be displayed, but the page we want to see will not be displayed. We need to download and install apache 2.0.45 and configure the httpd. conf file to enable apache2 to run. php and. phps files. This article is intended for Windows 2000/Me/XP users. If you do not have an msi installer, you may need to download and install it from Microsoft. The reason why I want to emphasize the Msi installation program is that this article is for those who first installed Apache 2. If you have installed Apache before, you can directly start the installation. However, pay attention to the steps in this article, especially when you plan to install PHP 4.3.1. Okay. Let's get started. Download apache2. If you have installed apache 1.3, stop it first. After installing apache2 and PHP scripts, you can safely uninstall apache1.3. conf file. In this way, you can use it on the new server with only a few changes. If you have not installed apache or other servers on your machine, go to apache.org to download apache2.0.45 (http://nagoya.apache.org/mirror/httpd/binaries/win32 ). Make sure that the. msi file you downloaded is 5.3M. Run the downloaded. msi file to install apache. Your server will start automatically. If you have a firewall, make sure that the firewall allows access to Apache. You should pay attention to the apache Service Monitor (a green light in the taskbar), which indicates that apache is working. To ensure that it is working, move the mouse arrow to the monitor and it will tell you that it is working. Your taskbar should be similar: Someone may wonder why "running 1 out of 2 apache services" is displayed, because you may have more than one version of apache at work. Most people won't do this, but I do have two apache servers on my machine. My 1.3.27 is stopped, while apache 2 is running. It is my machine: note that there is a red light on the monitor of apache1.3.27 and a green light on the monitor of apache2. The first time you install apache, you can only see one, because you have only installed one. Okay. The Apache server has been basically installed. Now let's download the PHP source code, because we want PHP to work with APACHE, go to php.net to download the latest version of PHP (currently PHP 4.3.2 http://www.php.net/downloads.php ). If you have installed PHP, check whether the php4apache2. dll file exists in the sapi file. If yes, skip the following steps. We need to download both the php-4.3.2-Win32.zip and the php-4.3.1-installer.exe, and many people have to ask why. This is to make you lazy, so you don't need to create a folder, you don't need to change the folder name from the php-4.3.1-Win32 to PHP. We first use installer.exe for installation. It will create a PHP folder for you and save more time. Run installer.exe and install PHP according to your preferences. decompress the zip file and find the sapi folder in the compressed package. Copy this folder to the PHP Directory you just installed. (For example: C: PHP) Then we can delete the php-4.3.2-win32 folder, because now it is no longer needed (A Bit Of A sense of uninstallation, haha ). Copy php4ts. dll in the PHP folder to your system directory: WINDOWSSystem32 in XP and WINNTsystem32 in 2 K. Next, modify the conf file. Let Apache parse the php page and open the httpd. conf file with your favorite text editor. Let's add a few lines so that Apache can parse the. php and. phps files. Pay attention to the two parts of the conf file. The first part is the Dynamic Shared Object (DSO) Support list, and the second part is cgi-bin directory. First, let's find the DSO list shown below. # Dynamic Shared Object (DSO) support # to be able to use the functionality of a module which was built as a DSO you # have to place corresponding 'loadmodule lines at this location so the # directives contained in it are actually available _ before _ they are used. # Statically compiled mo Dules (those listed by 'httpd-l) do not need # to be loaded here. # Example: # LoadModule foo_module modules/mod_foo.so there are many other such items. always find the last line: # LoadModule ssl_module modules/mod_ssl.so. The line above is the last line of the list, press enter to generate an empty row. Add the following line to the empty row: LoadModule php4_module c:/php/sapi/php4apache2. before closing the conf file, we need to add two more lines to the dll. Find the CGI-BIN directory, to save time, you can look for it like this: press CTRL + F) search In the second Press ENTER twice to add the following two lines: AddType application/x-httpd-php. php. phtml. php3. php4 AddType application/x-httpd-php-source. after adding phps, save your conf file and restart your apache server. Advanced users can now test your exciting PHP script. Once it runs successfully, your work is over. For initial installation users, you need to save the PHP file in your default path: c: Program FilesApache GroupApache2htdocs. Create a new text document, add the following code, and save it as date. php. Now, test the above Code (enter localhost/date. php in the address bar of the browser, and press Enter). The current month, date, and year are displayed. If the output is correct, it indicates that PHP has started to work on your server. To satisfy those who want to view the source code, create a text document and add the following code:


You are using Web browser.
<? Php echo $ title;?>Save it as browser. phps and save it as browser. php. After testing the two examples, you will find that the results are different. Browser. php will display your browser version, such as: You are using the Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) web browser. browser. phps shows your source code. To sum up, Apache 2.0.45 should be able to process your. php and. phps web pages. We hope everything will run smoothly. Now you have a brand new server. : P

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.