Primary school students will see the Apache virtual host configuration tutorial

Time:2021-3-18

@

preface

Lengyue today in the company’s development, need to configure a local virtual host, configuration process also encountered a lot of holes, for this record, you can learn from it. In this article, all the complete code and steps are on the blog, you can go to viewConfigure virtual host in Wamp integrated environment or Apache

Configuration process

This time, the basic environment Wamp is used, and other Apache configuration methods are the same.

1. Open Apache’s httpd.conf file

The file path is under the Wamp installation path (wamp64 / bin / Apache / apache2.4.41 / CONF). Other separate Apache environments are also in the same location under the bin directory. As shown in the figure below:
踩坑WAMP集成环境 或Apache 配置虚拟主机
Open it in Notepad httpd.conf As shown in the figure below:
踩坑WAMP集成环境 或Apache 配置虚拟主机
Cirl + F key to find inputInclude conf/extra/httpd-vhosts.conf, will be foundInclude conf/extra/httpd-vhosts.confRemove the # in front of this line and save it with cirl + s.

2. Open Apache’s httpd- vhosts.conf file

The file path is under the Wamp installation path (wamp64 / bin / Apache / apache2.4.41 / conf / extra). Other separate Apache environments are also in the same location under the bin directory. The location is shown in the figure below
踩坑WAMP集成环境 或Apache 配置虚拟主机

Add the following code to the file,

The location of the root directory of the website
  ServerName  www.text.com     #The custom domain name you want
  DirectoryIndex index.php

Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

As shown in the figure below:
踩坑WAMP集成环境 或Apache 配置虚拟主机
At this time, the virtual host will be configured. Finally, we will configure hosts

3. Modify the hosts file

The file path is in the following C disk (C:: (Windows) = (system32) = (drivers) = (etc)), as shown in the figure below:
踩坑WAMP集成环境 或Apache 配置虚拟主机
Open it in Notepad and add a record. Point the domain name we just defined to local 127.0.0.1, that is, change the address back.
踩坑WAMP集成环境 或Apache 配置虚拟主机
So our configuration is complete. At this point, we enter the www.test.com , you can visit successfully.

If this blog is helpful to you, you can help Lengyue point a like or add a concern!

Welcome to my official account: the school student, cold month, free to get exclusive learning resources and daily dry cargo push.
If you are interested in my topic content, you can also follow my blog:www.guoyu7.com
If this blog is helpful to you, you can help Lengyue point a like or add a concern!
Welcome to my official account: my senior student, cold month, get exclusive learning resources and push daily dry cargo.
If you are interested in my topic content, you can also follow my blog:guoyu7.com