How to host multiple websites with Apache

The Apache web server has a convenient feature called Name-based Virtual Hosting. This function allows us to have a single LAMP Stack server configured on one IP address, but serve a different set of files depending on which domain is being requested.

This sounds more complicated than it is. Say we had example1.com and example2.com, both of which are to be separate websites, but both domains point to the same IP address. Apache’s Name-based Virtual hosting makes this possible. In fact, this feature forms the basis of 90% of this planet’s shared hosting business.

Let’s see how to do this in CentOS 6 and 7.

Read more

How to update legacy constructor methods in PHP 7

When I was fiddling with my P2 Categories theme last week, debug mode generated several warnings when run in PHP 7.2.1. That’s because class methods are no longer allowed to have the same name as the class itself. This was allowed in PHP 5 and earlier, but from what I gather it’s no longer the … Read more

How to display categories in Automattic’s P2 Theme

By default, Automattic’s phenomenal P2 theme does not support posting into categories from the front page, it only supports tags. My fork of the theme called P2 Categories does that though and lets you conveniently select a category from a drop down menu right there on the front page.

I wrote an update to it last week, and in so doing my article from 2013 came in handy that explains how to add this functionality to P2. Nothing much has changed in the source code, so it’s still relevant and accurate.

What the above article did not explain however was how to show which category a post belongs to. And because it’s still fresh in my  memory how to do this, I thought I’d better write it down for next time (and anyone who’s interested in how to do it).

Read more

How to install PHP 7.x on a CentOS LAMP Stack

By default, CentOS 7 comes with support for PHP 5.4. Sadly that version has reached the end of its life in 2015and is no longer updated by the developers. If we want to stay up to date with the latest software, we may want to upgrade (if our applications are working with newer versions of PHP).

For CentOS users this either means to compile cutting edge versions from source and tweaking lots of scary system configurations – or dipping into the power of Software Collections. These are official pre-compiled packages by the software vendor, designed to run newer versions of software alongside those that are provided by default.

At the time of writing, PHP 7.2 is available but it’s not part of the software collections yet, so we’ll use  PHP 7.1 with FPM support under Apache (as it’s the recommended way to do so).

Let’s begin!

Read more

Finding your current MAC address in CentOS

I had an issue with one of my servers the other day: its power supply died unexpectedly during a scheduled restart. The poor thing never cam back up again.

Lucky for me, the data centre could simply swap out my hard disks and put them into another server. Although my data was save, the server wouldn’t connect to the network anymore – because it had a new MAC address. CentOS stores this value in two of its files, and when it changes (which is hardly ever the case), those files need to be updated.

Here’s how I fixed the problem. I did this on a CentOS 6 server, but it looks like the procedure is the same for CentOS 7.

Read more