Virtual host setup
This section describes how to set up a virtual host for eZ publish using the Apache webserver. A virtual host setup is only needed if eZ publish has been configured to use the host access method, which is the most secure method.
By making use of virtual hosts, it is possible to have several sites running on the same server. The sites are usually differentiated by the name they are accessed. Apache will look for a specified set of domains and use different configuration settings based on the domain that is accessed.
Generic virtual host setup
Virtual hosts are usually defined at the end of "httpd.conf", which is the main configuration file for Apache. Adding a virtual host for eZ publish can be done by copying the following lines and replacing the text encapsulated by the square brackets with actual values. Please refer to the next section for a real life example of using virtual hosts.
NameVirtualHost [IP_ADDRESS] <VirtualHost [IP_ADDRESS]:[PORT]> <Directory [PATH_TO_EZPUBLISH]> Options FollowSymLinks AllowOverride None </Directory> <IfModule mod_php4.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 ^/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] |
The IP address of the virtual host, for example "128.39.140.28". Apache allows the usage of a wildcards here ("*"). |
[PORT] |
The port on which the webserver listens for incoming requests. This is an optional setting, the default port is 80. The combination of an IP address and a port is often referred to as a socket. Apache allows the usage of a wildcards here ("*"). |
[PATH_TO_EZPUBLISH] |
Path to the directory that contains eZ publish. This must be the full path, for example "/var/www/ezpublish-3.6.0". |
[SERVER_NAME] |
The host or the IP address that Apache should look for. If a match is found, the virtual host settings will be used. |
[SERVER_ALIAS] |
Additional hosts/IP addresses that Apache should look for. If a match is found, the virtual host settings will be used. |
Please note that the "mod_rewrite" module must be enabled in "httpd.conf" in order to use the Rewrite Rules.
NameVirtualHost
The "NameVirtualHost" setting might already exist in the default configuration. Defining a new one will result in a conflict. If Apache reports errors such as "NameVirtualHost [IP_ADDRESS] has no VirtualHosts" or "Mixing * ports and non-* ports with a NameVirtualHost address is not supported", try skipping the NameVirtualHost line. For more info about the NameVirtualHost directive, see http://httpd.apache.org/docs/1.3/mod/core.html#namevirtualhost.
SOAP and WebDAV
If you would like to use the SOAP and/or the WebDAV features of eZ publish, you'll have to add the following lines in the virtual host configuration:
RewriteCond %{HTTP_HOST} ^webdav\..* RewriteRule ^(.*) /webdav.php [L] RewriteCond %{HTTP_HOST} ^soap\..* RewriteRule ^(.*) /soap.php [L] ServerAlias soap.example.com ServerAlias webdav.example.com
Balazs Halasy (17/01/2005 8:23 am)
Svitlana Shatokhina (22/05/2006 3:11 pm)
Comments
Mistake in last rewrite rule
Tuesday 06 December 2005 12:44:51 pm
Mahmoud Abu-Wardeh
The solution is that the last rewrite rule should read:
RewriteRule .* index.php # no leading slash
See http://www.sitepoint.com/print/mod_rewrite-no-endless-loops for an explanation.
By the way, this VirtualHost setup is quite differet to those in the .htaccess_root file that shops with ez Publish 3.7.2 - would you recommend a selective merge of the two or to stick to this example?
.htaccess
Monday 26 June 2006 4:24:03 pm
Björn Dieding
urls in cache probleme
Friday 12 January 2007 4:54:48 pm
Damien Pitard
http://yoursite.com/anything/here/index.php
and if the cache need to be regenerated, urls will be prefixed with /anything/here
to avoid this problem, we need to remove index.php from url doing an apache redirection
replace
<Directory [PATH_TO_EZPUBLISH]>
Options FollowSymLinks
AllowOverride None
</Directory>
by
<Directory [PATH_TO_EZPUBLISH]>
Options FollowSymLinks
AllowOverride None
RedirectMatch (.*)\index\.php$ $1
</Directory>
Binary files world-readable
Wednesday 14 February 2007 12:23:30 pm
Kristof Coomans
Isn't it better to replace
Rewriterule ^/var/[^/]+/storage/.* - [L]
with more specific rules?
The same counts for
Rewriterule ^/var/storage/.* - [L]
Re: Binary files world-readable
Tuesday 07 August 2007 9:52:05 pm
bjoern
serious security risk is also to expose images... I think we are doomed now... LOL
You can`t simply findout about binary files since you do not know their name MD5.
But you can find out about images if you just look on how they are stored with the path names all over.
php4 and apache2
Thursday 20 September 2007 9:23:33 am
Mauro
<IfModule sapi_apache2.c>
"mod_php4.c" is valid only for Apache 1.3