Installing Django with Satchmo on Debian Etch
Installing Django with Satchmo on Debian Etch
This is how I got Django and Satchmo set up on my Debian Etch box with Apache2, MySQL, mod_python and Memcached.
The machine I started with had Debian Etch installed as well as Apache2 and MySQL.
Note: I am assuming you are working as root on your machine. If not you will
have to do sudo
in front of all of the following commands.
Make sure that your /etc/apt/sources.list
is up to date and then update your
repositories and installed packages. I usually get my sources from
here…
$ apt-get update
$ apt-get upgrade
Since it is a new server and my locales
are not right, I reconfigure them.
$ dpkg-reconfigure locales
Install GCC, G++ and Make so you can compile code
$ apt-get install gcc g++ make
Install the newest version of Python (2.5.2 as of this writing).
$ cd ~/
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
$ tar -zxvf Python*
$ cd Python*
$ ./configure --enable-shared
$ make
$ make install
Set up a config file for python.
$ vi /etc/ld.so.conf.d/python2.5.conf
Put the following in it (path to the libpython2.5.so.1.0
):
/usr/local/lib
Make the settings take effect.
$ ldconfig
Make this version of python the default version.
$ vi /usr/share/python/debian_defaults
Change the contents of this file to:
[DEFAULT]
# the default python version
default-version = python2.5
# all supported python versions
supported-versions = python2.4, python2.5
# formerly supported python versions
old-versions = python2.3
# unsupported versions, including older versions
unsupported-versions = python2.3
Create a symlink to point to the new version of python.
$ rm /usr/bin/python
$ ln -s /usr/local/bin/python2.5 /usr/bin/python
Set up MySQL (MySQL-python) to work with Python.
$ apt-get install libmysqlclient15-dev
$ cd ~/
$ wget http://voxel.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
$ tar -zxvf MySQL-python*
$ cd MySQL-python*
$ python setup.py build
$ python setup.py install
Installing mod_python
for Apache2 in Debian Etch is a total PITA. Here are
the steps I took to get it installed…
$ apt-get install apache2-prefork-dev
$ cd ~/
$ wget http://ftp.wayne.edu/apache/httpd/modpython/mod_python-3.3.1.tgz
$ tar -zxvf mod_python*
$ cd mod_python*
$ ./configure --with-apxs=/usr/bin/apxs2 --with-python=/usr/local/bin/python2.5
$ make
$ make install
Install the newest version of Django (1.0 as of this writing).
$ cd ~/
$ wget http://www.djangoproject.com/download/1.0/tarball/
$ tar -zxvf Django*
$ cd Django*
$ python setup.py install
On my machine, this installed Django into /usr/local/lib/python2.5/site-packages
.
Set up your Django project.
$ cd ~/
$ django-admin.py startproject mysite
Set up your MySQL database. Since my machine is a fresh install I need to set up a password first.
$ mysqladmin -u root password PASSWORD
$ mysql -u root -p
> CREATE DATABASE mysite CHARACTER SET utf8;
Set up your project settings in settings.py
.
- Enter up your admin information.
- Enter up your database connection info.
- Change your timezone and language settings if needed.
Sync your installed apps and your database.
$ cd ~/mysite
$ python manage.py syncdb
Check this Django
documentation page for how to set up mod_python
.
You need to set up a directory where mod_python can extract eggs and you need to set up the permissions so it can write to it (don’t use 777 as in my example in production).
$ cd ~/mysite
$ mkdir cache_directory
$ chmod 777 cache_directory
$ chown www-data cache_directory
Now set up a config file to import those settings.
$ vi cache_file.py
Put the following lines in that file:
import os
os.environ['PYTHON_EGG_CACHE'] = '/absolute/path/to/cache_directory'
Configure mod_python
to work with Apache2.
$ vi /etc/apache2/httpd.conf
Add the following lines to that file:
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
PythonInterpreter mysite
PythonImport /absolute/path/to/cache_file.py mysite
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/path/to/project'] + sys.path"
</Location>
Restart Apache.
$ /etc/init.d/apache2 restart
At this point you should have a working Django install and you should be able to start adding apps…
Now lets get our install ready for Satchmo. We will need to install a bunch of things, as laid out on this page…
Install Python Imaging Library…
$ cd ~/
$ wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
$ tar -zxvf Imaging*
$ cd Imaging*
$ python setup.py install
Install Python cryptography toolkit…
$ cd ~/
$ wget http://www.amk.ca/files/python/crypto/pycrypto-2.0.1.tar.gz
$ tar -zxvf pycrypto*
$ cd pycrypto*
$ python setup.py install
Install ReportLab…
$ apt-get install libfreetype6 libfreetype6-dev
$ cd ~/
$ wget http://www.reportlab.org/ftp/ReportLab_2_2.tgz
$ tar -zxvf ReportLab*
$ cd ReportLab*
$ python setup.py install
Install Tiny RML2PDF…
$ cd ~/
$ wget http://tinyforge.org/frs/download.php/1/trml2pdf.tar.gz
$ tar -zxvf trml2pdf*
$ cd trml2pdf*
$ mv trml2pdf /usr/local/lib/python2.5/site-packages
$ python
>>> import trml2pdf
Install django-comment-utils…
$ cd ~/
$ wget http://django-comment-utils.googlecode.com/files/comment_utils-0.3p1.tar.gz
$ tar -zxvf comment_utils*
$ cd comment_utils*
$ python setup.py install
Install Django Registration…
$ cd ~/
$ wget http://django-registration.googlecode.com/files/django-registration-0.6.tar.gz
$ tar -zxvf django-registration*
$ cd django-registration*
$ python setup.py install
Install Memcached for caching (including its dependencies and python bindings)…
$ cd ~/
$ wget http://www.monkey.org/~provos/libevent-1.4.8-stable.tar.gz
$ tar -zxvf libevent*
$ cd libevent*
$ ./configure
$ make
$ make install
# Create a link so the memcached knows where to find the library...
$ ln -s /usr/local/lib/libevent-1.4.so.2 /lib/libevent-1.4.so.2
$ cd ~/
$ wget http://danga.com/memcached/dist/memcached-1.2.6.tar.gz
$ tar -zxvf memcached*
$ cd memcached*
$ ./configure
$ make
$ make install
$ cd ~/
$ wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-latest.tar.gz
$ tar -zxvf python-memcached*
$ cd python-memcached*
$ python setup.py install
# Start the memcached daemon...
$ memcached -d -u www-data -m 32 127.0.0.1 -p 11211
# Configure your django project to use memcached...
$ cd ~/mysite
$ vi settings.py
In that file add:
CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
Install PyYaml…
$ cd ~/
$ wget http://pyyaml.org/download/pyyaml/PyYAML-3.05.tar.gz
$ tar -zxvf PyYAML*
$ cd PyYAML*
$ python setup.py install
Install Docutils…
$ cd ~/
$ wget http://docutils.sf.net/docutils-snapshot.tgz
$ tar -zxvf docutils-snapshot*
$ cd docutils*
$ python setup.py install
Install Django Threaded Multihost…
$ cd ~/
$ wget http://gosatchmo.com/static/files/threaded-multihost-1.1-source.tgz
$ tar -zxvf threaded-multihost*
$ cd django-threaded-multihost
$ python setup.py install
Now you have all the prerequisites installed for Satchmo…
Its time to install Satchmo…
$ apt-get install subversion
$ cd ~/
$ svn co svn://satchmoproject.com/satchmo/trunk
$ cd trunk
$ python setup.py install
Check it…
$ cd ~/
$ python
>>> import django
>>> import satchmo
If they both import fine, then you are all set… Enjoy…
To finish configuring your store check this page…
I like to have a clean machine, so I remove all of the source files after installs…
$ cd ~/
$ rm -rf Python* MySQL-python* mod_python* Django* Imaging* pycrypto* ReportLab* trml2pdf* comment_utils* django-registration* libevent* memcached* python-memcached* PyYAML* docutils* trunk* django-threaded-multihost threaded-multihost*