PHP + Apache + Mysql environment build tutorial _ php instance

Source: Internet
Author: User
Tags apache download php development environment php download
This article describes how to build a PHP + Apache + Mysql environment and build a php development environment step by step. For more information, see Download Php + Apache + Mysql.
Php download:Http://www.php.net to enter the php official website and click download to enter the following interface. The above shows that php5.6.19 is selected for different versions. this version is relatively stable and is recommended if there is no version requirement. Develop php in Windows environment, so click Windows downloads in the picture to download the compressed package.


On the interface, we can see that there are versions such as VC11 X64 Thread Safe and VC11 X64 None Thread Safe. I chose the VC11 X64 Thread Safe ZIP compressed package.


After downloading the package, decompress the package to the directory you want to place. remember to keep it in the same directory as the next Apache installation package. open the folder and you will see the file, all the dynamic link library files (. dll) because it is a compressed package, we also need to manually set it; the original folder does not contain php. ini file, you need to put the php. ini-development file copy renamed, because we need php. ini to initialize the php settings.


Apache Download: http://www.apachehaus.com/cgi-bin/download.plx this link directly to the download interface apache can be directly on the latest version, for compatibility considerations, it is recommended to choose VC9 version, the specific difference in the web page to explain and then this will not go into details.


Click Download in the red border to Download the installation package, and then install it as prompted,Remember to install it in the same directory as the php decompression package.

Next, you need to configure and install the main service of Apache. with this service, Apache can be started:

Open the CMD window and enter: "D: studytools \ Apache \ bin \ httpd.exe"-k install-n apacheD: studytools \ Apache \ bin \ httpd.exe is my own path. you need to change it according to your own path.

Remember to include quotation marks. This command means to install the apache service and name it apache (you can also change it to another one). press Enter.

After the service is installed, it is automatically tested. if there is any problem, an error is prompted in the window. in this case, troubleshoot the error based on the error.

Here, Errors reported here must be corrected before the service can be started. This means that if there is an error message after this sentence, it indicates that the service installation has failed and you must correct the error first. If no, the operation is successful.

There are too many steps to download and install Mysql. the online tutorials are very detailed ........

However, I have shared several articles for your reference:

Mysql 5.7.12 winx64 installation and configuration method graphic tutorial

Mysql 5.7.13 installation and configuration method graphic tutorial (linux)

Mysql 5.7.13 winx64 installation and configuration method graphic tutorial

Highlights: installation tutorials for different mysql versions

Now we start to build three environments:
1. to enable PHP to connect to Mysql, Apache can parse PHP. we need to make some changes to PHP and Apache.

(1) copy the php. ini-development file and replace it with php. ini in the original folder.

(2) open the php. ini file and find; Extension = php_mysql.dll; extension = php_mysqli.dllRemove the previous ";" such


After removing the semicolon, you can connect to the database using mysql or mysqli. If you want to connect to the database using other commands such as PDO in the future, you can cancel the following PDO seals according to the tutorial. Find"Extension_dir ="Enter the path of the dynamic link library folder, that is,/php/ext. if the ext package path under my php is D: \ studytools \ php \ ext, set it to a red box. In this way, the path of the dynamic link library contained in php is given,SuggestionsIt is best to add the ext Path to the Path in the computer environment variable.


After that, there will be no problem between php and the database.

Next we will solve the problem of Apache parsing PHP.
1. open the httpd. conf file in the conf folder under the Apache installation package and find Define SRVROOT "" in the directory where the Apache path is written. then add the following code to save it.

LoadModule php5_module "E:/wamp/php-5.6/php5apache2_4.dll"

PHPINIDir "E:/wamp/php-5.6 /"

AddType application/x-httpd-php. php

AddType application/x-httpd-php-source. phps

Test successful
Finally, you can write your own PHP file in the htdocs folder under Apache. you can write a test. php file with the following content:

 <?php  phpinof(); ?>

Save, open apachemonitor.exe in the binfile under Apache, click start, and enter localhost/test. php on the website. The following interface is displayed. On the page, php information is displayed. if mysql is connected, MySQL information is displayed later.


The above is all the content of this article. I hope it will be helpful to everyone's learning, and I hope you can support your own home.

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.