Installation and configuration of PHP5 and Apache in Windows _ PHP Tutorial

Source: Internet
Author: User
Install and configure PHP5 and Apache in Windows. The following uses PHP5 as an example to describe how to install and configure Apache and PHP5 in Windows. 1. download and install Apache. you can use www. apache. orgdyncloser. cgihttpdbinarieswin32 to introduce the installation and configuration of Apache and PHP5 in Windows.

1. download the installer

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

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

II. installer

1. Apache installation is relatively simple. we have a Windows installation program from the website. we can double-click it to run it, in this way, Apache is easy to install on our computer.

2. we should note that the zip package must be downloaded when downloading PHP, rather than the Installer. decompress the downloaded PHP package to the root directory of drive C and change the decompressed folder to php.

Three configurations

1. it is best to ensure that php5ts. dll is available regardless of the Interface (CGI or SAPI), so you must put 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 package contains two ini files: php. ini-dist and php. ini-recommended. We recommend that you use php. ini-recommended because this file optimizes the performance and security of the default settings.

Copy the selected ini file to the directory that PHP can find and change it to php. ini. By default, PHP searches for php. ini in the Windows Directory:

3. in Windows 9x/ME/XP, copy the selected ini file to % WINDIR %, usually c: \ windows.

In Windows NT/2000, copy the selected ini file to % WINDIR % or % SYSTEMROOT %. generally, c: \ winnt or c: \ winnt40 corresponds to the server version.

4. PHP settings in Apache

There are two ways to make PHP work on Apache in Windows. One is to use CGI binary files, and the other is to use Apache module DLL. Regardless of the method, you must first stop the Apache server and then edit httpd. conf to configure Apache and PHP to work together.

To use a CGI binary file, insert the following command into the httpd. conf configuration file of Apache to set the CGI binary file:

Install PHP in CGI mode 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 the module of Apache 2.0, we must move php4ts. dll to winnt/system32 (Windows NT/2000) or windows/system32 (Windows XP), overwrite the Original file (if any). For PHP 5, this file is php5ts. dll. Then we need to insert the following two lines into httpd. conf so that our PHP can be installed as the PHP-Module of Apache:

Install PHP in modules to Apache 2.0:

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

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

After such configuration, we have installed our PHP and Apache servers. We can perform a simple test:

1. test Apache:

Open the browser and enter localhost in the address bar. if the Apache page appears, it means that Apache works properly.

2. test PHP settings:

We can simply compile a PHP page. we can use a text editor and enter the following code:

<Html>
<Head>
<Title>
Hello
</Title>
</Head>
<Body>
<? Php echo "hello, php";?>
</Body>
</Html>

Save the file as hello. php, put it in the Apache htdocs Directory (we can also. in the conf file), and then input http: // localhost/hello in our browser. php. if you can correctly display hello, php indicates that our PHP configuration can work normally.

In this way, we can also design our PHP site.

Bytes. A download installer Apache can be made from http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32...

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.