I wanted to research writing a WordPress plug-in. The problem? I have no idea how to do that!
I figured I’d need a WordPress environment to play in. So, rather than installing MySQL on my workstation and adding more clutter, I figured – why not just bring up the typical, simple installation that everyone uses?
What is LAMP?
You may have seen this acronym floating around, it means: Linux, Apache, MySQL, and PHP. That combination makes for a useful environment for development. This concept has been around for years, but for me personally, I haven’t really done anything with it.
Where do you start?
Well, it seems like Ubuntu is really the goto Linux distribution lately. It’s Debian-based which means it’s pretty reasonable to work with, a everything seems to work with it. So, I started by creating an Ubuntu virtual machine in Hyper-V. Download the .iso from here:
create a new virtual machine in Hyper-V and install the OS. Then, see here for fixing the default resolution.
Installing the “AMP” part of “LAMP”:
In the olden days (more than like 2+ years ago), this is where things turned into a nightmare. Rarely would there be an “installer”, and if there was, it didn’t work. You’d have to download, and perhaps even compile the dependencies, then compile the product you want – it was, a nightmare.
However, just like pretty much every other technology, there came about the idea of a “package manager” – similar to NuGet, Bower, NPM, which are all quite similar to the concept of an App Store for your phone. These package repositories have pre-built packages that you can add to your system, similar to how you add an app to your phone.
For Debian-based systems like Ubuntu, you can use “apt-get”, for Red Hat-based distributions, you’d use “rpm”, and for everything else, “yum” is still fairly popular. So, for our purposes, let’s get it simple and use “apt-get”. So, how to you install the Apache web server, MySQL, and then PHP? With these commands:
$ # Install the Apache web server.
$ sudo apt-get install apache2
$ # Install PHP5
$ sudo apt-get install php5 libapache2-mod-php5 php5-mysql
$ # Install MySQL
$ sudo apt-get install mysql-server mysql-client
$ # Install WordPress
$ sudo apt-get install wordpress
It literally doesn’t get any easier than that, and it just works!
I’m back at a command-line… um, now what?
Oh yeah, I forgot – so the installers don’t really tell you much.
For Apache and PHP – on my installation, the web server root is at:
and there is even a default index.php in that root folder too. So, put PHP or HTML files there if you like, and you should be able to open a browser and navigate to that computers name or IP address on port 80.
For MySQL – you can use “mysqladmin” at any prompt to see a help screen, and you can start configuring your server from there. You can also use “mysql –u root –p” with a blank password and that may work (depending on the version). You can also install a PHP front-end for MySQL administration. I couldn’t get it working, but try installing:
$ sudo apt-get install phpmyadmin
and there is a small wizard that you go through.
For WordPress – the root of the default site is:
however, this is not automagically mapped in Apache. To do that, edit this file:
$ sudo pico /etc/apache2/sites-enabled/000-default.conf
In there, you’ll see a “DocumentRoot” – which is the root directory of the website, and which folder on the file system to which it points. In the empty line after that, add this line:
Alias /wordpress /usr/share/wordpress
That will make it so that when you navigate to http://localhost/wordpress on the linux machine, it will serve the pages in the /usr/share/wordpress directory. You’ll need to restart the web server daemon for the change to take affect. You do that with:
$ sudo /etc/init.d/apache2 restart
After that, you’ll see that the directory is now mapped to the URL.
Particularly if you’ve never messed around with Linux, this is just a short crash-course on how to get a basic web installation set up. If you did this on a virtual machine, it’s even easier because it doesn’t require any hardware or for you to “mess up” any of your current configuration!