亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: 配置PHP虛擬目錄 [打印本頁]

作者: feiyang10086    時間: 2012-02-03 17:05
標題: 配置PHP虛擬目錄
配置PHP虛擬目錄





----------
摘要
----------
本文極為簡要的介紹了如何在Windows平臺下安裝Apache2.2.x并配置虛擬目錄. 以作為快速安裝的參考. 詳細的設(shè)置最好的文檔是官方的說明文檔見下方的鏈接, 在安裝配置的時候仔細的查閱文檔是很好的解決辦法.
1. Apache HTTP Server Version 2.2 英文文檔
2. Apache HTTP Server Version 2.2 中文文檔

----------
準備條件
----------
http://httpd.apache.org/ 下載相應(yīng)版本的Apache. (注意: 2.0與2.2版本的Apache對應(yīng)的Module版本頁不同, 互相不兼容, 因此需要根據(jù)應(yīng)用程序來下載相應(yīng)版本的Apache). 如果不需要使用ssl, 則要下載 Apache 2.x.x-win32-x86-no_ssl.msi, 如果需要使用, 則需要下載Apache 2.x.x-win32-x86-openssl-x.x.x.msi

----------
安裝
----------
雙擊安裝程序, 它將引導(dǎo)你完成整個安裝過程。請確保你輸入正確的服務(wù)器URL(如果你的服務(wù)器沒有DNS名稱,你可以直接輸入IP地址)。建議將Apache安裝成" for all Users,on Port 80,as a service" Apache將自動安裝一個系統(tǒng)服務(wù)以自動啟動。注意:如果你已經(jīng)有一個IIS或者其它的程序使用80端口,安裝可能會失敗。如果是這樣,你可以到程序目錄下的Apache Group\Apache2\conf目錄中找到文件httpd.conf,將其中的Listen 80改成一個不用的端口,比如Listen 81。然后重新運行這個安裝程序,這次應(yīng)該不會再有問題了。

安裝結(jié)束之后在瀏覽器中鍵入 http://loccalhost,如果呈現(xiàn)了一個已經(jīng)配置好的網(wǎng)站,那么Apache就安裝成功了。 如果你將Apache安裝成一個服務(wù),它將以本地system帳戶來運行。為Apache創(chuàng)建一個單獨的用戶來運行它將會更安全一些。

打開Apache的安裝目錄, 找到文件 /conf/httpd.conf, 打開它進行配置的編輯. 配置文件中對于各項都有比較詳細的描述, 在配置結(jié)束之后可以運行開始菜單中Apache安裝文件夾中的Test Configuration工具來檢驗配置文件是否正確. 如果配置不正確會給出簡要的說明. 如果在配置結(jié)束之后通過了Test Configuration工具, 但是仍然不能夠順利運行Apache, 可以到[Apache安裝目錄]/logs/ 這個目錄中查看記錄, 以找出問題所在.

----------
配置 httpd.conf文件
----------
# 設(shè)置文檔主目錄, 后面的就是磁盤的目錄
DocumentRoot "D:/Programs/Apache2.2/htdocs"

# 添加虛擬目錄, 下面的設(shè)置在瀏覽器中輸入 http://localhost/webpath/ 的時候機會訪問服務(wù)器的"D:/Programs/WebPath"目錄
Alias /webpath/ "D:/Programs/WebPath"
# 當/webPath 后面不加"/"的話, 在瀏覽器中可以輸入 http://localhost/webpath Apache會自動的在后面添加"/"
Alias /webpath "D:/Programs/WebPath"

# URL 重定向
Redirect permanent /foo/ http://www.example.com/bar/


# 設(shè)定虛擬主機: 請參考 http://lamp.linux.gov.cn/Apache/ApacheMenu/vhosts/index.html



  在WIN下安裝APACHE配置虛擬目錄和UNIN下基本是一樣的
  就是修改httpd.conf
  1:單個IP對應(yīng)單個玉米
  例如:www.phpunion.com對應(yīng)192.168.1.1
  www.feelone.net對應(yīng)192.168.1.2
  在httpd.conf中加入如下指令
  <VirtualHost 192.168.1.1> #對應(yīng)玉米所指向的IP
   DocumentRoot "c:/web/php" #www.phpunion.com要指向的目錄,注意一定要有""
   ServerName www.phpunion.com #所要綁的玉米
  </VirtualHost>




  <VirtualHost 192.168.1.2> #對應(yīng)玉米所指向的IP
   DocumentRoot "c:/web/feel" #www.feelone.net要指向的目錄,注意一定要有""
   ServerName www.feelone.net #所要綁的玉米
  </VirtualHost>
  剩下的可以繼續(xù)綁!




  2:單個IP對應(yīng)多個玉米



NameVirtualHost 192.168.1.1 #記得一定要有著句啊!
  <VirtualHost 192.168.1.1> #對應(yīng)玉米所指向的IP
    DocumentRoot "c:/web/php" #www.phpunion.com要指向的目錄,注意一定要有""
   ServerName www.phpunion.com #所要綁的玉米
  </VirtualHost>

<VirtualHost 192.168.1.1> #對應(yīng)玉米所指向的IP
  DocumentRoot "c:/web/feel" #www.feelone.net要指向的目錄,注意一定要有""
   ServerName www.feelone.net #所要綁的玉米
  </VirtualHost>





  這樣就綁上對應(yīng)的目錄了,如果沒有NameVirtualHost 192.168.1.1 這個指令的話,所有的玉米就都指到php目錄了.
  然后重新啟動apache,就可以看到所指的玉米對應(yīng)相應(yīng)的虛擬目錄!




Example:
<VirtualHost 10.1.2.3>
ServerAdmin webmaster@host.example.com
DocumentRoot /www/docs/host.example.com
ServerName host.example.com
ErrorLog logs/host.example.com-error_log
TransferLog logs/host.example.com-access_log
</VirtualHost>











今天網(wǎng)站建設(shè)技術(shù)部的PHP程序員教了我一個在本地實現(xiàn)虛擬一個域名來訪問本機電腦的數(shù)據(jù)的方法,首先說說我本地的環(huán)境是:WIN2003+xampp。其實能實現(xiàn)效果就行,直接用xampp的最好方法就是省事,不用一個一個軟件安裝!然后下面一步一步實現(xiàn)虛擬一個www.123.com來訪問本地網(wǎng)站程序。
1.關(guān)閉xampp的apache,然后找到C:\xampp\apache\conf\extra\httpd-vhosts.conf文件:
在##NameVirtualHost *:80 下面加入以下代碼,其中的IP為本地電腦的IP,可以進入CMD使用ipconfig查詢到本機IP
NameVirtualHost 192.168.1.101:80
然后把以下代碼復(fù)制一份
##<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
##DocumentRoot "C:/xampp/htdocs/dummy-host2.localhost"
##ServerName dummy-host2.localhost
##ServerAlias www.dummy-host2.localhost
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
##</VirtualHost>
修改成以下代碼
<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
DocumentRoot "E:/php/ecshop2.72"
ServerName www.123.com
ServerAlias www.123.com
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>
其中DocumentRoot 是本機網(wǎng)站制作程序的路徑,ServerName及ServerAlias 就是要虛擬的域名網(wǎng)址,這個隨便你高興了
2.找到C:\xampp\apache\conf\httpd.conf文件,找到以下代碼:
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
把上面的兩個網(wǎng)站目錄的路徑修改成上面設(shè)置的路徑
DocumentRoot "E:/php"
<Directory "E:/php">
因為設(shè)置了虛擬的域名網(wǎng)址,所以路徑不用再加上網(wǎng)站的文件夾名稱了
3.然后打開C:\WINDOWS\system32\drivers\etc\hosts 文件,
在127.0.0.1 localhost下添加你要添加的虛擬域名網(wǎng)址
127.0.0.1 localhost
192.168.1.101 www.123.com
呵呵,修改這三個文件之后就OK了,現(xiàn)在可以重新啟動xampp的apache了,然后在IE里輸入www.123.com就能訪問本地的網(wǎng)站程序了,這樣測試的好處是能把本機虛擬成服務(wù)器,有些東東很方便就能調(diào)試!當然,用localhost也是還可以訪問了,這個功能用不到的話也沒必要這么搞,我是因為有時用到Magento程序,使用域名會更好,不會有一些莫名其妙的問題。當然了,如果你有好幾個網(wǎng)站的話,每次都要修改一下C:\xampp \apache\conf\extra\httpd-vhosts.conf對應(yīng)的DocumentRoot "E:/php/ecshop2.72",因為我的網(wǎng)頁設(shè)計的PHP程序都是放在E盤下的PHP文件夾,然后每個網(wǎng)站就一個文件夾,這樣每次只需要修改一個文件就OK了,看個人愛好了,共享出來讓大家玩玩,嘿嘿!








詳細配置:http://httpd.apache.org/docs/2.2/vhosts/

中文配置:http://www.zzxj.net/web/manual/A ... /rewrite_guide.html









Apache虛擬主機的配置



虛擬主機的配置



基于IP地址的虛擬主機配置
Listen 80
DocumentRoot /www/example1
ServerName www.example1.com
DocumentRoot /www/example2
ServerName www.example2.org







基于IP和多端口的虛擬主機配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080



DocumentRoot /www/example1-80
ServerName www.example1.com
DocumentRoot /www/example1-8080
ServerName www.example1.com
DocumentRoot /www/example2-80
ServerName www.example1.org
DocumentRoot /www/example2-8080
ServerName www.example2.org



單個IP地址的服務(wù)器上基于域名的虛擬主機配置:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here



在多個IP地址的服務(wù)器上配置基于域名的虛擬主機:
Listen 80
# This is the “main” server running on 172.20.30.40
ServerName server.domain.com
DocumentRoot /www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
DocumentRoot /www/example1
ServerName www.example1.com
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …



在不同的端口上運行不同的站點:
基于多端口的服務(wù)器上配置基于域名的虛擬主機。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.example1.com
DocumentRoot /www/domain-80
ServerName www.example1.com
DocumentRoot /www/domain-8080
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080



基于域名和基于IP的混合虛擬主機的配置:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot /www/example1
ServerName www.example1.com
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net







自己的設(shè)置



hosts







127.0.0.1 localhost
127.0.0.1 fantsi







httpd.conf
  1. Alias /fantsi/ "E:/xampp/htdocs/fantsi"

  2. NameVirtualHost 127.0.0.1
  3. <VirtualHost 127.0.0.1 >
  4. DocumentRoot "E:/xampp/htdocs"
  5. ServerName localhost
  6. ServerAlias localhost
  7. </VirtualHost>

  8. <VirtualHost 127.0.0.1 >
  9. DocumentRoot "E:/xampp/htdocs/fantsi"
  10. ServerName fantsi
  11. ServerAlias fantsi
  12. </VirtualHost>
復(fù)制代碼

作者: 如果有一天21    時間: 2012-02-03 17:06
謝謝分享




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2