ibexa

Path

ez publish / technical manual / 4.x / 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 part of the 4.x documentation is for eZ Publish 4.0, only reference section is common for all eZ Publish 4.x versions as well as eZ Publish 5.x "LegacyStack", please select the version you are using for the most up to date documentation!

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_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|public)/.* - [L]
        RewriteRule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L]
        RewriteRule ^/share/icons/.* - [L]
        RewriteRule ^/extension/[^/]+/design/[^/]+/(stylesheets|flash|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>

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_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>

Geir Arne Waaler (01/10/2010 11:38 am)

Ricardo Correia (17/04/2013 9:58 am)

Geir Arne Waaler, Ricardo Correia


Comments

  • vhost example problem

    Hello,

    For those installing the new ezPublish 4.0 with the AJAX based content menu, please note that there is a mistake with the supplied vhost sample.
    I had to disable the /content/treemenu entry to make it work.

    • Re: vhost example problem

      ooops,
      The PDF version of the manual has correct.
      You can also fix this by changing:
      RewriteRule content/treemenu/? /index_treemenu.php [L]
      into:
      RewriteRule content/treemenu/?$ /index_treemenu.php [L]
  • Missing RewriteRule line for Online Editor 5.0 (

    This standard vhost configuration works great for eZ Publish 4.1, except for Online Editor 5.0, which require an additionnal line (located in the INSTALL file of the ezoe extension, I had to do some searching to found it) in order to display correctly the tinyMCE interface.

    I copy here the line to add

    RewriteRule ^/var/[^/]+/cache/public/.* - [L]
    


    I think it should be added in the standard vhost configuration, as OE 5.0 is bundled with standard installation of eZ Publish. A comment line could be added to indicate the line utility, allowing commenting if OE 5.0 is removed by a developer.
    • Re: Missing RewriteRule line for Online Editor 5.0 (

      With .htaccess I had to remove the first slash :

      RewriteRule ^var/[^/]+/cache/public/.* - [L]