Thursday, November 21, 2013

Moved my blog to VPS

Few months back I had moved my blog to Heroku, now I wanted to try out VPS. Heroku was all good but updating every thing via Git commands was kind of a pain when there is a image upload or wordpress version upgrade. VPS is like renting virtual hardware and OS and getting full access to the same. I choose DigitalOcean as they were very cheap and some of my friends gave good feedback about it. I choose the lowest plan that was 5 USD per month for a 512 MB ram. I got root access to the virtual machine and installed LAMP (Linux, Apache, MySQL and PHP) to host my PHP blog.

Blog ran all fine initially but soon I started getting the errors as MySQL kept shutting down automatically. So i had to login and start it manually. From error log and customer support I came to know that for tech stack I am running 512Mb may not be sufficient, so I decided to give it some swap space. Anyway DigitalOcean claims all its storage is SSD and those are supposed to be faster than HDD. Following are the commands for setting up swap.

dd if=/dev/zero of=/swapfile bs=1M count=1024

mkswap /swapfile

swapon /swapfile

# vi /etc/fstab

(add line /swapfile swap swap defaults 0 0)

swapon -s

free -k

This reminded me late 90s linux installation when we had to allocate some space to swap partition in the hard disk apart from boot and root (most of the times in addition a partition containing Windows 98 :) ) . of course those days RAM used to be expensive.

The blog has been running fine after that, I will continue to monitor for few for days.