Zope Install Instructions
Here are some notes I did a while ago for best practice setup of Zope on Linux. If I did it again it would walk you through a ZEO setup, but maybe when I have some time...
These notes are becoming a bit out of date now, as Zope 2.7 will make best-practise installations much easier. The Apache part will remain relevant for the forseeable future, though.
I believe that building python with large file support should no longer need the
magic outlined here.
Pick your versions
At the time of writing, Zope 2.6.2 is the latest stable Zope version. You should always make sure you have the latest release of Zope. The only exception is for major point releases (e.g. 2.7.0, 2.8.0) which have historically been less reliable than they should be. Most people like to wait until 2.x.1 until they upgrade a major version.
Also at the time of writing Python 2.1.3 is the "official" python to use with Zope 2.6.x. However, unless you have a very good reason (hint: you don't), python 2.2.3 is the one to go for. It is known to work and has loads of bug fixes and performance improvements over 2.1.3.
Install python from source
Python should be installed with large file support (LFS). In python 2.1.3, the autoconf doesn't handle the case where int and long are both 32 bit, so you have to define various flags etc yourself.
In python 2.2.3, LFS will be configured correctly without you having to do anything. But you should probably check, just to make sure (see below).
References:
Python docs Thread about compiling LFS
Here's how I do it:
# ./configure --without-pymalloc --with-threads
Then add the following lines to the top of config.h:
#define LARGEFILE_SOURCE 1 #define _FILE_OFFSET_BITS 64
Then make && make install
You can test largefile support is there by running the test_largefile.py script from the tests/ directory in your python installation:
python /usr/local/pythonX/lib/pythonX/tests/test_largefile.py
Install Zope
Unpack the source distribution:
$ cd /usr/local $ tar zxvf Zope-X.tgz $ cd Zope-X
Make a link from Zope to Zope-X:
$ ln -s /usr/local/Zope-X /usr/local/Zope
Link in the python libraries:
$ ln -s /usr/local/lib/python2.2/ lib/.
And also make a symlink to the python2.1 binary:
$ mkdir bin $ ln -s /usr/local/bin/python2.2 bin/python
Finally add a link to the ZServer module inside the Zope path - this is needed to make the unit testrunner work:
$ ln -s ZServer/ lib/python/.
Now we can build Zope:
$ /usr/local/Zope/bin/python wo_pcgi.py
Add an unpriviledged user to run zope as, and set the umask to something sensible:
# useradd zope # echo "umask 077" >> /home/zope/.bash_profile
Note that you can also run zope as root (see doc/SETUID.txt), but
there's no need to do this if you are not getting Zope to listen on
port 8080. When we start zope, we will do so as the zope user, e.g.
by running su zope -c ./start or somesuch.
Make sure Zope runs as that user, by editing the start script
to include the argument -u zope
Now we ensure only the zope user can write to the var directory:
# chown -R zope:zope var/ # chmod -R 700 var/
The start script needs a bit of tweaking (a) to make it work with
INSTANCE_HOME, and (b) to make it run Zope as the zope user, and
(c) to make it only bind to localhost (we are going to proxy requests
from the real world using Apache):
#! /bin/sh
reldir=`dirname $0`
INSTANCE_HOME=`cd $reldir; pwd`
export INSTANCE_HOME
PYTHONHOME=/usr/local/Zope
export PYTHONHOME
exec /usr/local/Zope/bin/python \
$PYTHONHOME/z2.py \
-w 8080 -f - -m - -u zope -a localhost "$@"
And the stop script can be modified to work anywhere:
#! /bin/sh reldir=`dirname $0` pidhome=`cd $reldir/var; pwd` kill `cat $pidhome/Z2.pid`
Now we set up an INSTANCE_HOME, which allows us to run multiple
Zopes with different pythons, and also separates the stuff we need
to back up from the rest of Zope. We keep this instance vanilla,
and copy it every time we need to set up a new instance:
# mkdir -p /var/zope-sites/Template && cd /var/zope-sites/Template
# cp -r /usr/local/Zope/var/ \
/usr/local/Zope/import/ \
/usr/local/Zope/Extensions/ \
/usr/local/Zope/start \
/usr/local/Zope/stop .
# mkdir Products
# chown -R zope:zope var/
Finally, I add three more directories: one for Apache to log to per virtual host, one for serving up static content such as images, and one for misc things like SSL keys etc:
# mkdir logs && mkdir -p static/images && mkdir conf # chown apache logs
Now for Apache.
Assuming you have it already installed from RPM or whatever...
I like to use the Apache Include directory, which includes the configurations contained in all files in the specified directory. This keeps maintainance easy. Each Virtual Host has its own configuration file, named for the domain name of that host. One problem is that if your individual conf files have any errors, apache does a bad job at reporting them, and fails quietly.
I also like to keep the configuration in the same place as the zope instances - it makes backing up easy.
Let's say you've set up a site in Zope at /MySites/FooBar. Make sure you've placed a VirtualHostMonster in the root of your Zope:
# mkdir /var/zope-sites/apacheconf
now put the following into the file foobar.net, in the apacheconf directory:
<VirtualHost [your.own.ip.address]>
ServerName foobar.net
ServerAlias www.foobar.net
ServerAdmin admin
DocumentRoot /var/zope-sites/FooBar/static
CustomLog /var/zope-sites/FooBar/logs/access_log combined
RewriteEngine on
RewriteRule ^/images/ - [L]
RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/foobar.net:80/MySites/FooBar/VirtualHostRoot/$1 [P]
</VirtualHost>
<VirtualHost [your.own.ip.address]>
ServerName manage.foobar.net
ServerAdmin admin
RewriteEngine on
RewriteCond %{SERVER_PORT} !443
RewriteRule ^/(.*) https://manage.foobar.net/$1 [P]
</VirtualHost>
<VirtualHost [your.own.ip.address]:443>
ServerAdmin admin
DocumentRoot /var/zope-sites/FooBar/static
CustomLog /var/zope-sites/FooBar/logs/access_log combined
ServerName manage.foobar.net
RewriteEngine on
RewriteRule ^/images/ - [L]
RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/https/manage.foobar.net:443/MySites/FooBar/VirtualHostRoot/$1 [P]
SSLEngine on
SSLCertificateFile /var/zope-sites/FooBar/conf/ssl/server.pub
SSLCertificateKeyFile /var/zope-sites/FooBar/conf/ssl/server.key
SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
and finally, we need to tell Apache a couple of things. Edit the httpd.conf, which is probably at /etc/httpd/conf/httpd.conf:
1) Load the proxy and rewrite modules (usually just a case of uncommenting):
LoadModule proxy_module modules/libproxy.so LoadModule rewrite_module modules/mod_rewrite.so ... AddModule mod_proxy.c AddModule mod_rewrite.c
2) Add (or uncomment) the NameVirtualHost directive:
NameVirtualHost [your.own.ip.address]
3) Include any conf files in the directory specified (note trailing slash):
Include /var/zope-sites/apacheconf/
Other notes
ImportError: No module named zlib
If you get the above error when starting zope, it means python wasn't compiled with zlib support; this is probably because you don't have zlib (i.e. the C version) installed on your system, so autoconf skipped compiling the python module. Install zlib, then rerun configure and recompile python.