Linux environment Apache Multi-port configuration virtual host method in depth introduce _php skills

Source: Internet
Author: User
By default, Apache on Linux uses the
The default document directory is:/var/www
The default port is: 80
If you want to publish a system resource directory of your own, you can use the following method to execute the following command:
(1) Add listening port
#cd/etc/apache2
#vim ports.conf
File add:
Namevirtualhost *:8000
Listen 8000
(2) Configure the virtual directory
#cd/etc/apache2/sites-available
#cp default Default-me
#vim Default-me
The contents of the document are as follows:
Copy Code code as follows:

<virtualhost *: 8000 >
ServerAdmin Webmaster@localhost
DocumentRoot/ wwwroot
<directory/>
Options FollowSymLinks
AllowOverride None
</Directory>
<directory/ wwwroot/>
Options Indexes followsymlinks MultiViews
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
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
</VirtualHost>

The bold part is the key point.
(3) Publishing site
# ln-s/etc/apache2/sites-available/default-me/etc/apache2/sites-enabled/001-default
(4) Restart service
#/etc/init.d/apache2 restart
(5) test
Http://localhost:8000/
The configuration is correct if you are able to access it properly.
Copy Code code as follows:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Virtual Hosts
#
# If you are want to maintain multiple domains/hostnames on your
# machine can setup virtualhost containers for them. Most configurations
# 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, the documentation at
# <url:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before your try to setup virtual hosts.
#
# with 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 could into a virtualhost container.
# the ' The ' the ' the ' the ' the ' virtualhost ' is used ' for all requests
# match a ServerName or serveralias in any <VirtualHost> blocks.
#
<virtualhost *:81>
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/appserv/www/www-nongye
ServerName www.dede.com
ErrorLog D:/appserv/www/www-nongye/errornongye.log
Customlog Logs/dummy-host2.appservnetwork.com-access_log Common
</VirtualHost>
<virtualhost *:82>
<directory "D:/APPSERV/WWW-CHINAEC" >
Options FollowSymLinks
#Deny from all
Allow from all
</Directory>
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/APPSERV/WWW-CHINAEC
ServerName www.dede.com
DirectoryIndex index.php index.html
ErrorLog D:/appserv/www-chinaec/errornongjiale.log
Customlog Logs/dummy-host2.appservnetwork.com-access_log Common
</VirtualHost>
<virtualhost *:83>
ServerAdmin jsw7001@hotmail.com
DocumentRoot d:/appserv/www/www-05110
ServerName www.dede.com
ErrorLog D:/appserv/www/www-05110/errornong05110.log
Customlog Logs/dummy-host2.appservnetwork.com-access_log Common
</VirtualHost>
<virtualhost *:84>
ServerAdmin jsw7001@hotmail.com
DocumentRoot d:/appserv/www/wordpress
ServerName www.dede.com
ErrorLog D:/appserv/www/wordpress/errornongwordpress.log
Customlog Logs/dummy-host2.appservnetwork.com-access_log Common
</VirtualHost>
<virtualhost *:85>
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/appserv/www/magento
ServerName www.dede.com
ErrorLog D:/appserv/www/magento/errormagento.log
Customlog Logs/dummy-host2.appservnetwork.com-access_log Common
</VirtualHost>
<virtualhost *:86>
ServerAdmin jsw7001@hotmail.com
DocumentRoot d:/appserv/www/magento1322
ServerName www.dede.com
ErrorLog D:/appserv/www/magento1322/errormagento1322.log
Customlog Logs/dummy-host2.appservnetwork.com-access_log Common
</VirtualHost>
<virtualhost *:88>
ServerAdmin jsw7001@hotmail.com
DocumentRoot D:/appserv/www/www-nongjiale
ServerName www.dede.com
ErrorLog D:/appserv/www/www-nongjiale/errornongjiale.log
Customlog Logs/dummy-host2.appservnetwork.com-access_log Common
</VirtualHost>
<virtualhost *:80>
ServerAdmin webmaster@dummy-host2.x
DocumentRoot "c:/apache2.2/docs/dummy-host2.x"
ServerName dummy-host2.x
ErrorLog "Logs/dummy-host2.x-error.log"
Customlog "Logs/dummy-host2.x-access.log" common
</VirtualHost>

1, single domain name single port setting
such as: www.abc.com by default with 80 access

Specifically, Apache configuration by default in the installation directory of the Conf directory inside
or a/etc/apache2.
However, it is important to note that port monitoring is turned on in the listen.conf file.
The following figure indicates that 80-port listening has been turned on

Direct default
1, single domain name single port setting
such as: www.abc.com by default with 80 access

Specifically, Apache configuration by default in the installation directory of the Conf directory inside
or a/etc/apache2.
However, it is important to note that port monitoring is turned on in the listen.conf file.
The following figure indicates that 80-port listening has been turned on
Direct Default Modification default-server.conf

This configuration is best simple
installed, and then the default has been able to use, but to change it to the domain name you need and access to the path.

Give a standard configuration.
Copy Code code as follows:

DocumentRoot "/srv/www/htdocs"
#
# Configure The DocumentRoot
#
<directory "/srv/www/htdocs" >
# Possible values for the Options directive are ' None ', ' all ',
# or any combination of:
# Indexes Includes followsymlinks symlinksifownermatch execcgi multiviews
#
# that ' MultiViews ' must be named *explicitly*---' Options all '
# doesn ' t give it to you.
#
# The Options directive is both complicated and important. Please
# http://httpd.apache.org/docs-2.2/mod/core.html#options
# for more information.
Options None
# AllowOverride Controls What directives may is placed in. htaccess files.
# It can be ' all ', ' None ', or any combination of the keywords:
# Options FileInfo authconfig Limit
AllowOverride None
# Controls who can get stuff from this server.
Order Allow,deny
Allow from all
</Directory>

2. Single-domain multi-port setting
Copy Code code as follows:

<directory "/srv/www/htdocs/bbs" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
<directory "/srv/www/htdocs/" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
Namevirtualhost *:80
Namevirtualhost *:81
<virtualhost *:80>
DirectoryIndex index.html index.php
ServerName "Www.abc.com"
DocumentRoot "/srv/www/htdocs/"
</VirtualHost>
<virtualhost *:81>
DirectoryIndex index.php
ServerName "www.abc.com:81"
DocumentRoot "/srv/www/htdocs/bbs/"
</VirtualHost>

3, multiple domain name multi-port settings
Copy Code code as follows:

<directory "/SRV/WWW/HTDOCS/BTC" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
<directory "/srv/www/htdocs/bbs" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
<directory "/srv/www/htdocs/" >
Options None
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
Namevirtualhost *:80
Namevirtualhost *:81
<virtualhost *:80>
DirectoryIndex index.html index.php
ServerName "Www.abc.com"
DocumentRoot "/srv/www/htdocs/"
</VirtualHost>
<virtualhost *:80>
DirectoryIndex index.html index.php
ServerName "Www.btc.com"
DocumentRoot "/SRV/WWW/HTDOCS/BTC"
</VirtualHost>
<virtualhost *:81>
DirectoryIndex index.php
ServerName "www.abc.com:81"
DocumentRoot "/srv/www/htdocs/bbs/"
</VirtualHost>

Need to pay attention to the problem is that multiport listening, be sure to pay attention to the listen.conf file, whether the corresponding port is open.
Related Article

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.