Linux environment Apache Multi-port configuration virtual host method in-depth introduction to _php Tutorial

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 your own system resource directory, you can use the following method to execute the following command:
(1) Adding a listening port
#cd/etc/apache2
#vim ports.conf
File Additions:
Namevirtualhost *:8000
Listen 8000
(2) Configuring the virtual directory
#cd/etc/apache2/sites-available
#cp default Default-me
#vim Default-me
The contents of the file are as follows:
Copy CodeThe code is as follows:
8000 >
ServerAdmin Webmaster@localhost
DocumentRoot/ wwwroot

Options FollowSymLinks
AllowOverride None

wwwroot/>
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) 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/
If normal access is available, the configuration is correct.
Copy CodeThe code is as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine your can setup VirtualHost containers for them. Most configurations
# Use of name-based virtual hosts so the server doesn ' t need to worry about
# IP addresses. This was indicated by the asterisks in the directives below.
#
# documentation at
#
# for further details before your try to setup virtual hosts.
#
# 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 go into a VirtualHost container.
# The first VirtualHost section was used for all requests and that does not
# match a ServerName or Serveralias in any Block.
#

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



Options FollowSymLinks
#Deny from all
Allow from all

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


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


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


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


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


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


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


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

In particular, Apache configuration defaults to the Conf directory under the installation directory.
or a/etc/apache2.
However, be sure to note that the port listener in the listen.conf file is turned on
For example, indicates that 80-port monitoring is turned on

Direct Default
1. Single-domain single port setting
such as: www.abc.com by default with 80 access

In particular, Apache configuration defaults to the Conf directory under the installation directory.
or a/etc/apache2.
However, be sure to note that the port listener in the listen.conf file is turned on
For example, indicates that 80-port monitoring is turned on
Direct Default Modification default-server.conf

This configuration is best for simple
installed, and then, the default is ready to use, just to change it to the domain you need and access to the path.

Give it a standard configuration.
Copy CodeThe code is as follows:
DocumentRoot "/srv/www/htdocs"
#
# Configure The DocumentRoot
#

# Possible values for the Options directive is "None", "all",
# or any combination of:
# Indexes includes followsymlinks symlinksifownermatch execcgi multiviews
#
# Note that "MultiViews" must is named *explicitly*---"Options all"
# doesn ' t give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.2/mod/core.html#options
# for more information.
Options None
# AllowOverride Controls What directives 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 the this server.
Order Allow,deny
Allow from all


2, single-domain multi-port settings
Copy CodeThe code is as follows:

Options None
AllowOverride None
Order Allow,deny
Allow from all


Options None
AllowOverride None
Order Allow,deny
Allow from all

Namevirtualhost *:80
Namevirtualhost *:81

DirectoryIndex index.html index.php
ServerName "Www.abc.com"
DocumentRoot "/srv/www/htdocs/"


DirectoryIndex index.php
ServerName "www.abc.com:81"
DocumentRoot "/srv/www/htdocs/bbs/"


3. Multi-domain multiport setting
Copy CodeThe code is as follows:

Options None
AllowOverride None
Order Allow,deny
Allow from all


Options None
AllowOverride None
Order Allow,deny
Allow from all


Options None
AllowOverride None
Order Allow,deny
Allow from all

Namevirtualhost *:80
Namevirtualhost *:81

DirectoryIndex index.html index.php
ServerName "Www.abc.com"
DocumentRoot "/srv/www/htdocs/"


DirectoryIndex index.html index.php
ServerName "Www.btc.com"
DocumentRoot "/SRV/WWW/HTDOCS/BTC"


DirectoryIndex index.php
ServerName "www.abc.com:81"
DocumentRoot "/srv/www/htdocs/bbs/"


Need to pay attention to the problem is, multi-port monitoring, be sure to note the listen.conf file, whether the corresponding port is opened.

http://www.bkjia.com/PHPjc/327524.html www.bkjia.com true http://www.bkjia.com/PHPjc/327524.html techarticle By default, the default document directory used by Apache on Linux is:/var/www The default port is: 80 If you want to publish your own system resource directory, you can use the following method to perform as ...

  • 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.