Using site access
What is site access?
Once you've gotten eZ publish up and running on a server you need to configure the system.
You can have several different sites running on the same eZ publish installation to distinguish
between these sites you need to set up something called site access. The site access defines
how eZ publish will recognize which site you're accessing. eZ publish will then know which database
to use, which design to show etc.
Site access configuration
Host
In this example we will name our site 'www.mybookstore.com' and we will use the 'admin.mybookstore.com'
as the administration interface. To make eZ publish fetch site access from host names you need to
configure a DNS server and point the domains to your web server. When your DNS is up and running
and the names resolve to your web server and your eZ publish installation you need to make eZ publish
recognize the names and use the correct configuration. To do this you open the configuration file
found in 'settings/site.ini' in the root of your eZ publish installation. In site.ini browse down to
the section [SiteAccessSettings] and alter the configuration like shown below. Only the settings
you need to change is shown below.
file: settings/site.ini
[SiteAccessSettings]
MatchOrder=host
HostMatchRegexp=^(.+)\.mybookstore\.com$
HostMatchSubtextPost=\.mybookstore\.com
Here we told eZ publish to take the part before .mybootstore.com of the url and map it to a directory in settings/siteaccess.
If we enter 'www.mybookstore.com' in our browser eZ publish will look a directory called 'www' in settings/siteacces.
Now that eZ publish knows how to distinguish between the two domains we need to create a configuration
file for each site. This is done by creating two folders under 'settings/siteaccess/' which
corresponds to our matches ( 'www' and 'admin' ). In both these folder you need to create a file
called site.ini.append. This is the configuration file which will be used to override any of
the standard settings in eZ publish. We will keep our example simple and have just made a few
settings distinguish between the two sites. You can see the two configuration files below.
file: settings/siteaccess/admin/site.ini.append
[SiteSettings]
LoginPage=custom
[SiteAccessSettings]
RequireUserLogin=true
The configuration LoginPage=custom means that eZ publish will use a separate template for
the login page of the administration site. RequireUserLogin=true tells eZ publish not to
let anyone inside eZ publish unless they're logged into the system.
file: settings/siteaccess/www/site.ini.append
[DesignSettings]
SiteDesign=mybookstore
[SiteAccessSettings]
RequireUserLogin=false
The settings above applies to the website. SiteDesign=mybookstore means that eZ publish
will prefer to use the design for the site found in design/mybookstore, RequireUserLogin=false
is set so that users do not have to log into eZ publish to browse the website.
Host Match Map
In the previous example we used a regexp to map part of the url to different sites. This is a very
powerful way of matching, but if you do not have experience or do not understand regexp,
this approach might be a very difficult. Instead of regexp we can make a list of URL's and tell eZ publish 3
to match them to a site. See configuration example below.
file: settings/site.ini
[SiteAccessSettings]
MatchOrder=host
HostMatchType=map
HostMatchMapItems[]=mybookstore.com;user
HostMatchMapItems[]=www.mybookstore.com;user
HostMatchMapItems[]=admin.mybookstore.com;admin
As you might see from the example we mapped 'mybootkstore.com', 'www.mybookstore.com' to the user site
and 'admin.mybookstore.com' to the admin site. To make individual settings for the
two sites edit 'settings/siteaccess/user/site.ini.append' and 'settings/siteaccess/admin/site.ini.append'.
The site.ini.append will override settings from 'settings/site.ini'
URI
We will stick with the www.mybookstore.com example, but now we will use URI to recognize the different sites.
http://www.mybookstore.com/index.php/admin will be our URL to the admin site and http://www.mybookstore/index.php
the URL to our user site. Here we only need the 'www.mybookstore.com' domain to point to our web server.
In settings/site.ini set these settings:
file: settings/site.ini
[SiteSettings]
DefaultAccess=user
[SiteAccessSettings]
MatchOrder=uri
With the DefaultAccess variable we told eZ publish to use the 'user' site if it is unable to match a site.
Now eZ publish will take the last part of the entered URL and map it do a directory under settings/siteaccess/.
If we now enter http://www.mybookstore.com/index.php/admin, eZ publish will look for a directory called 'admin'.
Using URI is useful when you want multiple sites but don't have a domain for each site or don't have the ability
to setup virtualhosts for each site. This is the configuration the eZ publish Windows installer use.
Port
By setting up site access to use ports we can let eZ publish distinguish different sites by mapping a port to a site.
In this example we will use port 80 for the user site and port 81 for the admin site. When the configuration is done
we should be able to access the user site on http://www.mybookstore.com:80 and the admin site
with http://www.mybookstore.com:81. The settings in settings/site.ini required for this setup is shown under.
file: settings/site.ini
[SiteAccessSettings]
MatchOrder=port
[PortAccessSettings]
80=user
81=admin
|