The problem is that I want to run with Python 2.5 instead of 2.4, and I don’t want to use Apache 1.3. Unfortunately, that’s what comes stock with CPanel. So, I came up with a decent workaround that I haven’t seen documented anywhere else.
What I did was to set up Lighhtpd on one of the other IPs provided with the account, and I simply use my custom-compiled Python with that.
Step 1 – Add a new user
Login to your WHM instance and add a new user. Do not check the "IP" checkbox. We’ll be faking out CPanel on this one.
Step 2 – Plan your IP usage
2) Using WHM, go to IP Functions/Show IP Address Usage. The first IP should be the IP you used to get to WHM. I’ll call that your "Base IP". Pick any of the other unused IPs and note that for the next step. That’s where you’ll be binding Lighttpd.
Step 3 – Update your DNS
3a) Using WHM, go to DNS Functions/Edit DNS Zone. Note that you should have (at least) two. One is the domain for WHM and the other is your new domain. On Liquidweb, these are "host.yourdomain.com" and "yourdomain.com".
3b) Edit the DNS Zone for "yourdomain.com". Change "mail.yourdomain.com" from "CNAME" "yourdomain.com" to "CNAME" "host.yourdomain.com" (which you noted above). This will keep mail going to the IP for your WHM instance, which is where CPanel is expecting it to go.
3c) Continuing to edit the zone, change the "a" record for "yourdomain.com" from the base IP to the IP you’ll be using for Lighttpd.
3d) Save.
3e) Watch out for the gotcha. You have to be using your own VPS as the private nameserver for your domain or this won’t work. Your VPS provider should have instructions for how to tell your domain registrar to register a private nameserver. It is very common, but not as widely understood as I might hope. If you can’t do this, then you’ll just assign IPs using whatever nameserver you are already using, and CPanel wouldn’t be managing your IPs anyway.
Step 4 – Get root
4) You want to get yourself "sudo" rights as the new user you added in step 1. Do this by logging in as root (your WHM user) on the base IP. Then run "visudo". Find the line that says "root ALL=(ALL) ALL" and add a new line after it that says "YOURUSERNAME ALL=(ALL) ALL". Of course, substitute the user name from step 1 here.
Step 5 – Build and install Lighttpd
5a) Login to the base IP as the username from step 1.
5b) Get the lighttpd tarball, and build.
$ wget http://www.lighttpd.net/assets/2007/1/29/lighttpd-1.4.13.tar.gz
$ tar xzf lighttpd-1.4.13.tar.gz
$ cd lighttpd-1.4.13
$ ./configure --with-openssl && make
$ sudo make install
Step 6 – Disable Apache on the Lighttpd IP
6a) Right now, Apache is listening on all your IPs, you need to stop it being so greedy. Edit /etc/httpd/httpd.conf
$ sudo vi /etc/httpd/httpd.conf
Search for "Listen", then add "Listen 1.2.3.4:80" after that line. Substitute your "Base IP" for the 1.2.3.4.
6b) Restart Apache
$ sudo /etc/init.d/httpd restart
Step 7 – Bind Lighttpd to your chosen IP.
7) Edit /etc/lighttpd/lighttpd.conf and substituting your lighttpd IP for 1.2.3.4, add:server.bind = "1.2.3.4"
Step 8 – Add an init script for Lighttpd
8a) I couldn’t use the init script that came with the Lighttpd distribution, since it was written for LSB, and my VPS has a Red-hat based init system so I wrote my own, feel free to use or improve it. Put something like this at /etc/init.d/lighttpd
#! /bin/sh
# Copyright (c) Bruce Kroeze brucek@solidsitesolutions
# All rights reserved.
#
# Provides: lighttpd
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start lighttpd
LIGHTTPD_CONFIG=/etc/sysconfig/lighttpd
test -r $LIGHTTPD_CONFIG || exit 6
. $LIGHTTPD_CONFIG
test -x $LIGHTTPD_BIN || exit 5
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo "Could not find functions file, your system may be broken"
exit 1
fi
case "$1" in
start)
echo -n "Starting lighttpd"
daemon $LIGHTTPD_BIN -f $LIGHTTPD_CONF_PATH
echo
;;
stop)
echo -n "Shutting down lighttpd"
killproc lighttpd
echo
;;
try-restart)
$0 status >/dev/null && $0 restart
;;
restart)
$0 stop
$0 start
;;
force-reload|reload)
echo -n "Reload service LIGHTTPD"
killproc -INT lighttpd
$0 start
touch $LIGHTTPD_PID_FILE
;;
status)
echo -n "Checking for service LIGHTTPD: "
status lighttpd
;;
probe)
test /etc/lighttpd/lighttpd.conf -nt $LIGHTTPD_PID_FILE && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
exit
8b) That script requires a config file at /etc/sysconfig/lighttpd. Here’s mine:
LIGHTTPD_CONF_PATH=/etc/lighttpd/lighttpd.conf
LIGHTTPD_PID_FILE=/var/run/lighttpd.pid
LIGHTTPD_BIN=/usr/local/sbin/lighttpd
8c) Install the init script with "sudo chkconfig –add lighhtpd"
Done! Start testing.
[tags]lighhtpd,cpanel,liquidweb,vps[/tags]