Adding Yum to CentOS 5

I use a lot of VPS and often times, they don’t actually have yum to make my life easier. So here is a quick HOWTO on installing yum on a CentOS box. This assumes that you have rpm and wget already installed. Note: This will only work on CentOS 5.2 while the mirror is still active.

Run the following code in a temporary directory to download all the RPMs.


for file in \
        elfutils-0.125-3.el5.i386.rpm \
        elfutils-libs-0.125-3.el5.i386.rpm \
        expat-1.95.8-8.2.1.i386.rpm \
        gmp-4.1.4-10.el5.i386.rpm \
        libxml2-2.6.26- \
        libxml2-python-2.6.26- \
        m2crypto-0.16-6.el5.2.i386.rpm \
        python-2.4.3-21.el5.i386.rpm \
        python-elementtree-1.2.6-5.i386.rpm \
        python-iniparse-0.2.3-4.el5.noarch.rpm \
        python-sqlite-1.1.7-1.2.1.i386.rpm \
        python-urlgrabber-3.1.0-2.noarch.rpm \
        readline-5.1-1.1.i386.rpm \
        rpm-4.4.2-48.el5.i386.rpm \
        rpm-libs-4.4.2-48.el5.i386.rpm \
        rpm-python-4.4.2-48.el5.i386.rpm \
        sqlite-3.3.6-2.i386.rpm \
        yum-3.2.8-9.el5.centos.1.noarch.rpm \
  do wget$file;

Once you have downloaded the necessary files. Install them all by typing:

# rpm -Uvh *.rpm

Then feel free to # yum -y update to bring your system up to date.

Posted in Misc. Tags: , , . 10 Comments »

Character Encoding

I recently ran into some character encoding issues and I wanted to share the fun. The default character encoding for MySQL on Gentoo is latin-1 or iso-8859-1. This wasn’t a problem until we recently started putting content straight from the DB through Java and onto the web. Java connects to the DB with a character encoding (typically UTF-8). Since UTF-8 is roughly a superset of iso-8859-1, it generally wasn’t a problem. Except when UTF-8 and UTF-16 characters were put into an iso-8859-1 database without translation.

What was essentially happening was that the data was being stored as iso-8859-1. The Java code was connecting to the DB in UTF-8 and pulling it into Java (which is usually UTF-16, but in this case was being handled as UTF-8). It was then being sent to the browser as URL encoded UTF-8 when in reality, it hadn’t even properly been put into UTF-8 character encoding. This then gave the web browser some funny yen symbols and question marks. This was not quite what we were aiming for.

The moral of this story is that it is necessary to realize the character encoding of the start point and end point of your data. It is crucial that the code points match up otherwise they could potentially make for an interesting screen given to the reader. All this could have been avoided with a simple: ALTER TABLE myTable MODIFY myColumn VARCHAR(255) CHARACTER SET utf8;.