Migrate WordPress on FreeBSD from php5 to php7

PHP7 offers performance improvements that anyone hosting WordPress site will want to enjoy.  Moving a B.A.M.P. install from php5 to php7 is simple enough.

First install the packages for php7:

  • pkg install mod_php70
  • pkg install php70-mysqli
  • pkg install php70-session
  • pkg install php70-ctype
  • pkg install php70-xml
  • pkg install php70-curl
  • pkg install php70-ftp

mod_php70 is the php7 module for apache.  We also need the mysqli package (don’t forget the “i”) otherwise we will get database connection errors.  Session handles sessions funnily enough.

Your not done yet even though your site may seem to work at this point.  ctype is used by jetpack, without this your jetpack dashboard won’t work.  I forgot why I need XML as I didn’t have a guide like this one to follow…  Finally if you use auto updates from within WordPress you need curl and ftp so you can download and install updates.

Now you have everything you need.  Time to enable php7 in the apache configuration in “/usr/local/etc/apache24/httpd.conf”

Remove php5 add php7:

  • LoadModule php5_module  libexec/apache24/libphp5.so  << remove this
  • LoadModule php7_module  libexec/apache24/libphp7.so << add this

Allow php to use the mysqli extension

  • Edit /usr/local/etc/php.ini
  • extension=php_mysqli.dll << remove the semi-colon (;) from the start of this line

Restart apache and you should now be running on WordPress on Apache 2.4 and php7 under FreeBSD.

 

Moving from Arch Linux to FreeBSD..

..and from a local web-server to a cloud based virtual machine.

So I’ve been running this site on an old Dell D400 laptop for a while.  Arch Linux has been the operating system of choice.  This machine has performed admirably as a web server for many months now.  But its single core 1.6 Ghz processor and 5400 RPM hard disk are limiting factors for performance and expansion.  Lets migrate it to the Cloud…

First step was to select a place to host the site from.

I went with a Digital Ocean droplet, I was able to quickly sign up for a single core machine with 512Mb of RAM and 20 Gigs of SSD storage  for $5 per month ($6 with weekly backups).  The lower amount of memory was not such an issue as Arch was using maximum of around 400Mb and that is running more services that just the website.  I could pick a data-center in London and speeds to and from droplet are clearly faster than my broadband’s 240 down and 24 up.

Operating System:

I’m a big fan of Arch Linux, but at this time Digital Ocean don’t offer it and to be honest I’d never expect them too.  CentOS is a solid choice and familiar to an R.H.C.E. like me, Ubuntu is also available but while I’ve used it a lot I just don’t enjoy some of the problems that crop up and how you need to solve them.  So in the end I decided to go with FreeBSD.  The choice came down to this, I can work with that operating system faster and the base install seems to be more memory efficient which should not be a factor, but its always better to have more RAM than you think you’ll need.

Deployment:

So the droplet was created very quickly, I had to generate an ssh key and associate it with the droplet first.  Then I still had some trouble logging in.  This came down to the fact that its not very clear that you need to use that key to login as the user FreeBSD then use ‘su’ and ‘sudo’ as needed, I eventually found out through Digital Oceans blog, would be nice if it said so on the creation screens.  Once that was out of the way we quickly install our web-server/database/language stack setup each component and wrote some test pages to make everything worked.

Finally I moved across this WordPress blog in about 2 minutes, using tar, gzip and ftp and it worked pretty much straight away.  Its so nice when your planned migration even a small one like this actually goes like clockwork!

Next:

So I will be blogging more instead of maintaining the servers, next I want to see what the state of MongoDB is on FreeBSD I’ve a feeling it isn’t going to be pretty, but time will tell.

FreeBSD, the good, the not so good, the next step

So about a week into using FreeBSD I have to say I really like it.

I went from “current” which is a stupid name for a future cutting edge version to “stable” which is the current recommended release version.

Basic tasks, editing files, starting and stopping services, network configuration changes are all straightforward and logical.

The pkg package manager is pretty cool, port works fantastically too.  It still is odd if your used to a single package manager on a system, but it works and works well.  You get odd situations, like the unbound situation.  Its part of the base system, already present, but for more than the basic config you are recommended to install the port.  So after a bit of compiling you end up with a few more config files.  I’m not sure if the compile turns on additional features but it seems a bit wasteful.  Regardless I did it and have unbound configured the way I want.

So I planned to do more testing this week, setup a NIS and LDAP server for example, but then I went and applied for a Linux/VMware job.   So I guess I need to study for that first.  Should be interesting to see how much Red Hat I’ve forgotten since May (probably not much) and how much VMware I’ve forgotten since last weeks training course (probably lots)

Wish me luck….