This is the basic configuration of Apache Virtual Host Configuration A found in the Ubuntu community. We all know that if we want to set multiple domain names or host names on A single machine, we need to use a name-based VM. So how should we set it? This is the problem that this guide is trying to solve. In the/etc/apache2/directory of Ubuntu, there is a master configuration file apache2.conf for apache2. In this file, we can see this line of content: Includ
This is the Apache Virtual Host Configuration found in the Ubuntu community.
A basic configuration
We all know that if we want to set multiple domain names or host names on a single machine, we need to use a name-based virtual master
Machine. So how should we set it? This is the problem that this guide is trying to solve. In Ubuntu/etc/apache2/Object
There is a master configuration file apache2.conf for apache2. In this file, we can see the following line of content:
Include/etc/apache2/sites-enabled/[^. #] *
This line indicates that the file contains the/etc/apache2/sites-enabled/directory file name does not contain "." or "#"
All files with two characters. When we list the files in this directory, we find that there is only one 000-default soft link file.
The actual connection is the default file in the/etc/apache2/sites-available Directory, which is not difficult to see.
The part name does not contain "." or "#". Therefore, this file must be included in the configuration file apache2.conf. Dozen
Open this file and find that it is actually a configuration file of the virtual host. However, because the virtual host in this file is *,
Is a common configuration file. If we want to create a VM, we need to change the file to the following:
NameVirtualHost 10.39.6.59
ServerName www.britepic.org
ServerAdmin Ubuntu@gmail.com
DocumentRoot/var/www/
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow, deny
Allow from all
# This directive allows us to have apache2's default start page
# In/apache2-default/, but still have/go to the right place
# Commented out for Ubuntu
# RedirectMatch ^/$/apache2-default/
ScriptAlias/cgi-bin // usr/lib/cgi-bin/
AllowOverride None
Options ExecCGI-MultiViews + SymLinksIfOwnerMatch
Order allow, deny
Allow from all
ErrorLog/var/log/apache2/error. log
# Possible values include: debug, info, notice, warn, error, crit,
# Alert, emerg.
LogLevel warn
CustomLog/var/log/apache2/access. log combined
ServerSignature On
Alias/doc/"/usr/share/doc /"
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny, allow
Deny from all
Allow from 127.0.0.0/255.0.0.0: 1/128
Next we will analyze the setting statements related to the VM in the above section:
'Namevirtualhost 10.39.6.59 ': indicates a name-based virtual host with its IP address
10.39.6.59
` And ': Indicates the configuration of a virtual host.
'Servername www.britepic.org ': sets the Domain Name of the VM.
'Serveradmin Ubuntu@gmail.com ': sets the mail for this VM Administrator
'Documentroot/var/www/': sets the main directory path of the VM.
'Errorlog/var/log/apache2/error. log': sets error information for this VM.
'Customlog/var/log/apache2/access. log combined': sets the access information of the VM.
In this way, we have configured a virtual host www.britepic.org. However, this is the default configuration, so restart Apache2.
Then, no matter you enter any domain name in the DNS server pointing to this host, it will be directed
The/var/www directory to which the default configuration points. Unless this domain name is used by other VM configurations, for example, we also configure
Edunuke.britepic.org points to the local machine and the corresponding virtual host is configured. In this way, enter the Domain Name
Edunuke.britepic.org will be placed in the directory of the expected domain name.