Wednesday, July 16, 2008

Lighttpd 1.4.19 compiling (Debian etch)

Following explains briefly how I managed to compile and run Lighttpd.

Remember that this doesn't include init.d scripts and such, and is not great idea for production servers.

Using Debian repository installation of Lighttpd is advised, seek the older article of installing Django, I have exaplained it there.

# Dependencies:
sudo apt-get install libpcre3
sudo apt-get install libpcre3-dev
sudo apt-get install zlib1g
sudo apt-get install zlib1g-dev

# Compilation:
cd /usr/src/
sudo wget
sudo tar -xvzf lighttpd-1.4.19.tar.gz
cd lighttpd-1.4.19
sudo ./configure
sudo make
sudo make install

ls -la /usr/local/sbin/ # should contain lighttpd (and lighttpd-angel)
ls -la /usr/local/lib/ # should contain whole bunch of mod_... files

# now since this is bare ass installation,
# we need to make init scripts and such ourselves
sudo adduser lighttpd

sudo apt-get install authbind
cd /etc/authbind/byport/
sudo touch 80
sudo chown lighttpd:lighttpd 80
sudo chmod 775 80

sudo mkdir /etc/lighttpd
sudo chown lighttpd:lighttpd /etc/lighttpd/
sudo su lighttpd

mkdir /home/lighttpd/public_html
pico /home/lighttpd/public_html/index.html
<html><body>Congrats I'm running!</body><html>
# Exit the pico

pico /etc/lighttpd/lighttpd.conf
server.document-root = "/home/lighttpd/public_html"
server.port = 80
index-file.names = ( "index.html", "index.htm" )
include_shell "/etc/lighttpd/"
# Exit the pico

pico /etc/lighttpd/
#!/usr/bin/perl -w
use strict;
open MIMETYPES, "/etc/mime.types" or exit;
print "mimetype.assign = (\n";
my %extensions;
while() {
next if /^\w*$/;
if(/^([a-z0-9\/+-.]+)\s+((?:[a-z0-9.+-]+[ ]?)+)$/) {
foreach(split / /, $2) {
# mime.types can have same extension for different
# mime types
next if $extensions{$_};
$extensions{$_} = 1;
print "\".$_\" => \"$1\",\n";
print ")\n";
# Exit the pico


# Runs the lighttpd for test ^C to exit
authbind /usr/local/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -D

exit # exits the "sudo su lighttpd"

Tuesday, July 15, 2008

Installation of MySQL server, MySQLdb, Flup, Lighttpd and Django (Debian etch)

Note: I have not tested it as is, I was writing this afterwards from memory, so beware of the errors.

Setting up debian

# logged in as root:
apt-get install sudo
adduser joe
sudoedit /etc/sudoers
joe ALL=(ALL) ALL # added this line

# Following is done in my own user (joe):
sudo apt-get upgrade
sudo dpkg-reconfigure locales
sudo tzselect
sudo apt-get install build-essential

Now to the installing Django and others...

# Python 2.5
sudo apt-get install python2.5
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python /usr/bin/python2.5

Python 2.5 (release25-maint, Dec 9 2006, 14:35:53)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

# Storing downloaded/compiled python-modules:
sudo mkdir /usr/src/python-modules

# MySQL server:
sudo apt-get install mysql-server

# MySQLdb:
# Dependencies:
sudo apt-get install libmysqlclient15-dev
sudo apt-get install python2.5-dev

cd /usr/src/python-modules/
sudo wget
sudo tar -xvzf MySQL-python-1.2.2.tar.gz
cd MySQL-python-1.2.2
python build
sudo python install
cd /usr/src/python-modules/

>>> import MySQLdb

# Flup (for the fastcgi):
cd /usr/src/python-modules/
svn co flup-svn
cd flup-svn
sudo python install
cd /usr/src/python-modules/

>>> import flup

# Lighttpd (1.4.19) installation using Debian unstable repository:
# TODO: Coming...

# NOTE: My installation method of Django allows to use both, svn and release
# Django as far as you always run the wanted django using env PYTHONPATH...
# Django release installation:
cd /usr/src/python-modules/
sudo wget # this one downloads Django-0.96.2.tar.gz
sudo tar -xvzf Django-0.96.2.tar.gz

env PYTHONPATH=$PYTHONPATH:/usr/src/python-modules/Django-0.96.2 python
>>> import django

# Django svn installation:
cd /usr/src/python-modules/
sudo svn co Django-svn

env PYTHONPATH=$PYTHONPATH:/usr/src/python-modules/Django-svn python
>>> import django

# Django new project and fastcgi server:
sudo mkdir /var/www-domains/

sudo adduser examplecom
sudo mkdir /var/www-domains/
sudo chown examplecom:examplecom /var/www/
sudo chmod +s /var/www/

sudo su examplecom
cd /var/www/
mkdir public
mkdir public_media
mkdir fastcgi-servers
mkdir django-projects

# TODO: More to come...