Because you do not have your own virtual host, you plan to have your own small database. However, I found that there are many folders in my www root directory, all of which were previously made. I cannot mix my record system with them, right? So I want to open a main site for myself. Therefore, this article is available.
Purpose: Enter "myhost" in the address bar of the browser to open the home page of my record West system.
Implementation:
1. Because I am working on the local machine, I need to modify the host file (c: \ windows \ System32 \ drivers \ etc \ hosts ), add the "myhost" Domain Name (of course you can use any name you want) to point to the local 127.0.0.1.
1 127.0.0.1 myhost
2. Open the Apache configuration file (httpd. conf) and delete # Before Include conf/extra/httpd-vhosts.conf
3. Open 'conf/extra/httpd-vhosts.conf 'under the Apache directory and you can see the default example. here we need to first modify the access permission of the folder
My modifications are as follows:
Copy codeThe Code is as follows: <Directory "U:/www/">
Options FollowSymLinks Indexes
Order Allow, Deny
Allow from All
AllowOverride All
</Directory>
First, you need to change the directory path of the permission.
4. Write a new sub-site according to the exampleCopy codeThe Code is as follows: <VirtualHost *: 80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "U:/www/doug /"
ServerName myhost
ServerAlias myhost
ErrorLog "log/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
Note:
The path of the third line is the sub-site path.
Line 4 and line 5 configure the access domain name for your sub-site. Here I use the previously configured myhost
5. When I was using this function, I found that localhost could not be accessed correctly. Then, the solution was to write a subsite for localhost.<Virtualhost> <br/> ServerAdmin webmaster@dummy-host.example.com <br/> DocumentRoot "U: /www/"<br/> ServerName localhost <br/> ServerAlias localhost <br/> ErrorLog" logs/dummy-host.example.com-error.log "<br/> CustomLog" logs/dummy-host.example.com-access.log "common <br/> </virtualhost>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Now you can enter your new domain name (myhost) in the address bar of your browser to access your website.