Apache opens the subsite configuration method

  • 2020-05-06 12:04:39
  • OfStack

Because do not have their own virtual host, so it is intended to exist on their own small book. However, I found that there are many folders in my www root directory, all of which are the things I made before. I can't mix my own recording system with them, can I? So I wanted to open a main site for myself. Hence the article.
Goal: enter "myhost" in the browser address bar to open the home page of my own record west system.
Implementation:
1. Since I am doing this locally, I need to modify the host file (c:\windows\System32\drivers\etc\hosts) and add the "myhost" domain name (of course you can use any name you want) to point to local 127.0.0.0.0.
1 127.0.0.1 myhost
2. Open the Apache configuration file (httpd.conf) and delete
from # before Include conf/extra/ httpd-vhosts.conf 3. After opening 'conf/extra/ httpd-vhosts. conf' in the Apache directory, you can see the default example I modified it as follows:
 
<Directory "U:/www/"> 
Options FollowSymLinks Indexes 
Order Allow,Deny 
Allow from All 
AllowOverride All 
</Directory> 

The first action is to change the permissions of the directory path
4. Write the new subsite
as an example
 
<VirtualHost *:80> 
ServerAdmin webmaster@dummy-host.example.com 
DocumentRoot "U:/www/doug/" 
ServerName myhost 
ServerAlias myhost 
ErrorLog "logs/dummy-host.example.com-error.log" 
CustomLog "logs/dummy-host.example.com-access.log" common 
</VirtualHost> 

Note here:
The third line is the subsite path
The fourth and fifth lines are for the access domain you set up for the subsite, and here I'm using the myhost
that I set up earlier 5. When I started this function, I found that localhost could not be accessed correctly. The solution was to write a subsite
for localhost here
 
 
ServerAdmin webmaster@dummy-host.example.com 
DocumentRoot "U:/www/" 
ServerName localhost 
ServerAlias localhost 
ErrorLog "logs/dummy-host.example.com-error.log" 
CustomLog "logs/dummy-host.example.com-access.log" common 
 
[Ctrl+A full selection note: if external Js needs to be introduced, it needs to be refreshed to execute]
You can now access your site by entering your new domain name (myhost here) in the browser's address bar

Related articles: