torsdag den 31. januar 2008

Installing ZMySQLDA in Zope using buildout on Ubuntu and perhaps Debian in general

Another note to future self. This is how I did it.

libmysql++-dev

To make Zope work with Mysql I needed to compile the database adapter. For this I needed the mysql dev libraries. On Ubuntu that is done like this:
aptitude install libmysql++-dev

MySQL-Python


For ZMySQLDA to work I needed the plain Python MySQL-Python library installed and compiled.

Luckily the MySQL-Python package is distributed as an egg, so it can just be added to buildout.cfg
eggs =
... other packages
MySQL-Python
Buildout will then download, compile and install the package automatically.


ZMySQLDA

ZMySQLDA is old. Latest release 2.0.8 is from 2001. But that is just because it is stable. No worry.

When I tried to install it with by adding it in the buildout.cfg:
urls = http://www.zope.org/Members/adustman/Products/ZMySQLDA/2.0.8/ZMySQLDA-2.0.8.tar.gz
It made a small tarbomb and put itself inside a directory structure like:
lib/python/Products/ZMySQLDA
And Zope was not be able to find it.

Buildout to the rescue again. Radim Novotny has made a buildout recipe for doing it right:
http://pypi.python.org/pypi/cns.recipe.zmysqlda/
So all I needed was a few additions to the buildout.cfg

[buildout]
parts =
...
zmysqlda
and
[zmysqlda]
recipe = cns.recipe.zmysqlda
target = ${buildout:directory}/products

And then I was good to go.

onsdag den 30. januar 2008

Installing Python, Zope and Plone on Ubuntu 7.10 - Gutsy Gibbon

Last time I installed plone on a Ubuntu system, I wrote a log of what I did. It might be that I am getting old, but I cannot seem to remember how I do it from time to time. So this is as much a note to future me as a help to others.

It is a newer version of this article on my main site.

http://www.mxm.dk/papers/installing-plone

With a little luck you should be able to run it as a script on your own server, or at least copy/paste the lines into your terminal, and the see where it fails.

####################################
# System installs, libraries etc.

# Installing python and plone on ubuntu server 7.10 Gutsy Gibbon
# much of it can probably be used on any debian system.

sudo bash
# as root: install system packages and libraries for compiling python
aptitude install gcc g++ make

# readline is needed for an interactive python prompt
aptitude install libreadline5 libreadline5-dev

# zlib is needed for zope & PIL
aptitude install zlib1g zlib1g-dev

# libjpeg is neded for PIL
aptitude install libjpeg62 libjpeg62-dev

# libssl is needed by buildout for downloading with the https protocol
aptitude install libssl0.9.8 libssl-dev

# create a user called zope.
adduser zope



####################################
# zope, plone specific install

# Do the rest as this user
su zope
# from the users home dir /home/zope
cd ~
# create the directory structure
mkdir downloads
mkdir pythons
mkdir instances

# download and install python in the zope users home dirs pythons directory
cd ~/downloads
wget http://www.python.org/ftp/python/2.4.4/Python-2.4.4.tgz
tar xzf Python-2.4.4.tgz
cd Python-2.4.4
./configure --prefix=/home/zope/pythons/python-2.4.4
make
make altinstall

# make a symbolic link for this python. This is optional. But you avoid having
# to type "python2.4" instead of "python"
ln -s /home/zope/pythons/python-2.4.4/bin/python2.4 /home/zope/pythons/python-2.4.4/bin/python
# make this the default python to use by pushing it to the front of the path with this command
PATH=/home/zope/pythons/python-2.4.4/bin:$PATH
# you can add the command to the zope users ~/.bashrc
# to automatically use that python at login. I normally do this.

# download and install PIL
cd ~/downloads
wget http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz
tar xfz Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
python setup.py build
python setup.py install

# download and install easy install
cd ~/downloads
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py

# create a default buildout config file. This way your eggs and downloads will
# automatically end up in the same dir.
mkdir ~/.buildout
vi ~/.buildout/default.cfg

# insert this text (without the "## ") and save
## [buildout]
## executable = /home/zope/pythons/python-2.4.4/bin/python2.4
## eggs-directory = /home/zope/.buildout/eggs
## download-directory = /home/zope/.buildout/downloads

# then install ZopeSkel with easy install
easy_install -U ZopeSkel

# you can see what buildouts can be created with this command
paster create --list-templates

# as I write this, the list looks like this.
#Available templates:
# archetype: A Plone project that uses Archetypes
# basic_namespace: A project with a namespace package
# basic_package: A basic setuptools-enabled package
# basic_zope: A Zope project
# nested_namespace: A project with two nested namespaces.
# paste_deploy: A web application deployed through paste.deploy
# plone: A Plone project
# plone2.5_buildout: A buildout for Plone 2.5 projects
# plone2.5_theme: A Theme for Plone 2.5
# plone2_theme: A Theme Product for Plone 2.1 & Plone 2.5
# plone3_buildout: A buildout for Plone 3 projects
# plone3_portlet: A Plone 3 portlet
# plone3_theme: A Theme for Plone 3.0
# plone_app: A Plone App project
# plone_hosting: Plone hosting: buildout with ZEO and any Plone version
# recipe: A recipe project for zc.buildout

# so to create a plone 3 server you write

cd ~/instances
paster create -t plone3_buildout p3test

# It asks a few questions. If you are in doubt just press enter for default values.
# now run the bootstrap script

cd p3test
python bootstrap.py

# at this point you should check out builout documentation for your options,
# if you want to run anything but a plane plone site.
# you can edit you buildout.cfg file in p3test. There is a good intro at:
# http://plone.org/documentation/tutorial/buildout/understanding-buildout.cfg

# now let buildout install and compile Plone. Zope will be compiled automatically.

./bin/buildout -v

# then start up and test the site with
./bin/instance fg

Good luck!