WIKI使用導(dǎo)航
站長(zhǎng)百科導(dǎo)航
站長(zhǎng)專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢
- 虛擬主機(jī)
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計(jì)算
- 微博營(yíng)銷
- 虛擬主機(jī)管理系統(tǒng)
- 開放平臺(tái)
- WIKI程序與應(yīng)用
- 美國(guó)十大主機(jī)
EZ Publish/EZ Publish虛擬主機(jī)設(shè)置
EZ Publish | EZ Publish安裝與卸載 | EZ Publish的使用 | EZ Publish常見問題 | EZ Publish其他 |
本條目介紹了如何在Apache 中為eZ Publish 配置虛擬主機(jī)。只有當(dāng)使用主機(jī)名訪問方法(最安全的方法)時(shí),才需要配置虛擬主機(jī)。
通過(guò)使用虛擬注意,可以在同一臺(tái)服務(wù)器上運(yùn)行多個(gè)站點(diǎn)。站點(diǎn)通常是通過(guò)它們各自的主機(jī)名來(lái)區(qū)分。Apache 會(huì)根據(jù)訪問的域名使用相應(yīng)的配置。
通用虛擬注意配置[ ]
虛擬主機(jī)通常在"httpd.conf"(Apache 服務(wù)器的主要配置文件)結(jié)尾處定義??梢詮?fù)制以下內(nèi)容并替換方括號(hào)"[]"內(nèi)部的內(nèi)容。參閱下面真實(shí)的虛擬主機(jī)配置文件示例。
NameVirtualHost [IP_ADDRESS] <VirtualHost [IP_ADDRESS]:[PORT]> <Directory [PATH_TO_EZPUBLISH]> Options FollowSymLinks AllowOverride None </Directory> <IfModule mod_php5.c> php_admin_flag safe_mode Off php_admin_value register_globals 0 php_value magic_quotes_gpc 0 php_value magic_quotes_runtime 0 php_value allow_call_time_pass_reference 0 </IfModule> DirectoryIndex index.php <IfModule mod_rewrite.c> RewriteEngine On RewriteRule content/treemenu/?$ /index_treemenu.php [L] Rewriterule ^/var/storage/.* - [L] Rewriterule ^/var/[^/]+/storage/.* - [L] RewriteRule ^/var/cache/texttoimage/.* - [L] RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L] Rewriterule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L] Rewriterule ^/share/icons/.* - [L] Rewriterule ^/extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L] Rewriterule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L] RewriteRule ^/packages/styles/.+/thumbnail/.* - [L] RewriteRule ^/favicon\.ico - [L] RewriteRule ^/robots\.txt - [L] # Uncomment the following lines when using popup style debug. # RewriteRule ^/var/cache/debug\.html.* - [L] # RewriteRule ^/var/[^/]+/cache/debug\.html.* - [L] RewriteRule .* /index.php </IfModule> DocumentRoot [PATH_TO_EZPUBLISH] ServerName [SERVER_NAME] ServerAlias [SERVER_ALIAS] </VirtualHost>
[IP_ADDRESS] | 虛擬主機(jī)的IP 地址,例如:"128.39.140.28"。Apache 允許使用通配符("*") |
[PORT] | WEB 服務(wù)器的監(jiān)聽端口。端口配置是可選配置,默認(rèn)端口為80。IP 地址與端口的組合通常被稱為套接字。Apache 允許使用通配符("*") |
[PATH_TO_EZPUBLISH] | eZ Publish 安裝目錄的絕對(duì)路徑。如:"/var/www/ezpublish-3.6.0" |
[SERVER_NAME] | Apache 需要監(jiān)控的IP 地址或主機(jī)名。如果匹配,對(duì)應(yīng)的虛擬主機(jī)配置會(huì)被使用 |
[SERVER_ALIAS] | Apache 需要監(jiān)控的附加的主機(jī)名/IP 地址。如果匹配,對(duì)應(yīng)的虛擬主機(jī)配置會(huì)被使用 |
注意:"mod_rewrite"模塊必須在"httpd.conf"中啟用,才能使用Rewrite Rules。
NameVirtualHost[ ]
"NameVirtualHost"配置可能已經(jīng)存在。如果定義新的NameVirtualHost 會(huì)造成沖突。如果“ Apache 報(bào)告如“NameVirtualHost [IP_ADDRESS]沒有VirtualHost ”或“ 不能混用*端口和非*端口的NameVirtualHost 地址 ”的錯(cuò)誤,嘗試注釋NameVirtualHost 這一行。詳情請(qǐng)參閱http://httpd.apache.org/docs/1.3/mod/core.html#namevirtualhost 了解更多關(guān)于NameVirtualHost 的內(nèi)容。
SOAP 與WebDAV[ ]
如果希望在eZ Publish 中使用SOAP 與/或WebDAV,需要在虛擬主機(jī)配置文件中添加以下內(nèi)容:
RewriteCond %{HTTP_HOST} ^webdav\..* RewriteRule ^(.*) /webdav.php [L] RewriteCond %{HTTP_HOST} ^soap\..* RewriteRule ^(.*) /soap.php [L] ServerAlias soap.example.com ServerAlias webdav.example.com
配置示例[ ]
此示例演示了如何在Apache 中為eZ Publish 配置虛擬主機(jī)。假設(shè)eZ Publish 安裝在"/var/www/example",并且可以通過(guò)以下URL 訪問:
? http://www.example.com (公共站點(diǎn)入口)
? http://admin.example.com(管理界面站點(diǎn)入口)
為了達(dá)到這個(gè)目的,需要配置Apache 和eZ Publish 從而保證它們可以正確相應(yīng)不同的請(qǐng)求。
配置eZ Publish[ ]
站點(diǎn)入口配置eZ Publish 需要被配置為使用主機(jī)名訪問方法??梢酝ㄟ^(guò)安裝向?qū)Щ蚴謩?dòng)編輯"settings/override/site.ini.append.php"。典型的配置如下:
... [SiteAccessSettings] AvailableSiteAccessList[] AvailableSiteAccessList[]=example AvailableSiteAccessList[]=example_admin MatchOrder=host HostMatchMapItems[]=www.example.com;example HostMatchMapItems[]=admin.example.com;example_admin ...
以上配置要求eZ Publish 為"www.example.com"使用"example"站點(diǎn)入口,為"admin.example.com"使用"example_admin"站點(diǎn)入口。參閱“EZ Publish基本概念(二)”中的“站點(diǎn)管理”章節(jié)了解更多站點(diǎn)管理的內(nèi)容。
Apache 配置[ ]
虛擬主機(jī)配置
對(duì)此我們先做出一個(gè)安裝假設(shè)
? eZ Publish 被安裝在"/var/www/example"
? 服務(wù)器IP 地址為128.39.140.28
? 希望通過(guò)"www.example.com"和"admin.example.com"訪問站點(diǎn)
以下虛擬主機(jī)配置需要被添加到"http.conf"結(jié)尾處:
NameVirtualHost 128.39.140.28 <VirtualHost 128.39.140.28> <Directory /var/www/example> Options FollowSymLinks AllowOverride None </Directory> <IfModule mod_php5.c> php_admin_flag safe_mode Off php_admin_value register_globals 0 php_value magic_quotes_gpc 0 php_value magic_quotes_runtime 0 php_value allow_call_time_pass_reference 0 </IfModule> DirectoryIndex index.php <IfModule mod_rewrite.c> RewriteEngine On RewriteRule content/treemenu/?$ /index_treemenu.php [L] Rewriterule ^/var/storage/.* - [L] Rewriterule ^/var/[^/]+/storage/.* - [L] RewriteRule ^/var/cache/texttoimage/.* - [L] RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L] Rewriterule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L] Rewriterule ^/share/icons/.* - [L] Rewriterule ^/extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L] Rewriterule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L] RewriteRule ^/packages/styles/.+/thumbnail/.* - [L] RewriteRule ^/favicon\.ico - [L] RewriteRule ^/robots\.txt - [L] # Uncomment the following lines when using popup style debug. # RewriteRule ^/var/cache/debug\.html.* - [L] # RewriteRule ^/var/[^/]+/cache/debug\.html.* - [L] RewriteRule .* /index.php </IfModule> DocumentRoot /var/www/example ServerName www.example.com ServerAlias admin.example.com </VirtualHost>
注意:不必為"admin.example.com"配置單獨(dú)的虛擬主機(jī),它可以作為"ServerAlias"添加。
可以在同一個(gè)虛擬主機(jī)內(nèi)使用apache1 和apache2。這種方式允許用戶為兩個(gè)服務(wù)器中使用同一個(gè)虛擬主機(jī)。
<IfModule mod_php5.c> # If you are using Apache 2, you have to use <IfModule sapi_apache2.c> # instead of <IfModule mod_php5.c>. # some parts/addons might only run safe mode on php_admin_flag safe_mode Off # security just in case php_admin_value register_globals 0 # performance php_value magic_quotes_gpc 0 # performance php_value magic_quotes_runtime 0 #http://www.php.net/manual/en/ini.core.php#ini.allow-call-time-pass-reference php_value allow_call_time_pass_reference 0 </IfModule> <IfModule sapi_apache2.c> # If you are using Apache 2, you have to use <IfModule sapi_apache2.c> # instead of <IfModule mod_php5.c>. # some parts/addons might only run safe mode on php_admin_flag safe_mode Off # security just in case php_admin_value register_globals 0 # performance php_value magic_quotes_gpc 0 # performance php_value magic_quotes_runtime 0 #http://www.php.net/manual/en/ini.core.php#ini.allow-call-time-pass-reference php_value allow_call_time_pass_reference 0 </IfModule>