Saturday, March 28, 2009

Setting up a Django Server for Dev/Hosting I

As previously stated, I'm way out of touch and struggling to do things that most consider obvious. But the journey's the fun part anyway (I keep telling myself). These "Setting up a Django Server for Dev/Hosting" posts are going to be answers to questions I have about getting the environment ready for dev and hosting. (Since we're 4 months from release).

Assumption #1. CentOS is the server OS
Going to release on CentOS 5.2 Why? It's free and considered "server" and very stable and well tested. I dont want to take chances with OS issues, so I love "Mr. Stability". Problem is, I found that an idiot like me can take down the whole server where it requires a complete re-install within 10 minutes...

Assumption #2. I want the terminal Python release for my Django Projects
Why do I want terminal releases? In my 15 years of development experience, terminal releases are usually rock solid (at least compared to the other releases). So I'm going with Python 2.6.1 for my websites. But... CentOS 5.2 comes with Python 2.4...

Answer/Lesson. Well just install 2.6.1 on CentOS 5!
Duh! That was easy and probably obvious. But... "Don't do it". Well, "Do it, but be really careful". So in updating CentOS 5, it's very simple to just download the Python 2.6 source and compile it as the instructions say and then install it as the system python binary. The problem is when I rebooted the system wouldn't get past the GRUB loader. I think it never even shut down correctly as it failed to run some python scripts with the 2.6 binary.

UGH! I had setup a lot of stuff (Eclipse, PyDEV, etc...) and now I had to reinstall the OS from scratch (I tried to just install on top but this failed permanently too). After I got my blood pressure back down from it's peak, I tried again - downloaded python 2.6, compiled it, and installed it. BUT - this time I was careful to change the link to python in /usr/bin to python2.4 instead of python2.6 (found in usr/local/bin). So the easiest way to verify this is to run python as root and as your user and make sure that it always runs as version 2.4.3. I then ran python2.6 and made sure it always ran as version 2.6.1. Seemed ok so I rebooted.... Everything came back fine this time. WHEW!

Lessons Learned.
  1. Don't replace system script libraries with new versions without REALLY knowing what you're doing. (I even saw some websites warn me, I just didn't see how it would break anything!)
  2. Verify your installs work properly after you've done them. Check things as root and as a user (originally I had different behaviors in the two cases).
  3. Linux is incredibly easy to break badly. Tread carefully, change as little as possible.




No comments:

Post a Comment