ibexa

Path

ez publish / technical manual / 3.9 / installation / virtual host setup / virtual host example


Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

Virtual host example

This example demonstrates how to set up a virtual host on the Apache web server for an eZ publish installation located in "/var/www/example". Let's say that we want to access eZ publish by using the following URLs:

  • http://www.example.com (actual website for public access)
  • http://admin.example.com (administration interface for the webmaster)

In order to achieve this, we need to set up both eZ publish and the web server so that they respond correctly to the different requests.

eZ publish configuration: siteaccess settings

eZ publish needs to be configured to use the host access method. This can be done from within the web based setup wizard or by manually editing the global override for the site.ini configuration file: "/settings/override/site.ini.append.php". A typical configuration would look something like this:

...
[SiteAccessSettings]
AvailableSiteAccessList[]
AvailableSiteAccessList[]=example
AvailableSiteAccessList[]=example_admin
MatchOrder=host
 
HostMatchMapItems[]=www.example.com;example
HostMatchMapItems[]=admin.example.com;example_admin
...

This configuration tells eZ publish that it should use the "example" siteaccess if a request starts with "www.example.com" and "example_admin" if the request starts with "admin.example.com". For more information about site management in eZ publish, please refer to the "Site management" part of the "Concepts and basics" chapter.

Apache configuration: virtual host settings

Assuming that...

  • eZ publish is located in "/var/www/example"
  • the server's IP address is 128.39.140.28
  • we wish to access eZ publish using "www.example.com" and "admin.example.com"

...the following virtual host configuration needs to be added at the end of "http.conf":

NameVirtualHost 128.39.140.28
 
<VirtualHost 128.39.140.28>
    <Directory /var/www/example>
        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 /var/www/example
    ServerName www.example.com
    ServerAlias admin.example.com
</VirtualHost>

Please note that it isn't necessary to create a separate virtual host block for "admin.example.com", it can be added to the existing block using the "ServerAlias" directive.

You can have apache1 and apache2 part in the sample vhost. That way allows to use one vhost for both servers.

<IfModule mod_php4.c>
# If you are using Apache 2, you have to use <IfModule sapi_apache2.c>
# instead of <IfModule mod_php4.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_php4.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>

Balazs Halasy (17/01/2005 9:49 am)

Svitlana Shatokhina (30/05/2006 8:27 am)

Balazs Halasy, Svitlana Shatokhina


Comments

  • non virtual host install

    Hello,

    Is it possible to configure apache so that ezpublish does not uses virtual hosts, ie like :

    Alias /ezpublish "/usr/local/ezpublish-3.9.0"
    <Directory "/usr/local/ezpublish-3.9.0">
    AcceptPathInfo On
    AddType application/x-httpd-php .php
    ...
    </Directory>

    Regards.