Installation and configuration of Apache and PHP under Windows

Source: Internet
Author: User
Tags php development environment php windows phpinfo windows download

Windows apache+php Development environment is mainly composed of three ways, the first is the direct adoption of integrated installation package, such as XAMPP, the second is Apache with the official MSI installation package, PHP manual installation, the third is Apache and PHP are manually installed. Obviously, the first way is the simplest, but the corresponding restrictions are relatively large, the third is the most troublesome, but you can flexibly choose the version you need to install. This paper mainly records the installation process of the third method.

One of the characteristics of this article is that I don't want to just provide a few download links, but I want to tell beginners how to find relevant resources from the official website, so that even if things change (such as a new release or a broken link), you can retrace find new resources.

Method One, adopt the integrated development environment XAMPP

In addition to integrating Apache and PHP, XAMPP also includes MySQL and Perl, which makes it easy to quickly install and configure the PHP development environment.

XAMPP's official website is:

Https://www.apachefriends.org/index.html

Https://www.apachefriends.org/zh_cn/index.html (English)

The installation process is slightly.

Way two, Apache uses the official MSI

Apache's official website is: http://httpd.apache.org

Open the download page (http://httpd.apache.org/download.cgi) to find the latest version and click on the binaries below.

into the Win32 download page, you can see the different versions of the MSI file, download the version you need to install.

We did not find the latest version of 2.4.10 MSI, only the 2.2.25 version can be installed. If PHP chooses the current PHP-5.5.15, it will not start properly because PHP does not match the Apache version. So this way of installation must be careful to choose the version of PHP that matches Apache.

Method Three, manually install Apache and PHP

PHP's official site is: http://php.net, the official website provides a version of the Windows download links, such as:

On the left side of the PHP Windows version download page, there is a description of the version selection, so be sure to read it carefully. This text expressly suggests that we Apache should choose the lounge version, while PHP should use the thread-safe (TS) version.

Go to the Apache Lounge download page (http://www.apachelounge.com/download) and download the desired version:

The specific installation and configuration steps are as follows

1. Download the Windows version of Apache and PHP, I chose to use the VC11 compiled 32-bit version.

Apache-2.4.10:http://www.apachelounge.com/download/vc11/binaries/httpd-2.4.10-win32-vc11.zip

Php-5.5.15:http://windows.php.net/downloads/releases/php-5.5.15-win32-vc11-x86.zip

2. Unzip the Apache package and read the ReadMe.txt, which tells us what to do.

Copy the extracted Apache24 to the target location to be installed. It is recommended to copy to the C packing directory, as this is its default setting.

I chose to copy to the D packing directory, so I need to modify the Apache configuration file d:\Apache24\conf\httpd.conf, open the file, replace C:/apache24 all to D:/apache24

3. Run cmd, enter the bin directory under Apache24, in order to check whether httpd.conf has problems, we input httpd.exe-t, if normal will only show a row syntax OK, if there is a mistake will tell us where is wrong.

D:\apache24\bin>httpd.exe-tah00558:httpd.exe:could not reliably determine the server ' s fully qualified do main name, using FE80::29B5:91F1:1DBA:81BE. Set the ' ServerName ' directive globally to suppress this messagesyntax OK

The error message I get here is that ServerName has a problem. Find servername in httpd.conf, it is this setting by default is commented out, remove the previous # number, save the file. Re-execute HTTPD.EXE-T, test pass.

Tip: More commands for Httpd.exe can be viewed through httpd.exe-h.

4. Run Httpd.exe-k install in the console to have Apache installed as a Windows service so that Apache will run automatically later.

D:\apache24\bin>httpd.exe-k installinstalling the Apache2.4 servicethe Apache2.4 service is successfully installed. Testing httpd.conf .... Errors reported here must is corrected before the service can be started. 

5. Run Httpd.exe-k start service, if there is no error prompt, enter http://127.0.0.1 in the browser or http://localhost will display the following page:

At this point, Apache installation is successful. If you want to use Apachemonitor, you can create a shortcut for Apache24\bin\apachemonitor.exe or add it to a Windows startup program group.

6. After extracting PHP and copying it to the installation location, I chose d:/php-5.5.15. Then copy the php.ini-development and rename it to PHP.ini, and if it is a deployment, copy the Php.ini-production.

7. Edit Apache's httpd.conf

To find LoadModule, add the following configuration after it, if your PHP in the C drive, please change D: to C:, also note the path use/.

LoadModule php5_module d:/php-5.5.15/php5apache2_4.dllphpinidir d:/php-5.5.15

To find AddType, add the following configuration:

AddType application/x-httpd-php. php

Find DirectoryIndex, join index.php, and if you want index.php to take precedence over index.html, put it in front.

<ifmodule dir_module>    directoryindex index.html index.php</ifmodule>

Save the configuration, run the Httpd.exe-t check configuration on the command line, and if there is no problem, run httpd.exe-k restart to restart the Apache service.

8. Create a new phpinfo.php file in the Apache24\htdocs directory, and enter the following PHP code:

<? php    phpinfo();? > 

Then access the http://127.0.0.1/phpinfo.php in the browser, and if the following page is displayed, the surface PHP works correctly:

At this point, apache+php's basic development environment has been built.

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.