How does one add a VM in Apache?

Source: Internet
Author: User

How does one add a VM in Apache?

It is easy to add a VM in Apache. modify the configuration file: httpd. conf.

1. Remove the # sign before the following two lines of text.

 
# Loadmodule vhost_alias_module modules/mod_vhost_alias.so

Remove # It means to enable the virtual host function of Apache.

 
# Include CONF/extra/httpd-vhosts.conf

Removing this line # means importing the VM configuration from the conf/extra/httpd-vhosts.conf File

 

2. open the file and see the following similar content. The configuration of the VM is also based on the following content. Next we will explain this content

<Virtualhost *: 80> serveradmin [email protected] DocumentRoot "C: /apache2/docs/dummy-host.example.com "servername dummy-host.example.com serveralias www.dummy-host.example.com errorlog" logs/dummy-host.example.com-error.log "customlog" logs/dummy-host.example.com-access.log "common </virtualhost>

 

Namevirtualhost *: 80
Note 1: namevirtualhost specifies the IP address or domain name used by the VM, but preferably the IP address. When using a domain name-based Vm, namevirtualhost is a required command. Multiple namevirtualhost can be defined.
NOTE 2: All requests that comply with the namevirtualhost or <virtualhost> label will be processed as virtual hosts, and the master server will ignore them. If the <virtualhost> label does not define a request, the server cannot find the corresponding virtual host and cannot process it. Therefore, each parameter defined by namevirtualhost must have at least one <virtualhost> matched.
NOTE 3: If namevirtualhost or <virtualhost> is set to *: 80, all requests for port 80 will be processed by the VM, and the requests will be directed to a VM based on the domain name. If there is a request from port 80 and the requested domain name is not configured as a VM, it will point to the first VM. In this way, the master server will not be able to receive any requests from port 80. Therefore, you must configure a virtual host for the master server.
Serveradmin administrator email
DocumentRoot website directory (Note: if the path in the website directory contains spaces, add double quotation marks at both ends of the path)
Servername: The domain name to be bound (required)
The alias of the virtual host to bind to serveralias. (Optional. If multiple domain names are separated by spaces in the middle, if not, this line is removed)
*,? Two wildcard characters, such as * .abc.com, indicate that any second-level domain name of abc.com can be accessed.
Customlog user log file (optional. Remove this line if not required)
Errorlog Error Log (optional. Remove this line if not required)

 

Ipbased setting method:

<Virtualhost 192.168.218.230: 80> servername www.123.com DocumentRoot "D:/wwwroot" <directory "D:/wwwroot"> AllowOverride all options all </directory> </virtualhost>

 

 

Domain name-based setting method:

 
<Virtualhost *: 80> servername nss.abc.cn serveralias uc.abc.com DocumentRoot "D:/program files/100" <directory "D: /program files/100 "> AllowOverride all options all </directory> </virtualhost>

 

Remember to restart the web server.

 

Alternate reference address: http://blog.csdn.net/zm2714/article/details/8351342

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.