新浪微博虛擬機器開發設定步驟及介紹。
1、由於後面虛擬機器中需要用到Rewrite所以先編輯Apache的conf目錄下的httpd.conf檔。 (可依實際需求操作)
新增mod_rewrite.so模組支援。去掉下列行中前面的#號。
LoadModule rewrite_module modules/mod_rewrite.so
2、設定apache支援虛擬機器。這一步很重要。
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
找到 上面相關文本,去掉#Include conf/extra/httpd-vhosts.conf前的#。
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
保存退出。
3、編輯conf目錄下extra資料夾下的httpd-vhosts.conf。
去掉實例配置,新增有配置。以新浪微博為例,設定檔如下:
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for 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 ify your virtual hostsme影響
.
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go intoal example:
# Almost any Apaches directive may go intoal Virtual Hoster. not
# match a ServerName or ServerAlias in any
#
#staffs
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
apps/index.php [L]
4、編輯本地host文件,以windows為例
進入C:/Windows/System32/drivers/etc
記事本開啟hosts文件
最後新增
127.0.0.127. localhost
127.0.0.1 test.t.sina.com.cn
範例:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# Thip This is .
# 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
# be placed in the first column followed by
. 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 may be inserted on individual
# lines or following the machine name denote by machine bol#.
# For example:
#
# 102.54.94.97 rhino.acme.com # source 15015. acme.com # x client host
# localhost name resolution is handled within DNS itself.
# ::1 localhost
127.0.0.1 test.t.sina.com.cn
存檔退出原文網址:http://www.server110.com/apache/201309/1615.html
以上就介紹了Apache伺服器中配置虛擬機器的方法,包含了Apache方面的內容,希望對PHP教學有興趣的朋友有幫助。