Home  >  Article  >  Backend Development  >  How to configure a virtual machine in Apache server, apache virtual machine_PHP tutorial

How to configure a virtual machine in Apache server, apache virtual machine_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:54:44976browse

How to configure virtual machines in Apache server, apache virtual machine

Sina Weibo virtual machine development and configuration steps and introduction.
1. Since Rewrite will be used in the virtual machine later, edit the httpd.conf file in the conf directory of Apache first. (Can be operated according to actual needs)
Add mod_rewrite.so module support. Remove the # sign in front of the following lines.
LoadModule rewrite_module modules/mod_rewrite.so
2. Configure apache to support virtual machines. This step is very 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 httpd-vhosts.conf in the extra folder in the conf directory.
Remove the instance configuration and add new configuration. Taking 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 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
#
# 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 block.
#

#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 ​​lias 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, you can add them according to actual needs
RewriteRule ^/(.*)$ /apps/index.php [L]

4. Edit the local host file, taking windows as an example
Enter C:/Windows/System32/drivers/etc
Open the hosts file with notepad
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 localhost
127.0. 0.1 test.t.sina.com.cn
Save and exit
5. Restart apache and enter http://test.t.sina.com.cn
in the browser

Please indicate the original address for reprinting: http://www.server110.com/apache/201309/1615.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1119057.htmlTechArticleHow to configure virtual machines in Apache server, apache virtual machine Sina Weibo virtual machine development and configuration steps and introduction. 1. Since Rewrite will be used in the virtual machine later, edit Apach first...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn