程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> Apache服務器中配置虛擬機的方法,apache虛擬機

Apache服務器中配置虛擬機的方法,apache虛擬機

編輯:關於PHP編程

Apache服務器中配置虛擬機的方法,apache虛擬機


新浪微博虛擬機開發配置步驟及介紹。
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 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>
    #管理員郵箱
    ServerAdmin  [email protected] 
    #項目根目錄   
    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
    #重寫規則,可根據實際需要添加
    RewriteRule  ^/(.*)$       /apps/index.php [L]
</VirtualHost>
4、編輯本地host文件,以windows為例
進入C:/Windows/System32/drivers/etc
記事本打開hosts文件
最後添加
 127.0.0.1       localhost
 127.0.0.1       test.t.sina.com.cn
例子:
# 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
保存退出
5、重啟apache,浏覽器輸入http://test.t.sina.com.cn

轉載請注明原文地址:http://www.server110.com/apache/201309/1615.html

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved