Configure Apache Virtual Hosts and Zope using SiteRoot
Created by .
Last modified on 2003/08/05.
Introduction
Greetings!
This is my first time to create this How-To so please bear with me
I just would like to help others out in creating a "harmonious" interaction between Apache and Zope using VirtualHosts and SiteRoot.
Purpose
(1)
Suppose you have http://www.foo.com and you want to have cgi scripts while you serve the main website in Zope.
Scenario: http://www.foo.com would serve your Zope content. http://www.foo.com/cgi-bin/ would serve your CGI scripts.
(2)
This will also hide the port number and folder of the zope site.
Scenario: http://www.foo.com will be visible to your visitors. http://www.bar.com:8080/folder/ is the actual server and folder.
Assumptions
Apache is installed with DSO support.
Zope is already installed with the SiteAccess Product. (We need SiteRoot)
You know how to use mod_rewrite or create rewrite passes.
If not, please check this out first: Apache.org - mod_rewrite
Procedure
Step 1
Better setup the rewrite passes first BEFORE installing the SiteRoot.
We need Evan Simpson's SiteAccess product (SiteRoot). Fortunately it is already included in Zope version 2.3 and higher.
If you are using a Zope version I advice to upgrade it first. BUT a lot of people have advised not to upgrade yet to version 2.4 if you are not ready to do a lot of dependency upgrades. Oh well, you can't please them all. It just depends on you.
Open your httpd.conf or access.conf of Apache.
Look for these 4 lines to make sure mod_rewrite and mod_proxy has been installed:
In summary, RewriteEngine on - activates the rewriting (must be in every virtual host) RewriteLog - the location to put the rewrite logs (useful for debugging) RewriteLogLevel - determines the level of rewrite logging
RewriteRule ^/static_page_folder1/ - [L] - simply goes to /folder/subfolder/static_page_folder RewriteRule ^/static_page_folder2(.*) /static/page/folder/not/in/root/folder$1 [L] - same as above except to a different folder than the document root RewriteRule ^/(.*) http://www.bar.com:8080/zope_folder/$1 [P,L] - proxy passes to your zope site all requests not explicitly stated in the static pages rewrite rules.
Save your file and restart the Apache server.
Step 2
Now go to your management screen for zope.
Go inside the /zope_folder.
Warning: Be careful when adding SiteRoots. You might be locked out if configured wrongly.
Add a SiteRoot object.
Edit the contents.
Be careful in the Base part as an extra "/" can cause error in your site.
It will really depend on your links.
Step 3
Great! Now you have RewriteRules and a SiteRoot! Close your browser and Open a new one.
If you don't, authentication glitches may confuse you.
Step 4
Now try: http://www.foo.com.
You should now see your zope site that is located in http://www.bar.com:8080/zope_folder.
The links should now appear as http://www.foo.com/folder. /folder is the folder under /zope_folder.
If you get locked out
As Trevor Toenjes ([email protected]) has reminded me to add here:
If you get locked out, you can disable SiteRoot by adding _SUPPRESS_SITEROOT.
Example: http://www.foo.com/_SUPPRESS_SITEROOT/manage
Another option is to ftp into Zope and delete SiteRoot.
Good Luck!