Django on a Joyent Accelerator, the Hard Way

There have been a couple of excellent guides on installing Django on an Accelerator, and I thought I’d throw mine into the mix.

These are the notes I took during a recent install of Django on a pair of Joyent Accelerators.  While the other guides I found used the versions of Apache, PostgreSQL et al available in Blastwave or Pkgsrc, this project required newer versions than the package managers could provide.  This means, of course, that nearly everything had to be built from source.

All source was downloaded to /home/admin/src, and everything was installed to /opt/local.  In the following, Server1 refers to the Accelerator running Apache, and Server2 is the Accelerator running Mysql.

/home/ admin/.bashrc

Changed the default PATH on both machines to something like:

export PATH=/opt/local/bin:/opt/local/sbin:/usr/xpg4/bin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/ccs/bin:/opt/csw/bin:/opt/csw/sbin:/opt/csw/gnu:/opt/csw/gcc3/bin:/opt/local/apache2/sbin:/opt/local/apache2/bin:/opt/local/mysql/bin

Python 2.5 on Server1

Building:

cd Python-2.5.1/
gpatch -p1 < ../Python-2.5.1.patch
./configure --enable-shared --prefix=/opt/local
make
sudo make install

Python-2.5.1.patch

OpenSSL 0.9.7 on both servers

This may not have been needed on Server2, as I used the SSL bundled with MySQL.

Building:

cd openssl-0.9.7m/
./Configure --prefix=/opt/local --openssldir=/opt/local/openssl solaris-x86-gcc
gpatch -p1 < ../openssl-0.9.7m.patch
make
sudo make install

openssl-0.9.7m.patch

MySQL 5.0.45 (client and mysqld) on both servers

Building:

cd mysql-5.0.45/
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors
-fno-exceptions -fno-rtti" ./configure --prefix=/opt/local/mysql
--enable-assembler --with-yassl
make
sudo make install
sudo mysql_install_db # Only on Server2; probably not necessary for upgrades

Edited /etc/passwd on Server2:

mysql:x:100:100::/opt/local/mysql:/bin/false

SSL certs are in /opt/local/mysql/certs.

Config is at /etc/my.cnf; databases and logs are in /opt/local/mysql/var.

MySQLdb 1.2.2 on Server1

The “python setup.py build; rsync …” dance is to avoid installing eggs.

Building:

cd MySQL-python-1.2.2/
gpatch -p1 < ../MySQL-python-1.2.2.patch1
gpatch -p1 < ../MySQL-python-1.2.2.patch2
LD_LIBRARY_CONFIG=/opt/local/mysql/lib
LDFLAGS="-L/opt/local/lib" python setup.py build
sudo rsync -aP build/lib.solaris-2.11-i86pc-2.5/
/opt/local/lib/python2.5/site-packages/

MySQL-python-1.2.2.patch1 MySQL-python-1.2.2.patch2

Apache 2.2.6 on Server1

Pre-build, I moved the existing Blastwave Apache install out of the way, but didn’t pkgrm it:

sudo mv /opt/csw/apache /opt/csw/apache2.disabled

Building:

cd httpd-2.2.6/
./configure --prefix=/opt/local/apache2 --enable-mods-shared=all --enable-ssl
make
sudo make install

Config is in /opt/local/apache2/conf/httpd.conf

mod_python 3.3.1 on Server1

Building:

cd mod_python-3.3.1/
./configure --with-apxs=/opt/local/apache2/bin/apxs
--with-python=/opt/local/bin/python
make
sudo make install

libevent/memcached on Server1

Install via Blastwave:

pkg-get -i memcached

Libevent wouldn’t build from source cleanly; the solution may be here:

http://monkeymail.org/archives/libevent-users/2007-February/000481.html
http://monkeymail.org/archives/libevent-users/2007-June/000661.html
http://www.mail-archive.com/libevent-users@monkey.org/msg00658.html
http://lists.danga.com/pipermail/memcached/2007-July/004631.html
http://monkeymail.org/archives/libevent-users/2007-May/000615.html
http://monkeymail.org/archives/libevent-users/2007-May/000621.html
http://monkeymail.org/archives/libevent-users/2007-June/000678.html

python-memcached 1.40 on Server1

Building:

cd python-memcached-1.40/
python setup.py build
sudo cp build/lib/memcache.py /opt/local/lib/python2.5/site-packages/

Django on Server1

Added /opt/local/lib/python2.5/site-packages/tetriad.pth:

/home/code

Django svn checkout is at /home/code/django. /home/code/network/settings.py shows how I connected to MySQL:

DATABASE_ENGINE = 'mysql'
DATABASE_OPTIONS = {
   'read_default_file': '/etc/my.cnf',
}
DATABASE_NAME = 'installer'

Manifests and Methods (both servers)

Copies of the manifests are in /opt/local/svc/manifest.  Methods called by the manifests are in /opt/local/svc/method.

apache.xml memcached.xml mysql5.sh mysql5.xml