Use WAMP to build a PHP local development environment and wamp to build php development
Preface
PHP is a server scripting language, so it can only run on the server. As a newbie, it may take a long time to set up a server. Therefore, in the entry stage, to spend more time on programming languages, it is best and most convenient to use an integrated environment. This article describes how to build a PHP development environment on the windows platform.
Install the Integration Environment
1. Download the integrated environment packageWampServer Official Website
I downloaded Wampserver 3.0.6 64 bit. After the download is complete, double-click to install it.
The software installed in wamp 3.0.6 is:
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 2.4 and later versions is somewhat different from that of apache 2.4 or later versions.
* Wamp will install PHP5 and PHP7 at the same time. After installation, you can switch between them.
2. Installation errors
If the msvcr110.dll file is missing during installation, download vcredist_x64.exe to install the wamp environment.
Server Configuration
1. Project path
After wamp is installed, there is a www folder in the installation path. This folder is used to store your project files. Files under this directory will be recognized and executed by the server.
For example, when I install wamp, the selected directory is
D: \ wamp64
After installation, the Directory of the stored project file is
D: \ wamp64 \ www
Of course, if you do not want to use the defaultWwwFolder, you can also modify the apache configuration to specify the directory for Server Resolution.
Find the apache configuration file in the installation directoryHttpd. conf
Installation directory \ bin \ apache \ apache2.4.23 \ conf \ httpd. conf
Use notepad or another editor to open the file and find
DocumentRoot "${INSTALL_DIR}/www"<Directory "${INSTALL_DIR}/www/">...</Directory>
Set$ {INSTALL_DIR}/wwwChange to the directory to be specified
Then, findHttpd-vhosts.confFile
Extra \ httpd-vhosts.conf # open the file hosts <VirtualHost *: 80> ServerName localhost DocumentRoot D:/wamp64/www <Directory "D:/wamp64/www/">... </Directory> </VirtualHost>
ModifyD:/wamp64/wwwSpecify the directory. In this way, the server will parse the files in this directory.
* After modifying the configuration, remember to restart the server.
2. Test
Create a new project to test whether the server is available.
Create a test folder under the www folder, create a test. php folder, and write some output statements in the php file. For example, a programmer must write a sentence:
Echo 'Hello World! ';
Then open the browser and enter in the address bar
Localhost/test. php
If your browser displays Hello World! It indicates that your server can be used.
3. Configure the VM
Do not likeLocalhost/project file name/xxx. php /...In this way? You can configure a virtual host and then access it in the form of www.test.com (custom.
First findHttpd-vhosts.confFile and open
Installation directory \ bin \ apache \ apache2.4.23 \ conf \ extra \ httpd-vhosts.conf
Add
<VirtualHost *: 80> # Set the Host Name (which can be set by yourself) ServerName www.test.com # Set the host alias so that you can use this alias to access it (provided that the domain name resolution is correct) serverAlias test.com # Set the root Directory of the site DocumentRoot "D: \ wamp64 \ www \ test" # Set the folder access control. The path must be the same as that of DocumentRoot in the previous line. <Directory "D: \ wamp64 \ www \ test "> # used to display and set" file list displayed "(when no webpage is displayed) Options Indexes # enable folder access control for files. htaccess sets AllowOverride All # Request control Require all granted # DirectoryIndex index is set on the default page. php index.html </Directory> </VirtualHost>
Then, find the hosts file. The hosts file path of win10 is:
C: \ Windows \ System32 \ drivers \ etc # each system is different. You can ask Baidu
Add at the end of the file127.0.0.1 www.test.com(Do not lose spaces in the middle), save.
* If you are prompted to save the file as hosts, You can first save the file as hosts and then modify the file name to overwrite the original hosts file.
...# Additionally, comments (such as these) may be inserted on individual# 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 modifying hosts is to submit the resolution directly based on the hosts file instead of submitting the domain name (www.test.com) to the DNS server during browser access. In this way, our local server can resolve this domain name.
4. remote LAN Access
If you need to access the site through a link in the LAN (for example, you can use a mobile phone to test when developing a web app), you need to enable remote access to the server.
Open the apache configuration file httpd. conf.
Installation directory \ bin \ apache \ apache2.4.23 \ conf \ httpd. conf
Modify AllowOverride and Require as follows:
DocumentRoot "${INSTALL_DIR}/www"<Directory "${INSTALL_DIR}/www/"> ... AllowOverride all Require all granted ...</Directory>
You also need to modifyHttpd-vhosts.confFile to modify the same configuration
<VirtualHost *:80> ServerName localhost DocumentRoot D:/wamp64/www <Directory "D:/wamp64/www/"> ... AllowOverride All Require all granted </Directory></VirtualHost>
If you only need to access one of the sites, you must first configure a virtual host for the site, and then modifyAllowOverrideAndRequire
Now, you can use WAMP to set up the PHP local development environment. Setting up these items is a programmer's "no return.
If you find any incorrect article, please correct it.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.