Tuesday, April 14, 2009

Setting up Django on a vps

It´s not often that I have really nice experiences with linux. But I have to say, installing django on a vps has really been a pleasure, no compatability problems and quick to do.

My choice of hosting was a openvz basic vps from a2hosting.com. I chose the centos 5 afull linux distribution, because I had a conflict with the centos 5 lamp version one when I tried yum update.

You have to install a few thing on it, but if you follow the tutorial for setting up the server here:

http://www.rayheffer.com/linux%20web%20server.shtml


and install mysql yourself (if you choose the afull version)
yum install mysql mysql-server
/sbin/chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
Then you get a nice empty vps to play with ready for your aps! And no control panel like plesk or cpanel that makes it confusing on how to set up vhosts, just go ahead with the normal vhosts on apache.

The one real gotcha that happened to me is that mysqld confilcts with yum for some reason and yum complains about not being able to start a new thread. There is a work around about turning off the yum plugin that allows the nearest host lookup. Or, if it´s an option you can just stop mysqld for a moment.

The error I got with yum was:


File "/usr/lib/python2.4/threading.py", line 416, in start
_start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

and the fix was to this:

cd /etc/yum
# ls
pluginconf.d yum-daily.yum

# cd pluginconf.d/
# ls
downloadonly.conf fastestmirror.conf

# mv fastestmirror.conf fastestmirror.conf.unused

After a bit more experience, I suspected as well that I needed to optimize mysql memory usage a bit and followed some ideas on this blog post for mysql:
http://www.satchmoproject.com/blog/2007/sep/25/optimizing-django-vps-setup/

0 comments: