Website constructionWhen people test locally, it is often not a website, so how can it be like input How can I access the website locally by typing "domain name" in the address bar just like the domain name? Here we need to configure the Apache virtual host !
1. Find the apacheconfhttpd.conf file and find the code #Include conf/extra/httpd-vhosts.conf in the file and delete the previous #!
2. Find the apacheconfextrahttpd-vhosts.conf file. We will configure the virtual machine in this file! Open the file, and you can delete all the #s in front of the code. They only serve as comments. It would be more annoying to leave them here!
3. Let’s talk about the functions of each code,
NameVirtualHost is to set the port number of the virtual machine. There is no need to change it here unless you change the port number of the originally configured wamp!
ServerAdmin email address
DocumentRoot The home directory of this virtual machine
ServerName The domain name of this virtual machine
ServerAlias Alias of the virtual machine domain name
ErrorLog The storage location of the virtual machine error log
CustomLog The storage location of the virtual machine access log
There is common after CustomLog which represents the common log format, and there is also
referer records visitor source information
agent records the version information of the visitor’s agent software
combined Three types of combination
Pay attention to the configuration of each virtual machine, within each VirtualHost tag
Here is an example
4. After you configure a virtual machine in the httpd-vhosts.conf file, change the directory of your virtual machine in httpd.conf and add as many Directory tags as there are virtual machines.
Here is an example
5. Now when you use the domain name you defined in the virtual machine to access the website, you will find that you still cannot access it. Why? We still have the last step to resolve our domain name into an IP address through the DNS server.
First, open the C:WindowsSystem32driversetchosts file locally. Note that if you are not an administrator, you must open it as an administrator. You will find this code at the bottom
This is the resolved IP address of your original localhost. Now it’s simple. Just follow it and resolve your domain name to 127.0.0.1 below!
Then, you need to refresh the dns resolution cache, start -> run -> cmd
Enter ipconfig/flushdns and click the Enter key. When the following screen appears, it means success!
Now, you can access your website normally by entering your domain name!
wamp basic configurationPlease enter
Configure wamp development environment
This article is original to Wang Yelou’s personal blog. If you want to reprint, please indicate the source: Wang Yelou’s personal blog www.ly89.cn