This article provides a detailed analysis of how to configure a virtual host using multiple ports in apache in linux. For more information, see
This article provides a detailed analysis of how to configure a virtual host using multiple ports in apache in linux. For more information, see
By default
The default document directory is/var/www.
Default port: 80
To publish a system resource directory, run the following command:
(1) Add a listening port
# Cd/etc/apache2
# Vim ports. conf
File addition:
Namevirtualhost*: 8000
Listen 8000.
(2) configure the virtual directory
# Cd/etc/apache2/sites-available
# Cp default-me
# Vim default-me
The file content is as follows:
The Code is as follows:
ServerAdmin webmaster @ localhost
DocumentRoot/wwwroot
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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
The bold part is the key point.
(3) release site
# Ln-s/etc/apache2/sites-available/default-me/etc/apache2/sites-enabled/001-default
(4) restart the service
#/Etc/init. d/apache2 restart
(5) test
: 8000/
If the access is normal, the configuration is correct.
The Code is as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# Machine you can setup VirtualHost containers for them. Most deployments
# Use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation
#
# For further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# Configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *: 81
NameVirtualHost *: 82
NameVirtualHost *: 83
NameVirtualHost *: 84
NameVirtualHost *: 85
NameVirtualHost *: 86
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# Match a ServerName or ServerAlias in any Block.
#
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www-nongye
ServerName
ErrorLog D:/AppServ/www-nongye/errornongye. log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
Options FollowSymLinks
# Deny from all
Allow from all
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www-chinaec
ServerName
DirectoryIndex index. php index.html
ErrorLog D:/AppServ/www-chinaec/errornongjiale. log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/www-05110
ServerName
ErrorLog D:/AppServ/www/www-05110/errornon1_5110.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/wordpress
ServerName
ErrorLog D:/AppServ/www/wordpress/errornongwordpress. log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/magento
ServerName
ErrorLog D:/AppServ/www/magento/errormagento. log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www/magento1322
ServerName
ErrorLog D:/AppServ/www/magento1322/errormagento1322.log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/AppServ/www-nongjiale
ServerName
ErrorLog D:/AppServ/www-nongjiale/errornongjiale. log
CustomLog logs/dummy-host2.appservnetwork.com-access_log common
ServerAdmin webmaster@dummy-host2.x
DocumentRoot "C:/Apache2.2/docs/dummy-host2.x"
ServerName dummy-host2.x
ErrorLog "log/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common
1. Single Domain Name and single port settings
For example, 80 is used by default for access.
Note: apache configuration is in the conf directory of the installation directory by default.
Or/etc/apache2
However, be sure to check whether port listening is enabled in the listen. conf file.
For example, port 80 listening is enabled.
Direct default
1. Single Domain Name and single port settings
For example, 80 is used by default for access.
Note: apache configuration is in the conf directory of the installation directory by default.
Or/etc/apache2
However, be sure to check whether port listening is enabled in the listen. conf file.
For example, port 80 listening is enabled.
Direct default modification default-server.conf
This configuration is easier.
After the installation is completed, the Hong Kong server will be rented. By default, it will be ready for use. You just need to change it to the domain name and access path you need.
Let's get a standard configuration.
The Code is as follows: