Here’s a guide to take a fresh Debian stable (Etch) install and turn it into a viable Lisp web development environment. (Including Emacs22, SBCL, Slime, Hunchentoot, Apache2 all working together from boot)

Please note that this guide assumes you’re using a fresh installation of Debian stable.

All the commands assume you are logged in as root on your soon-to-be web server.

Installation Steps

# Install Emacs 22
echo deb http://hype.sourceforge.jp/f etch backports >> /etc/apt/sources.list
wget http://hype.sourceforge.jp/A7F20B7E.gpg -O- | apt-key add -
apt-get update
apt-get install emacs22

# Install the other required packages
apt-get install darcs cvs subversion curl git-core cogito sbcl make gcc build-essential detachtty

# Grab clbuild
cd /usr/src
darcs get http://common-lisp.net/project/clbuild/clbuild
cd clbuild && chmod +x clbuild

# Install the different bits and bobs with clbuild
./clbuild update sbcl
./clbuild compile-implementation sbcl
echo cl-unicode get_darcs http://common-lisp.net/~loliveira/ediware/cl-unicode >> projects
echo metabang-bind get_darcs http://common-lisp.net/project/metabang-bind >> projects
echo stefil get_darcs http://common-lisp.net/project/stefil/darcs/stefil >> projects
echo cffi get_darcs http://common-lisp.net/project/cffi/darcs/cffi >> projects
./clbuild build cl-unicode cl-ppcre hunchentoot vecto cl-who slime metabang-bind iterate stefil babel cffi

# Make a Lisp image
./clbuild dumpcore --installed

# Setup Lisp to start on boot
cd /etc/init.d
wget http://www.kzar.co.uk/lisp-install/lisp-boot
chmod a+x lisp-boot
cd /etc/rc2.d
ln -s ../init.d/lisp-boot S98lispboot
mkdir /var/run/lisp

# Add the lisp user for Lisp to run as
adduser lisp-user
touch /var/log/detachtty.log
touch /var/log/lisp-app-dribble
chown lisp-user:lisp-user /var/log/detachtty.log
chown lisp-user:lisp-user -R /var/run/lisp
chown lisp-user:lisp-user /var/log/lisp-app-dribble

# Make it so Lisp will start the webserver and swank server each time
cd /usr/src/clbuild/
mkdir /var/lisp && cd /var/lisp
wget http://www.kzar.co.uk/lisp-install/server.lisp
mkdir images && cd images
wget http://www.lisperati.com/lisplogo_alien_128.png
chmod g+w -R /var/lisp
chown -R lisp-user:lisp-user /var/lisp

# Grab Apache2 and set it up with modlisp
apt-get install apache2 cl-modlisp libapache-mod-lisp apache2-threaded-dev
cd /etc/apache2/sites-available/
rm default && wget http://www.kzar.co.uk/lisp-install/default
cd /etc/apache2/mods-enabled
wget http://www.kzar.co.uk/lisp-install/lisp.load
wget http://www.kzar.co.uk/lisp-install/lisp.conf
cd /usr/lib/apache2/modules
wget http://www.kzar.co.uk/lisp-install/mod_lisp2.so

# Get rid of the old SBCL that comes with Debian (Thanks Todd)
apt-get remove sbcl
echo SBCL_HOME=/usr/src/clbuild/target/lib/sbcl >> /etc/profile
ln -s /usr/src/clbuild/target/bin/sbcl /usr/bin/sbcl
ln -s /usr/src/clbuild/target/lib/sbcl /usr/local/lib/sbcl
cd /usr/src/clbuild/target/lib/sbcl && rm -r site-system
ln -s /usr/lib/sbcl/* .

# Start it all running
/etc/init.d/apache2 restart
/etc/init.d/lisp-boot start

# Set up Emacs (Run as the user who will use Emacs)
cd ~ && wget http://www.kzar.co.uk/lisp-install/.emacs

Usage

  • Browse to http://SERVERNAME/lisp to view your website.
  • Type emacs /var/lisp/server.lisp to start editing the little example page.
  • Type M-x slime-connect RET RET in Emacs to connect to the running Lisp REPL

Notes

  • Add your user to the lisp-user group to edit the files
  • Make sure you have downloaded the .emacs for your user so slime-connect works properly

Leave a comment if you hit a problem and I’ll try and help - Dave.

Edit: Thanks to Todd for some good feedback, I have added some extra commands that help to get rid of the outdated version of SBCL which comes with Debian, while still making use of Debian’s cl package. (That’s the hope anyway, let me know if it worked for you / if there’s a better way to do that part)