_php Basics for installation and configuration of PHP5 and Apache under Windows

Source: Internet
Author: User
Tags apache php
Here take PHP5 as an example of how to install and configure Apache and PHP5 under Windows.

Download installation program

Apache can download from http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/

PHP can be downloaded from the http://www.php.net.

Two setup programs

1, the Apache program is relatively simple to install, we are down from the site is a Windows installation program, we can double-click directly to run, so we will facilitate the Apache in our computers on the home.

2, we have to pay attention here is to download PHP when you must download the ZIP package, and do not download installer. Unzip our downloaded PHP package to the root directory under C disk and rename the extracted folder to PHP.

Three configurations

1, preferably, regardless of the interface (CGI or SAPI) you use to ensure that Php5ts.dll is available, you must place this file 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 up a valid PHP configuration file, php.ini. The compressed package includes two INI files, php.ini-dist and php.ini-recommended. It is recommended that you use php.ini-recommended, because this file performs performance and security optimizations on the default settings.

Copy the selected INI file to the directory that PHP can find and rename it to PHP.ini. PHP defaults to search for php.ini in Windows directory:

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%, typically C:\Winnt or C:\WINNT40 corresponds to the server version.

4 the PHP settings in Apache

There are two ways to make PHP work under Windows Apache. One is to use CGI binaries, and the other is to use the Apache module DLL. Either way, you must first stop the Apache server and then edit the httpd.conf to configure Apache and PHP to work together.

If we were to use a CGI binary, we would insert the following instruction into Apache's httpd.conf configuration file to set up the CGI binaries:

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/php.exe"

If we want to use PHP as a module for Apache 2.0, then be sure to move Php4ts.dll to Winnt/system32 (Windows nt/2000) or Windows/system32 (Windows XP), overwriting existing files (such as In the case of PHP 5, this file is Php5ts.dll. Then we're going to insert the following two lines into httpd.conf to make our PHP install as Apache php-module:

PHP is installed in modular mode to Apache 2.0:

; For PHP 4 does something like this:
LoadModule php4_module "C:/php/php4apache2.dll"
AddType application/x-httpd-php. php

; For PHP 5 does something like this:
LoadModule php5_module "C:/php/php5apache2.dll"
AddType application/x-httpd-php. php

After this configuration, we have installed our PHP and Apache servers. We can simply test:

1, Test Apache:

We open the browser, enter the localhost in the address bar, if the Apache page can appear, then our Apache can work properly.

2, Test PHP settings:

We can simply write a PHP page, we can use a text editor, enter the following code:



<br>Hello<br>



Then save the file as hello.php, place it in the Apache Htdocs directory (we can also change the directory in the http.conf file), and then enter http://localhost/hello.php in our browser, If you can display the hello,php correctly, our PHP configuration is working properly.

Then we can also design our PHP site.

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.