How to configure Apache server virtual machine

Apache virtual host is running multiple sites on a single server, each virtual host can bind an independent domain name, you can specify a separate directory for these domain names, access times these domains, Apache will open the corresponding directory stuff . This article describes how to configure Apache to you server virtual machines, and interested friends together to learn it

Apache virtual host is running multiple sites on a single server, each virtual host can bind an independent domain name, you can specify a separate directory for these domain names, access times these domains, Apache will open the corresponding directory stuff . Configuring Apache virtual hosts, just go to modify the Apache configuration file. English is the virtual host virtual host, so your Apache virtual host configuration file may be httpd.conf, it may be associated with the virtual host name of a file, such as vhost.conf, specifically which profile you want to use, you to make their own judgments.

 

Weibo virtual machine configuration step development and introduction.

1, due to the need to use a virtual machine behind Rewrite it to edit the httpd.conf file under the Apache conf directory. (Operation according to the actual needs)

Add mod_rewrite.so module supports. Remove the front of the following rows # Number.

LoadModule rewrite_module modules/mod_rewrite.so

2, configure apache support virtual machines. This step is very important.

Copy the code code is as follows:
# the hosts the Virtual
#Include the conf / Extra / the httpd-vhosts.conf

Find the relevant text above, remove #Include conf / extra / pre-httpd-vhosts.conf #.

Copy the code code is as follows:
# the hosts the Virtual
the Include the conf / Extra / the httpd-vhosts.conf

Save and exit.

3, httpd-vhosts.conf extra folder edit conf directory.

Remove example configuration, there is added a new configuration. Sina microblogging, for example, the configuration file as follows:

## Virtual Hosts## If you want to maintain multiple domains/hostnames on your# machine you 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 see the documentation at# <URL:http://httpd.apache.org/docs/2.2/vhosts/># 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 *:80## 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 <VirtualHost> block.#<VirtualHost *:80># Administrator mailbox ServerAdmin [email protected] # project root directory DocumentRoot "D: / htdocs / frame_export" # domain name ServerName test.t.sina.com.cn # alias ServerAlias ​​test.t.sina.com. cn # error log path ErrorLog "logs / test.t.sins.com.cn-error.log" CustomLog "logs / test.t.sins.com.cn-access.log" commonRewriteEngine on # rewrite rules, according to actual need to add RewriteRule ^ / (. *) $ /apps/index.php [L] </ VirtualHost>

4, edit the local host file to windows, for example

Enter C: / Windows / System32 / drivers / etchttp: //www.bbqmw.net/ baby named Network

Notepad to open the hosts file

Finally, add

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 of IP addresses to host names. Each# entry should be kept on an individual line. The IP address should# be placed in the first column followed by the corresponding host name.# The IP address and the host name should be separated by at least one# space.## Additionally, comments (such as these) may be inserted on individual# lines or following the machine name denoted by a '#' symbol.## For example:## 102.54.94.97 rhino.acme.com # source server# 38.25.63.10 x.acme.com # x client host# localhost name resolution is handled within DNS itself.127.0.0.1 localhost# ::1 localhost127.0.0.1 test.t.sina.com.cn

Guess you like

Origin www.cnblogs.com/murongyuling/p/11009032.html