So most of the day yesterday I spent a lot of time doing a lot of really boring work. But it needed to be done. Essentially, I had to take all our server code (ie, the stuff that manages the database that we use to store data about avatar location and appearance) and install it on the server machine that we will be using for the installation. Unfortunately that server is now several years old and so this process was quite laborious and riddled with hoops that needed to be jumped through.
Installing Django on a Red Hat Linux box from about 2005:
- Fortunately, MySQL came pre-installed, but upon trying to run the server daemon I was getting a
“STOPPING server from pid file” error, with the log file saying “Table ‘mysql.host’ doesn’t exist”. This was fixed easily enough with themysql_install_dbcommand (as well as some miscellaneous other permissions and config changes). - Next step was installing MySQLdb so that Python could communicate with MySQL. Had to try this install a couple times due to an “ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory”. Finally after some LD_LIBRARY_PATH tweaks and installing from source, I thought the install worked, but then I got an “undefined symbol: uncompress” error. Reading the MySQLdb README file, I realized I needed to install zlib. But zlib came pre-installed on the box! And here is where things got tricky …
I came across this lame build error in older MySQL versions. Apparently the _r version of libmysqlclient.so wasn’t properly linked against zlib. So even though zlib was installed, the library file that MySQLdb was referencing wasn’t linked. I guess “_r” stands for “re-entrant”? Because if I built MySQLdb with the threadsafe option set to False in site.cfg, MySQLdb linked against a different version of libmysqlclient, which apparently links against zlib properly. I heart the ldd command. anyway, that finally worked.
- ok, now I installed DJango which went smoothly. And installed my Django code. But trying to run Django syncdb, I got “Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)”. Now this was a massive pain to fix, and this mailing list thread was pretty helpful here. I edited /etc/my.cnf and set all my encodings and collations to utf8 and utf8_unicode_ci (see this and this from the MySQL reference — note this is the 4.1 documentation). After dropping and re-adding my database a few times, and running syncdb a few times, I was still getting “unknown encoding: latin1_swedish_ci” errors. argh!
ok, found this helpful post which talks about this problem with MySQLdb. I’m still not sure why
db.character_set_name()wasn’t returning “utf8″, and I’m not sure if it is a MySQL config thing that I could fix somehow or something else, but I just unzipped the MySQLdb egg file and hacked the source to hardcode my encoding to be “utf8″ and everything worked. This is a hideous kludge that no one should be proud of, but at least it should keep everything running for now.
ok! tedious work but worth it as now we have a full test of the system up and running here at Nabi.