Installing Mezzanine (Django based CMS) on Dreamhost via virtualenv

July 20th, 2011 § 3 comments § permalink

Here’s some notes for installing Mezzanine on Dreamhost using virtualenv. This can be useful for installing on any server where you don’t have permissions to install python packages normally. There’s also notes here for how to set up Passenger to serve your site via Apache.

In Dreamhost panel, setup site for use with Passenger & ssh

Ssh into your Dreamhost server

Setup a Python virtualenv so you can install your own Python packages. Check the virtualenv pypi page for the latest virtualenv version (currently 1.6.3).

wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.6.3.tar.gz
tar xzf virtualenv-1.6.3.tar.gz
python virtualenv-1.6.3/virtualenv.py $HOME/local
rm -rf virtualenv*
export PATH=$HOME/local/bin:$PATH

You probably want to add $HOME/local/bin to your path permanently. Add the export line to your ~/.bashrc file:

export PATH=$HOME/local/bin:$PATH

To make sure that you are using the virtualenv python, check that which python returns /home/youruser/local/bin/python and NOT /usr/bin/python.

Now you can install some Python packages

pip install --upgrade django mezzanine south paste

Create a mezzanine project

cd ~/site.com
# Name this project whatever you like.  I will use "mez"
mezzanine-project mez

Edit your settings in mez/local_settings.py. I will leave the sqlite database for testing. You could should probably create a mysql database for a real site though. Add these lines so Django knows where files are.

TIME_ZONE = 'America/Los_Angeles'
APP_URL = 'http://site.com'
## Note the leading and trailing slash here
#ADMIN_MEDIA_PREFIX = '/admin_media/'
#MEDIA_ROOT= '/home/youruser/site.com/mez/site_media/'
#MEDIA_URL = 'http://site.com/site_media'

Setup your site with Passenger by creating a ~/site.com/passenger_wsgi.py file with the following:

import sys,os
# Force Passenger to run our virtualenv python
INTERP = "/home/youruser/local/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
# Setup paths and environment variables
sys.path.append("/home/youruser/site.com")
sys.path.append("/home/youruser/site.com/mez")
os.environ['DJANGO_SETTINGS_MODULE'] = 'mez.settings'
# Set the application
import django.core.handlers.wsgi
from paste.exceptions.errormiddleware import ErrorMiddleware
application = django.core.handlers.wsgi.WSGIHandler()
# Use paste to display errors
application = ErrorMiddleware(application, debug=True)

Now setup the static files

ln -s ~/site.com/mez/site_media ~/site.com/public/site_media

Setup the database

cd ~/site.com/mez
python manage.py syncdb
# I think I initially had some errors running migrate, 
# but it worked the second time running migrate
python manage.py migrate

Restart the web server. Ordinarily you might do sudo /etc/init.d/apache2 restart. On Dreamhost you do this by touching tmp/restart.txt. (If the tmp directory doesn’t exist, mkdir ~/site.com/tmp)

touch ~/site.com/tmp/restart.txt

That should be it. Check to see if your site is up and running.

TODO’s: setup mysql, customize theme, etc

There’s alternative ways to handle the static files. The package django-staticfiles might be better? I haven’t tried it.

Ubuntu: Wacom Tablet Hotplugging

September 1st, 2008 § 4 comments § permalink

Update 11-04-2008: The release version of Ubuntu 8.10 Intrepid should work out of the box, so you don’t need to do any of this. However, only the stylus works. If linuxwacom comes out with an update to use the eraser and tablet buttons, you might need to manually install the linuxwacom driver, but right now, enjoy the “it just works” philosophy. :)

Ubuntu 8.10 “Intrepid Ibis” will use Xorg 7.4′s input hotplugging, allowing auto-detection of input devices (e.g. keyboards, mice, tablets) during an X session. (Previously, input devices were only detected at the startup of an X session.)

Note that there are still a number of bugs with hotplugging:

  • you must install the latest linuxwacom driver to get correct clicking
  • hotplugging will only recognize the stylus events (so no eraser or express buttons)
  • unplugging the tablet causes X to crash. Edit 9-20-08: There is a line in the linuxwacom source you need to edit to fix this (see step 4 of Manual Installation below). [linuxwacom post] Edit 11-04-08: Intrepid updated the linuxwacom driver that ships with Intrepid, so you don’t need to install the updated linuxwacom driver.

Installing LinuxWacom driver in Intrepid
(based off the Hardy linuxwacom install thread, here. Tested on Intrepid alpha 6 LiveCD)

Easy Method:

  1. Download my install_linuxwacom script
  2. Run the script
    chmod +x install_linuxwacom
    ./install_linuxwacom
  3. Enjoy!

Manual Installation Steps:

  1. Install required packages
    sudo apt-get update
    sudo apt-get install linux-headers-$(uname -r) build-essential x11proto-core-dev libxau-dev libxdmcp-dev x11proto-input-dev x11proto-kb-dev xtrans-dev libx11-dev x11proto-xext-dev libxext-dev libxi-dev linux-libc-dev libc6-dev libncurses5-dev xserver-xorg-dev tk-dev tcl-dev -y
  2. Download latest linuxwacom-dev package from linuxwacom (0.8.1-4 as of this writing)
    wget -nd http://prdownloads.sourceforge.net/linuxwacom/
    linuxwacom-0.8.1-4.tar.bz2
  3. Extract the source
    tar xjvf linuxwacom-0.8.1-4.tar.bz2
    cd linuxwacom-0.8.1-4
  4. To fix the X crashing when unplugging the tablet, edit line 381 of src/xdrv/wcmConfig.c replacing WCM_UNINIT_CALLED with WCM_XORG_XSERVER_1_4
    sed -i -e '381s/WCM_UNINIT_CALLED/WCM_XORG_XSERVER_1_4/' src/xdrv/wcmConfig.c
  5. Compile the driver
    ./configure --enable-wacom
    make
    sudo make install
  6. (Optional) You can test the kernel module before installing it. Plug in your tablet and see if it works correctly after executing these commands.
    sudo rmmod wacom
    sudo insmod src/2.6.26/wacom.ko

    If it doesn’t work, you can reload the original driver. (Or just reboot your computer)

    sudo rmmod wacom
    sudo modprobe wacom
  7. Install the kernel module (and backup the original). (Note: The 2.6.26 module works with Intrepid’s 2.6.27 kernel)
    cp /lib/modules/$(uname -r)/kernel/drivers/input/tablet/wacom.ko wacom.ko.$(uname -r)
    sudo cp src/2.6.26/wacom.ko /lib/modules/$(uname -r)/kernel/drivers/input/tablet/wacom.ko
  8. Reload the kernel module with the new version
    sudo rmmod wacom
    sudo modprobe wacom
  9. Enjoy!

» Read the rest of this entry «