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.

Arch Linux: moving from php5 to php7

So as per usual I issued a pacman -Syu, then did a reboot to check everything is as it should be and well it wasn’t.   Apache was no longer starting as it was claiming that line 155 in the config file was wrong.

155 LoadModule php5_module modules/libphp5.so

I remember reading that arch had moved from php5 to php7 so this made sense.  I changed the line to the following

155 LoadModule php7_module modules/libphp7.so

That worked out as expected, the server was happy to boot up now, however on my homepage I got a warning that mysql support is not enabled in php.  So next we changed /etc/php/php.ini to removed the semicolon infront of

877 extension=mysqli.so

Restart apache, job done..