Tag Archives: linux server

Upgrade to most recent ImageMagick version on CentOS 5.x

My favorite choice for running a Linux Server is CentOS, since it is based on the RedHat distribution you can rest assured you will get a top notch enterprise offering and stability. As with all things “enterprise” the priority is on stability and security and not on the latest code releases. This works 99% of the time, but sometimes you still need some update.

In the case of ImageMagick, CentOS comes with version 6.2.8, it was a bug that was fixed with PSD conversion and thus I needed to get the latest version installed. So, here are the steps to install ImageMagick 6.5.7 on CentOS 5.x. Mind you, that you will loose the internal patch upgrading from yum, but all you need to install to the next version is just to follow these steps again.

Uninstall current version
Uninstall the current version with:

yum erase ImageMagick*

This will uninstall ImageMagick 6.2.8 and if you have any other versions installed, like the devel one.

Install the needed dependencies
ImageMagick depends on a couple of additional libraries to convert to different formats. Let us just make sure, that they are all installed with:

yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel

Download and extract latest ImageMagick version
You can always get the latest ImageMagick version directly from their website. Code below will download and extract the file.

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xcvf ImageMagick.tar.gz
cd ImageMagick-6.5.7-5

Configure and make ImageMagick
With the below configure command we are configuring ImageMagick with the most needed options. Feel free to adjust it to your needs. As always issue a “–help” to see all the available options.

configure --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes

Wait until configure has finished. At the end you will see all the enable options. When you think all went well issue:
make

Now is a good time to make yourself some coffee or continue coding your next big killer application because make will take some time to finish. When it’s done, issue:
make install

That’s it! You are done. Wasn’t so bad, was it? Check with:

convert --version

That ImageMagick is properly installed and that you got the current version up and running. If all went well you should see something similar to this:
Version: ImageMagick 6.5.7-5 2009-11-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

How to create a virtual machine server image from a physical CentOS server

I run a couple of servers over at a server farm. All of those machines run VMWare ESX, so today I wanted to move my last physical server to a VMWare image. If you want to convert a physical Windows machine then your task is quite easy. Start up the freely available VMWare Converter and start converting your physical machine to a virtual one. But what about when you need to convert a Linux server?

Since I really did not want to setup a new CentOS machine with all the packages I need and copying stuff from the physical to the virtual I did the following steps successfully. Keep in mind that this is on CentOS 5.2. I am sure this works for other Linux distributions as well.

  1. Create a new virtual machine and install the bare minimum CentOS. I used the CentOS NetInstall Option. This takes about 20 minutes or so.
  2. Now, create a “backup” directory on the root level (“/”) of your disk and copy the following directories into this backup directory;
    1. boot
    2. etc/fstab
    3. lib/modules
  3. Then on your physical server create tarball with the following directories included;
    1. boot
    2. bin
    3. etc
    4. home
    5. lib
    6. sbin
    7. usr
    8. root
    9. var
    10. opt

    Include any other directories that you need or have created. You should not need to include the “tmp” or the “lost & found” one. It is important to keep the permissions settings and this use the following command to create the tar;
    tar czvfp physicalserver.tgz <directoriesabove>
    (be prepared to make yourself some coffee in the meantime)

  4. Copy the file physicalserver.tgz to your new virtual machine.
  5. On the virtual machine move the physicalserver.tgz to the root (“/”) folder and extract it. This will probably take some time and you should get to your second cup of coffee.
  6. Once it has finished extracting do not attempt to reboot the server. Doing so will most probably render your image unbootable!
  7. Copy all of the directories within the backup directory to their original position (the ones from step 2) and confirm to overwrite existing files.
  8. Once done, issue the command “grub”. You will then be in the grub editor. Type the following commands to create a new MBR;
    1. root (hd0,0) (this is hd<zero>,<zero>)
    2. setup (hd0) (this is hd>zero)
      You should see some confirmation messages. Type “quit” to exit the editor.
  9. Now reboot the server and pray :-)

I have done the above steps with 3 servers and it has always worked without problems. But there are some post-reboot steps that you should do as well. They are;

  1. Network Adapter. During the move above you will loose your network adapter. Thought CentOS still got everything setup and all working, you wont be able to reach outside of the virtual machine. Funny thing is that the Network Adapter in the Virtual Machines Configuration Settings also shows no problem. To make it work again you have to remove the Network Adapter in the Virtual Machine Settings and add one again.
  2. Install VMWare Tools. Since your physical server has no VMWare Tools installed this is a obvious step.
  3. Run security configuration. In my case, after step 1 and 2 above were done, I still could not get outside of my network. This was due to a mess up with the security settings of CentOS and most probably SELinux is running and prohibiting any network traffic. Simply run “system-config-security” in the shell and adjust your settings.
  4. Reboot your server.

With the above steps you should have a full copy of your physical server on your virtual machine environment. Let me know how it goes for you in the comments.