A WordPress LAMP?! An Introduction to WordPress Infrastructure

If you’ve been around web servers for very long, you’ve probably heard someone refer to the “LAMP stack.” And whether or not that’s true, you probably have some interest in how WordPress actually presents pages to the Internet. So our goal is to get a basic understanding of the infrastructure that underlies your WordPress site. In doing so I hope you get a basis through which to understand all the ways you may use WordPress for development, making local changes, and maybe even hosting it yourself.

What is the LAMP stack?

At its heart, LAMP is in initialisms that stands for: Linux, Apache, MySQL, and (depending on who you ask) PHP. So lets explain each of those individually, starting from the last.

Using PHP as a Part of the LAMP Stack

php-med-transAs I said, PHP isn’t the only P-language that can be used in a LAMP stack. Initially (in the 1990s, when this whole thing was new) it commonly stood for Perl, and it’ll also sometimes explained as Python. If someone is hosting a LAMP application, they’re using one of those languages in the final implementation layer of their app, and for WordPress that means PHP. And also, PHP is necessary for WordPress. The computer that’ll host your WordPress site simply has to be able to parse and execute PHP code. If it can’t, you don’t get to run WordPress.

That being said, you may have heard about the HHVM. I wrote an article last year that explains the HHVM in more detail, but the very short version is that it is a faster (if somewhat less stable) engine upon which you can run PHP scripts. Quite recently Wikipedia, which is written in PHP like WordPress, revealed that they’ve nearly doubled their performance by switching to the HHVM. A number of WordPress hosts are also toying with it for that big performance boost.

MySQL as your database

mysql-logoWordPress needs a place to store data. For this it traditionally uses an relational database management  system, RDBMS, solution called MySQL. MySQL was the first and still most popular free software RDBMS solution (in terms of both rights — libre — and price — gratis — meanings). There’s been some tumult in the last few years that Oracle, who own the project, is making it less free. But it remains the go-to for many for both practical and historical reasons.

While it’s possible to make a CMS like WordPress without a database, it’s neither very common nor all that practical. So when you create a new post in WordPress, it goes into the database. When you save a new option in your site for a plugin, it goes into the database, etc.

WordPress doesn’t actually — strictly speaking — need to be run on MySQL. I’ve heard tell from more than a few sources that MariaDB and Percona can be and are both used as the database layer for WordPress. But those two are drop-in replacements for MySQL, so it’s not the case that WordPress can work with just any RMDBS.

Apache takes care of that Web Stuff

Apache-LogoIn a vast oversimplification, computers do computing and the internet works on data-exchange. How do you bridge that gap? A web server like Apache. For a long long time, Apache was the only web server that anyone used or cared about. That’s changed in the last few years, but it’s still the biggest, and it’s what your WordPress site is likely being served with.

The most obvious way that users know and care that they’re hosting on an Apache instance is that they use and know what an .htaccess file is. There are a lot of other things that matter about Apache, but for WordPress purposes that blows all the others away. Many WordPress user’s first and only exposure to Apache is through that file not working to give them their “pretty permalinks” for some unknown reason.

What’s been replacing Apache? Nginx — pronounced “Engine X” — is a leaner server than Apache, which shows all it’s 20-some years. Nginx is a good bit snappier than Apache, which is the reason that many many WordPress specific hosts are moving or have already moved to it. For a while PHP+Apache went together everywhere, now you’ll see HHVM+Nginx chosen by a non-trivial number of people to replace it; it’s just such a faster combination. But it’s got some hurdles, and for Nginx the most important is that you don’t get your convenient (if sometimes frustrating) .htaccess file. This is the most obvious hard thing about running WordPress on something other than Apache, but it’s also a solved problem.

Linux: The Operating System under Everything

TuxSo as we’ve covered, almost every piece of the LAMP stack which is traditionally used to run WordPress isn’t required, and this is especially true of Linux. If you’re not familiar, Linux is an operating system, like Apple’s Mac OS or Microsoft’s Windows. It’s the most popular Unix-like operating system, and it’s the most common operating system on servers.

The specifics of what “Unix-like” means, what an operating system is, etc aren’t that important. What you actually need to know about this layer, from a WordPress perspective, is just that everything else — your web server, your database, and your language — ride atop the operating system. And if those three work, WordPress works. If you’ve ever heard people refer to WAMP or MAMP as how they develop WordPress sites locally, that’s how — Windows and Mac OS work fine for WordPress, assuming everything else is in order.

What it all means

Why cover the LAMP stack? Because we, as WordPress users, hobbyists, and professionals can often get so caught up on WordPress stuff that we miss the things that underly and power WordPress, like the whole LAMP (or MEPH, if you picked alternates for each; people use an E for Nginx because it more easily replaces the A of Apache) stack. What I hope this quick tour of the infrastructure that usually powers WordPress has given you is a basis to learn and understand more.

I hope you now understand what it means and why it’s cool that you can use WAMP, MAMP, or XAMPP to develop WordPress sites locally. Or use Vagrant (or more specifically VVV) to virtualize a WordPress-running stack right on your computer. When you understand all the building blocks that underlie your software, you end up with way more power over your software. Happy hacking!

Image credit: artdecodude


2 Responses

Pingbacks