EZ Publish/EZ Publish虚拟主机设置
EZ Publish | EZ Publish安装与卸载 | EZ Publish的使用 | EZ Publish常见问题 | EZ Publish其他 |
本条目介绍了如何在Apache 中为eZ Publish 配置虚拟主机。只有当使用主机名访问方法(最安全的方法)时,才需要配置虚拟主机。
通过使用虚拟注意,可以在同一台服务器上运行多个站点。站点通常是通过它们各自的主机名来区分。Apache 会根据访问的域名使用相应的配置。
通用虚拟注意配置[ ]
虚拟主机通常在"httpd.conf"(Apache 服务器的主要配置文件)结尾处定义。可以复制以下内容并替换方括号"[]"内部的内容。参阅下面真实的虚拟主机配置文件示例。
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] | 虚拟主机的IP 地址,例如:"128.39.140.28"。Apache 允许使用通配符("*") |
[PORT] | WEB 服务器的监听端口。端口配置是可选配置,默认端口为80。IP 地址与端口的组合通常被称为套接字。Apache 允许使用通配符("*") |
[PATH_TO_EZPUBLISH] | eZ Publish 安装目录的绝对路径。如:"/var/www/ezpublish-3.6.0" |
[SERVER_NAME] | Apache 需要监控的IP 地址或主机名。如果匹配,对应的虚拟主机配置会被使用 |
[SERVER_ALIAS] | Apache 需要监控的附加的主机名/IP 地址。如果匹配,对应的虚拟主机配置会被使用 |
注意:"mod_rewrite"模块必须在"httpd.conf"中启用,才能使用Rewrite Rules。
NameVirtualHost[ ]
"NameVirtualHost"配置可能已经存在。如果定义新的NameVirtualHost 会造成冲突。如果“ Apache 报告如“NameVirtualHost [IP_ADDRESS]没有VirtualHost ”或“ 不能混用*端口和非*端口的NameVirtualHost 地址 ”的错误,尝试注释NameVirtualHost 这一行。详情请参阅http://httpd.apache.org/docs/1.3/mod/core.html#namevirtualhost 了解更多关于NameVirtualHost 的内容。
SOAP 与WebDAV[ ]
如果希望在eZ Publish 中使用SOAP 与/或WebDAV,需要在虚拟主机配置文件中添加以下内容:
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 配置虚拟主机。假设eZ Publish 安装在"/var/www/example",并且可以通过以下URL 访问:
• http://www.example.com (公共站点入口)
• http://admin.example.com(管理界面站点入口)
为了达到这个目的,需要配置Apache 和eZ Publish 从而保证它们可以正确相应不同的请求。
配置eZ Publish[ ]
站点入口配置eZ Publish 需要被配置为使用主机名访问方法。可以通过安装向导或手动编辑"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"站点入口,为"admin.example.com"使用"example_admin"站点入口。参阅“EZ Publish基本概念(二)”中的“站点管理”章节了解更多站点管理的内容。
Apache 配置[ ]
虚拟主机配置
对此我们先做出一个安装假设
• eZ Publish 被安装在"/var/www/example"
• 服务器IP 地址为128.39.140.28
• 希望通过"www.example.com"和"admin.example.com"访问站点
以下虚拟主机配置需要被添加到"http.conf"结尾处:
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"配置单独的虚拟主机,它可以作为"ServerAlias"添加。
可以在同一个虚拟主机内使用apache1 和apache2。这种方式允许用户为两个服务器中使用同一个虚拟主机。
<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>