Windows Apache and PHP installation and configuration ____php

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

Reprint: https://www.cnblogs.com/freefalcon/p/3888459.html

Under Windows apache+php Development environment construction mainly includes three kinds of ways, the first one is to use the integrated installation package directly, such as XAMPP, the second is Apache to use 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 way the most troublesome, but can be flexible to choose the version of their own to install. This article mainly records the third way of the installation process.

One of the features of this article, unlike other similar articles, is that I don't want to simply provide a few downloads, but I want to tell beginners how to find resources from the official web site so that even if things change (such as a new release or a broken link), you can netizens find new resources. mode One, adopt the integrated development environment XAMPP

XAMPP In addition to the integration of Apache and PHP, but also includes MySQL and Perl, it is very convenient to implement the PHP development environment for rapid installation and configuration.

XAMPP's official website is:

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

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

The installation process is slightly.

mode two, Apache uses official MSI

The official website of Apache is: http://httpd.apache.org

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

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

We have not found the latest version of 2.4.10 MSI from the above image, only 2.2.25 version can be installed. If PHP chooses the current PHP-5.5.15, it does not start properly because PHP does not match the Apache version. So this installation must be careful to choose the PHP version that matches with Apache.

mode three, manually install Apache and PHP

The official website of PHP is: http://php.net, the official website provides the download link of the Windows version, the following figure:

On the left side of the PHP Windows version download page is a description of the version selection, and be sure to read it carefully. This text clearly suggests that we Apache should choose the lounge version, while PHP should use the thread safety (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, where 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 Compression Pack 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 because this is the default setting.

My choice is to copy to D-Packing directory, so you need to modify the Apache configuration file d:\Apache24\conf\httpd.conf, open the file, replace C:/apache24 all D:/apache24

3. Run cmd, enter Apache24 under the Bin directory, in order to check httpd.conf have no problem, we enter httpd.exe-t, if the normal words will only show a row of syntax OK, if the wrong words will tell us where is wrong.

D:\apache24\bin>httpd.exe-t
AH00558: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 message
Syntax OK

The error message I get here is that ServerName has a problem. Found in the httpd.conf servername, the original is the default is commented out, remove the front #, save the file. Re-execute httpd.exe-t and test pass.

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

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

D:\apache24\bin>httpd.exe-k install
Installing the Apache2.4 service The
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 no error prompts, enter http://127.0.0.1 in the browser or http://localhost will display the following page:

At this point, the Apache installation was successful. If you want to use Apachemonitor, you can either establish a shortcut for Apache24\bin\apachemonitor.exe or add it to the Windows Startup program group.

6. Copy the PHP to the installation location, I choose d:/php-5.5.15 here. Then rename the php.ini-development to PHP.ini, and if it is deployed, copy the php.ini-production.

7. Edit Apache's httpd.conf

Look for LoadModule, add the following configuration behind it, if your PHP is in C, please change D: C:, and note the path use/.

LoadModule php5_module d:/php-5.5.15/php5apache2_4.dll
phpinidir d:/php-5.5.15

Find AddType and add the following configuration:

AddType application/x-httpd-php. php

Look for DirectoryIndex, join index.php, and if you want index.php to take precedence over index.html, place it in the 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 run httpd.exe-k restart restart the Apache service if there is no problem.

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

<?php
    phpinfo ();
? >

The http://127.0.0.1/phpinfo.php is then accessed in the browser, and if the following page appears, the surface of PHP works fine:

So far, 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.