How to configure virtual hosts with multiple ports in apache in linux

Source: Internet
Author: User
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:

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.