Using Wamp to build a local development environment method in PHP

Source: Internet
Author: User
Tags php development environment
This article is mainly for you to introduce in detail the use of Wamp to build PHP local development environment related materials, with a certain reference value, interested in small partners can refer to

Write it in front.

PHP is a server scripting language, so it needs to be run on the server. As a novice, building a server may take a long time and may be churn. So in the introductory phase, in order to spend more time with the familiar programming language, using an integrated environment is the best and most convenient choice. This article describes how to build a PHP development environment on the Windows platform.

Installing an integrated environment

1. Download the integrated Environment package Wampserver official website

I downloaded the wampserver 3.0.6 bit, after the download is complete, double-click Install.

The software installed by Wamp 3.0.6 are:

Apache 2.4.23
PHP 5.6.25/7.0.10
MySQL 5.7.14
PhpMyAdmin 4.6.4
Adminer 4.2.5
Phpsysinfo 3.2.5

* The configuration of Apache version 2.4 and above will be different from the version 2.4
* Wamp will install both PHP5 and PHP7, which can be switched on after installation is complete.

2. Error occurred during installation

If you are prompted for a missing Msvcr110.dll file during installation, please download the required environment for Vcredist_x64.exe installation Wamp first.

Server Configuration

1. Project path

After installing the Wamp, there is a WWW folder under the installation path, which is used to store your project files and the files in this directory will be recognized and executed by the server.

For example, when I install Wamp, the directory selected is

D:\wamp64

After the installation of the project file directory is

D:\wamp64\www

Of course, if you do not want to use the default www folder, you can also modify the Apache configuration, specifying the directory for the server to resolve.

Locate the Apache configuration file under the installation directory httpd.conf

installation directory \bin\apache\apache2.4.23\conf\httpd.conf

Open the file using Notepad or another editor to find


DocumentRoot "${install_dir}/www" <directory "${install_dir}/www/" >...</Directory>

Modify the ${install_dir}/www to the directory you want to specify

The httpd-vhosts.conf file is then also found in this directory


extra\httpd-vhosts.conf# Open File ↓<virtualhost *:80>  ServerName localhost  documentroot d:/wamp64/www  <directory "d:/wamp64/www/" > ...  </Directory></VirtualHost>

Modify the d:/wamp64/www to the directory you want to specify. The server will then parse the files in this directory.
* Remember to restart the server after you modify the configuration

2. Testing

Create a new project test server is available.

Create a new test folder under the WWW folder, and write some output statements in a new test.php,php file in the folder. For example, a programmer must write a sentence:

Echo ' Hello world! ';

After opening the browser, enter in the address bar

localhost/test/test.php

If your browser has the word Hello world!, it means your server is ready to use.

3. Configure the Virtual host

Do not like to localhost/project filename/xxx.php/ ... Access in this way? That can be configured with a virtual host, which can be accessed in a form similar to www.test.com(customizable).

First find the httpd-vhosts.conf file and open

installation directory \bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf

Add at the end of the file


<virtualhost *:80>  #设置主机名 (you can set it yourself)  ServerName www.test.com  #设置主机别名, which is also accessible with this alias (if the domain name is resolved correctly)  Serveralias test.com  #设置该站点根目录  documentroot "D:\wamp64\www\test"  #设置文件夹访问控制, The path is the same as the DocumentRoot on the previous line,  <directory "D:\wamp64\www\test" >    #用于显示设定 "can display the file list" (when there is no page to display)    Options Indexes    #启用文件夹访问控制的文件. htaccess settings    allowoverride all    #请求控制    Require all granted    # Default open Page Setup    directoryindex index.php index.html  </Directory></VirtualHost>

Then, locate the Hosts file, and the path to the hosts file for Win10 is:


C:\windows\system32\drivers\etc# Each system is not the same, you can ask Baidu

Add 127.0.0.1 www.test.comat the end of the file (note the spaces in the middle do not lose), save.
* If the save prompt is saved as, you can save as, then modify the Save as file named hosts, overwriting the original Hosts file


... # Additionally, comments (such as these) may is inserted on inpidual# lines or following the machine name denoted by a ' # ' symbol.## for example:##   102.54.94.97   rhino.acme.com     # source server#    38.25.63.10   x.acme.com       # x client host# localhost name resolution is handled within DNS itself.# 127.0.0.1 localhost#
  ::1       localhost127.0.0.1 www.test.com

The purpose of the hosts modification is to make the system not submit the domain name (www.test.com) to the DNS server when the browser is accessed, but instead locate the IP address (local) and submit the resolution directly according to the hosts file. This allows our local server to parse the domain name.

4. LAN Remote Access

If you need to be able to access the site via a link in your local area network (for example, when developing a web app), you need to turn on server remote access.

Open Apache configuration file httpd.conf

installation directory \bin\apache\apache2.4.23\conf\httpd.conf

Modify the allowoverride and require configurations as follows


DocumentRoot "${install_dir}/www" <directory "${install_dir}/www/" > ...  AllowOverride all  Require all granted  ...</directory>

Also need to modify the httpd-vhosts.conf file, modify the same configuration


<virtualhost *:80>  ServerName localhost  documentroot d:/wamp64/www  <directory "d:/wamp64/www/ "> ...    AllowOverride all    Require all granted  </Directory></VirtualHost>

To access only one of these sites, you first need to configure the virtual host for the site, and then modify the allowoverride and Require in the configuration of the virtual host.

Okay, here's the basic steps to build a PHP native development environment using WAMP. You're going to be the programmer's "no way" to build these.

If you find that there is something wrong with the article, please correct it.

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.