theChrisWalker.net

“PHP 5.3 addict ”

says Chris

QR Code for Permalink
VPS Migration for thechriswalker.net – New Host, New OS, no Plesk

without comments

Not that I didn’t like Plesk. I just have the urge to understand things well, and I couldn’t understand all of how Plesk worked… So I wanted it “all-manual”, like the true hardcore (read: idiot) I am.

I had been using a VPS to host this website (amongst other things) and it was getting old. It ran on CentOS 4 and used Plesk as a control panel. PHP was down at version 4.2.2 or something and MySQL still at version 4.x. I didn’t understand server administration as well as I do now and the whole thing was a bit of a mess. So I decided a fresh start, with a VPS on more powerful hardware and built cleanly.

So I went for a basic VPS from 34SP.com with no control panel and using Ubuntu 9.04 as the OS. They set up the server quickly and so I went about configuring it how I wanted. There were a couple of snags along the road and so I’ll tell you about them here too.

The Basics, disabling root.

First things first, the VPS came with the root account enabled and that as the only user on the system. Now I like to have my root account disabled and use sudo, so I created an admin user, granted sudo rights and disabled the root account. The command used are below.

Create user and set password:

# useradd admin
# passwd admin
# visudo

Now in the sudoer’s file you’ll see a line for root which looks something like:

root ALL=(ALL) ALL

duplicate this line but with you’re username:

admin ALL=(ALL) ALL

save and exit. Now log out of root and back in as admin, then disable the root account:

$ sudo passwd -l root

and we’re done!. Now on this system my home directory wasn’t created (probably because I didn’t give the right flags in the useradd command. So we need to make it.

$ sudo mkdir -p /home/admin

LAMP Stack

34SP had installed Apache but not PHP or MySQL, both of which I wanted. In fact I wanted the following:

  • Apache with mod_rewrite
  • PHP5.3+ (5.3 is important to me) with APC, Xdebug and MongoDB
  • MongoDB server
  • MySQL5 server

I also needed to migrate my blog from it’s current location, to the new server. The Blog uses WordPress 2.8.something and the latest version at time of writing is 2.9.2 (time to upgrade!). WordPress doesn’t mention PHP5.3 support so this could be fun.

So, first hurdle, the default Ubuntu Repositories do not have packages for PHP5.3. This leaves 2 options, compile from source or find a repositiory which does have the packages. Knowing which I’d prefer and having already heard of dotdeb.org I added the dotdeb.org PHP5.3 repository to my sources.list and then I could install PHP5.3.2 and xdebug and apc right from apt!

After editing /etc/apt/sources.list:

$ sudo apt-get update
$ sudo apt-get install php5 php5-mysql php5-cli php5-xdebug php5-apc mysql5-server

But I also wanted MongoDB which is only available as a PECL module. So I need the php5-dev package. unfortunately, this gave me an error about libtool not being the correct version. and the only way to resolve it (that I could find) was to use libtool from the previous Ubuntu release.

$ sudo apt-get purge libtool
$ wget http://cn.ubuntu.com/hardy/libtool.deb
$ sudo dpkg -i libtool.deb
$ sudo apt-get install php5-dev

Then it worked like a dream and I could finally use pecl

$ sudo pecl install mongo

That was the PHP module, but what about the actual MongoDB server itself? Well, there’s a repository for that as well. Add it to your sources.list, update then you can apt-get install mongodb. no configuration necessary. The phpinfo() output shows the mongo extension installed correctly and the mongo shell functions to show the mongodb server is working fine.

OK, now time to get my blog up and running, so I create a new virtual host in /etc/apache2/sites-available and use the apache tool to enable it sudo a2ensite thechriswalker.net. I have all my virtual hosts in /var/www/vhost//{httpdocs,logs}, I change to the httpdocs directory and grab wordpress wget http://wordpress.org/latest.tar.gz, unzip and browse to it to see if it worked!

Well, of course it didn’t – I hadn’t done a couple of things. First I needed to restart Apache to enable the Virtual Host I had created. Then I realised that the DNS hadn’t propagated so I needed to set a static hosts entry on my local computer. This done I tried again – success!

So I dumped the database from the old VPS, copied (scp’d) my custom theme, plugins and some other non-wordpress content across to the new one. On the new one, I imported the wordpress database and tried to access it again. It took me through a 2 step “we need to update your database” (it was 2.8 not 2.9 remember) screen which worked great! That was easier than expected and I haven’t seen anything behave oddly under PHP5.3 – result.

More

Now I just need to setup the email side of things, I want to be able to send and recieve mail securely through this server, but thats a job for another day… Also I moved the email for this domain over to Google Apps, as I like GMail so much, so I may not even bother with the email part of this!

Written by Chris

March 25th, 2010 at 7:16 pm

Posted in Not Code

Tagged with , , ,

Leave a Reply