23rd Jan2014

Update/Install ImageMagick on CentOS 5 and CentOS 6

by Gyro

Today I had a classic example of what happens when you do not RTFM. I had to install ImageMagick on a webserver running CentOS 5 with cPanel. First I simply ran "yum install imagemagick", which did install ImageMagick just fine.

Now, the reason I had to install it was to do a batch resize of about 20,000 images and place the resized images in a new directory. So I did:
# mogrify -resize 250 -quality 70 -path /home/somesite/public_html/image/thumbs/ -format jpg /home/somesite/public_html/images/*

To my surprise I got the error message:

mogrify: unrecognized option `-path'.

After a quick google search, I realized that yum installed a super old version that was not supporting the -path option?!

So, after some more searching, I found this great guide on how to Install ImageMagick 6.6.5 and followed the instructions. But when I got to the final installation command, I got a dependencies error?!

After another google search, I came across a forum post saying "Make sure that RPMForge repository is installed first, and then everything works."… and when I looked back at the guide, I realized that it did in fact tell me to do that. The reason I did not see it was because it was a one liner with a link to another website, and I was expecting to be able to simply copy paste commands, so I skipped reading that line. I did not RTFM properly…

So, to make it easy for the future, I will combine these two pages, in order to have a step by step set of instructions without having to go to another website :)

Before starting, make you sure you know whether you are using a 32-bit or 64-bit system.
# uname -i
x86_64 would be 64-bit

OK, here we go!

1. Uninstall ImageMagick

# rpm -e --nodeps ImageMagick.i386 ImageMagick-devel.i386 ImageMagick.x86_64 ImageMagick-devel.x86_64
this actually didn't work for me, so I did:
# yum remove imagemagick

2. Add the EPEL repository to yum:

CentOS 6:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
CentOS 5:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

3. Download and Install RPMforge (Check here for newer version.)

CentOS 6:
Download RPMforge for 32-bit systems: rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
Download RPMforge for 64-bit systems: rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Install DAG's GPG key:
# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

If you get an error message like the following the key has already been imported:
error: http://apt.sw.be/RPM-GPG-KEY.dag.txt: key 1 import failed.

Verify the package you have downloaded:
# rpm -K rpmforge-release-0.5.3-1.el6.rf.*.rpm

Install RPMforge:
# rpm -i rpmforge-release-0.5.3-1.el6.rf.*.rpm

CentOS 5:
Download RPMforge for 32-bit systems: rpmforge-release-0.5.3-1.el5.rf.i386.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm
Download RPMforge for 64-bit systems: rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm

Install DAG's GPG key:
# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

If you get an error message like the following the key has already been imported:
error: http://apt.sw.be/RPM-GPG-KEY.dag.txt: key 1 import failed.

Verify the package you have downloaded
# rpm -K rpmforge-release-0.5.3-1.el5.rf.*.rpm

Install RPMforge
# rpm -i rpmforge-release-0.5.3-1.el5.rf.*.rpm

4. Install dependencies for ImageMagick 6.6

For 32-bit systems:
# yum install djvulibre OpenEXR jasper ghostscript librsvg2 libwmf libtool-ltdl
For 64-bit systems:
# yum install djvulibre OpenEXR jasper ghostscript librsvg2.x86_64 libwmf.x86_64 libtool-ltdl.x86_64

Systems running CentOS 6 will need the old version of libtool-ltdl installed:
For 32-bit systems:
# rpm -ivh --force ftp://ftp.muug.mb.ca/mirror/centos/5.9/os/i386/CentOS/libtool-ltdl-1.5.22-7.el5_4.i386.rpm
For 64-bit systems:
# rpm -ivh --force ftp://ftp.muug.mb.ca/mirror/centos/5.9/os/x86_64/CentOS/libtool-ltdl-1.5.22-7.el5_4.x86_64.rpm

5. Download and Install ImageMagick 6.6.5

Download for 32-bit systems: ImageMagick-6.6.5-10.i386.rpm
# wget http://www.lassosoft.com/_downloads/public/Lasso_Server/CentOS-Extra/ImageMagick-6.6.5-10.i386.rpm
Download for 64-bit systems: ImageMagick-6.6.5-10.x86_64.rpm
# wget http://www.lassosoft.com/_downloads/public/Lasso_Server/CentOS-Extra/ImageMagick-6.6.5-10.x86_64.rpm

Install ImageMagick
# rpm -ivh ImageMagick-6.6.5*

DONE! :crazy:

9725

21st Feb2013

Restore large mysql databases with nginx 504 Gateway Timeout

by Gyro

I had to restore a 36MB sql database today and kept getting a "504 Gateway Time-out".

After playing around with the config files, adding fastcgi_read_timeout to the settings for php5-fpm, and fiddling with the php.ini, I realized that this can be accomplished with one single line using ssh:

Assuming that you have packed the .sql file into a zip file, and you are currently in that folder:
# gunzip < databasebackup.sql.gz | mysql -DDATABASENAME -uUSERNAME -pPASSWORD

DATABASENAME = name of the database
USERNAME = mysql username
PASSWORD = mysql password

I hope this helps when trying to restore large mysql databases with nginx 504 Gateway Timeout

2338

04th Feb2013

Ubuntu update/upgrade fails with dpkg error message

by Gyro

Today, my Ubuntu was unable to install update.

I got this error message after trying to update Ubuntu:

dpkg: error: parsing file ‘/var/lib/dpkg/available' near line 15054 package ‘unity-common':
duplicate value for `Architecture' field
E: Sub-process /usr/bin/dpkg returned an error code (2)

After some research and trial'n'error, I came up with this solution:

1.Clear the content of the "available" file
# sudo nano /var/lib/dpkg/available
or
# sudo rm /var/lib/dpkg/available
# sudo touch /var/lib/dpkg/available

2. "Reset"
# sudo dpkg --configure -a
# sudo apt-get clean

3. Update/Upgrade again
# sudo apt-get update
# sudo apt-get upgrade

That should be all!

Step 2 may be unnecessary, but I have no way of testing it again… maybe someone with the same or a similar problem can try it without step 2 and let me know? ;)

1364

21st Jan2013

Gitlab service doesn’t run on startup/boot/autostart

by Gyro

I have been using Gitlab for a while now to have backups of all my git repositories on my dedicated servers. Now, I needed to reboot one of them for the first time since I installed Gitlab, and ended up with a ‘502 bad gateway' warning by nginx, when trying to access the Gitlab web interface.

I found this on the github, hidden in a small pull request:

gitlab doesn't start on boot if you follow the install instructions on Ubuntu (12.04 LTS Server -- probably others). Turns out gitlab requires redis-server to be running for gitlab to be able to start. Startup script S20redis-server isn't run until after S20gitlab so gitlab fails to start on boot. Webserver will be up, bad gateway 502 error is usually seen/reported. Starting gitlab manually works (because redis-server has started). This change makes gitlab start after redis-server.

The single line for victory:
# sudo update-rc.d gitlab defaults 70 30

Enjoy :enjoy:

source: github

2995

20th Sep2012

An error occurred while loading the page android facebook newsfeed 2012

by Gyro

First time I opened the Facebook app on our new android tablet, it said: An error occurred while loading the page.

So the android facebook newsfeed not showing was a real bummer, and finding out why I cannot see anything when opening the Android Facebook app, except a small turning circle and a short message saying: "An error occurred while loading the page.", became a priority.

After some searching, the solution was simple:

(more…)

6181