How to configure virtual machines in the Apache server _linux

Source: Internet
Author: User

Apache Virtual host is to run multiple Web sites on a single server, each virtual host can bind a separate domain name, for these domain names can specify a separate directory, access to these domain names, Apache will open the corresponding directory inside of things. Configure Apache's virtual host, only to modify the Apache configuration file. The virtual host in English is a virtual host, so, your Apache configuration of the files may be httpd.conf, or may be the name of the fictitious host file, such as vhost.conf, specifically to use which configuration file, you need from To judge.


Sina micro-Blog Virtual machine Development configuration steps and introduction.

1, because the following virtual machines need to use the rewrite, so first edit Apache httpd.conf files in the Conf directory. (Can be operated according to actual needs)

Add mod_rewrite.so module support. Remove the # number in front of the line below.

LoadModule Rewrite_module modules/mod_rewrite.so

2, configure Apache support virtual machine. This step is very important.

Copy Code code as follows:

# Virtual Hosts
#Include conf/extra/httpd-vhosts.conf

Find the relevant text above and remove the # before #include conf/extra/httpd-vhosts.conf.

Copy Code code as follows:

# Virtual Hosts
Include conf/extra/httpd-vhosts.conf

Save exit.

3, Edit conf directory under the Extra folder under the httpd-vhosts.conf.

Remove the instance configuration and add a new configuration. Take Sina Weibo as an example, the configuration file is as follows:

# Virtual Hosts # If You are want to maintain multiple domains/hostnames in your # machine you can setup VirtualHost cont Ainers 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 yo
U try to setup virtual hosts.
# with the command line option '-s ' to verify your virtual host # configuration.
# use name-based virtual hosting.
# namevirtualhost *:80 # VirtualHost Example: # Almost any Apache directive could go into a virtualhost container. # the ' The ' the ' the ' the ' the ' the ' the ' is used ' for all requests, ' do not # match a ServerName or Serveralias
Lhost> block. # <virtualhost *:80> #管理员邮箱 ServerAdmin jiangfeng3@staff.sina.com.cn #项目根目录 documentroot "D:/htdocs/frame_export "#域名 ServerName test.t.sina.com. CN #别名 Serveralias test.t.sina.com.cn #错误日志路径 ErrorLog "Logs/test.t.sins.com.cn-error.log customlog" logs/ Test.t.sins.com.cn-access.log "Common Rewriteengine on #重写规则, can add Rewriterule ^/(. *) $/apps/index.php [L] </according to actual needs Virtualhost>

4, edit the local host file, take windows as an example

Enter C:/WINDOWS/SYSTEM32/DRIVERS/ETC

Notepad opens the Hosts file

Add last

127.0.0.1 localhost
127.0.0.1 test.t.sina.com.cn

Example:

# Copyright (c) 1993-2009 Microsoft Corp.
# This is
a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This
file contains the mappings's IP addresses to host names. Each
# entry should is kept on a individual line. The IP address should # is placed in the ' in the ' the ' the ' the ' the '
corresponding host name followed by.
# The IP address and the host name should is separated by at least one
#.
#
Additionally, comments (such as) may is inserted on individual
# lines or following the machine name D Enoted by a ' # ' symbol.
# for
Example: #
102.54.94.97 rhino.acme.com # source Server
# 38.25.63.10 x.acme.com # x client H OST
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
#:: 1 localhost
127.0.0.1 test.t.sina.com.cn

Save exit

5, restart Apache, browser input http://test.t.sina.com.cn

About Apache virtual Machine Server Configuration Small set to introduce so many people, I hope to help you!

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.