How to configure virtual machines on the Apache server
Development and configuration steps and introduction of Sina Weibo virtual machine.
1. Because Rewrite needs to be used in subsequent virtual machines, edit the httpd. conf file in the conf directory of Apache first. (Operations can be performed as needed)
Added support for the mod_rewrite.so module. Remove the # In front of the following line.
LoadModule rewrite_module modules/mod_rewrite.so
2. Configure apache to support virtual machines. This step is important.
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
Find the relevant text above and remove the # Before # Include conf/extra/httpd-vhosts.conf #.
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Save and exit.
3. Edit the httpd-vhosts.conf under the extra folder under the conf directory.
Remove instance configuration and add new configuration. Take Sina Weibo as an example. The configuration file 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
# <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 email
ServerAdmin jiangfeng3@staff.sina.com.cn
# 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" common
RewriteEngine on
# Rewrite rules, which can be added as needed
RewriteRule ^/(. *) $/apps/index. php [L]
</VirtualHost>
4. Edit the local host file. Take windows as an example.
Go to C:/Windows/System32/drivers/etc
Open the hosts file in Notepad
Last added
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 shoshould be kept on an individual line. The IP address shold
# Be placed in the first column followed by the corresponding host name.
# The IP address and the host name shocould 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 localhost
127.0.0.1 test.t.sina.com.cn
Save and exit
5, restart apache, browser input http://test.t.sina.com.cn
Reprinted please indicate the original address: http://www.server110.com/apache/201309/1615.html