can you blame me for this one?

Let’s put it together, piece by piece, so we have a clear idea of what we’re running on our system and how to configure them.

If you want to install everything right now and configure later:

However, you might want to choose between MariaDB and PostgreSQL, unless you want to try both.


If you don’t have Apache / httpd installed, you’ll want that with something like:

If you’re running soy-stemD.. I mean systemd, you can use these following commands to start/stop Apache, see if the Apache service is running, etc:
If you haven’t started it yet, you’ll see something like:

Run something like:
After this, you should see something like: along with some other info about the service.
You can always run the status command to check on it at any point in the future as well.
Of course if you want Apache to start automatically when you start your computer, you can “enable” it with:

at which point you’ll see something like:

We now must make one quick configuration check and change, if needed, to comment out the unique_id_module because, we’re focused on a local development setup, not serving traffic to customers here.
To do this, edit your httpd.conf file

Make sure this line is commented:

It was already commented on my Apache install, but it’s good to double check. If your version was already commented, you’re good to go. If you had to comment it out, restart Apache with:

Now Apache is running. If you’re new to this, now you also know that “Apache” as known by Unix, is “httpd.”

LAMP or LAPP? …MySQL/MariaDB or PostgreSQL

Public Domain,

So, now that you have the L and the A of the LAMP going, we’ll turn our attention to the database service. I’m a bit of a Postgresql fanatic, but choose as you like. At this point it’s either LAPP or LAMP. If you choose Postgresql, it’s double elephant mascots, so that’s great. I was going to say that the process to install either is well documented on the internet, but after a couple of searches, I take it back. I’ll outline the installation of both here, succinctly. If you view the MySQL Arch Wiki page, you’ll see that MySQL is developed by Oracle, and Arch favors the community-developed fork MariaDB. In fact, Arch dropped MySQL down from the core repo to the AUR.


Let’s install MariaDB instead of MySQL, since Arch favors it (since 2013), and it starts with an M so technically, the LAMP acronym will still apply.. haha.
Install it from the core repo with:

At the time of writing, this command installs three packages:
Before starting the service, run:

This is a basic installation. You may choose to put your datadir in another spot, like an external hard drive or something like that.
At this point, there will be instructions in your terminal about how to start, auto-start, and test the service. For example:

which, after executing should return something like:

At this point, you can start the service with soystemd like this:

At this point, you should see that it is and you may log into it with default / unhardened blank root password like this:

After hitting Enter to pass a blank password you should see something like this, indicating that the database service is up and running and you are logged into it:

You can exit MariaDB for now by issuing the command:
Check the docs for further info about creating a user, granting it privileges, hardening initial security, further configuration, etc. We’ll discuss connecting to a test database in a bit.


If instead of, or in addition to, MariaDB, you’d like to have Postgresql installed, you can get a jump on this install and setup process by following along here. There are a few options I’ve played with over the last few months. If you want version 10, which I did initially because it was the engine version I was running in AWS RDS Postgresql, there is a nice option , courtesy of EDB, you can get from the AUR. At the time of writing, the regular pg-10 package has been recently orphaned. For now, I’ll walk you through install and setup of the latest, official version from the core repo. Install it with:

At time of writing, the current version is
During installation, a user called postgres is created. You can check him like this:
which will produce and output something like this:
Next, we’ll need to initialize the db cluster. Before we do that, let’s switch to the postgres user. (Medium’s formatting is not allowing me to write “su <dash> postgres” without it looking like this “su — postgres”)

type this to become the postgres user

Now, that you are the postgres user, initialize the database cluster with:

Just like MariaDB, you may put your data directory somewhere besides this location, but for right now, we’re sticking with basics.
After running the above command, you should see some output ending with:

It’s no surprise, you can also start and enable the service with our old friend soystemd. Just be sure to switch back to your regular user (by typing from your postgres session) before you do it like this:

If you want it to start automatically when you start your system, “enable” it with:

If you’d like to check it’s status, follow the same pattern:

Now that the cluster is initialized and the service is running, you can log into the PostgreSQL cluster using . You can either switch to the postgres user and simply run , or you can run: to do the same thing.
From here, continue to follow the docs to create users, databases, etc.
There is some assumption here, that you have some familiarity with MariaDB/MySQL or PostgreSQL if you are following along here.


Finally, the P in LAMP. If you’d like a specific version of PHP, there are various versions of php5 and php7 available if you search the AUR. If you want the official, latest version from the core repo, you can simply run:

At the time of writing, it is version Edit the PHP configuration by editing your php.ini file:
Change to and to
You’ll also want to uncomment some of the extensions by removing the at the beginning of each line:

After making these changes, you should restart Apache:


Now you have a LAMP (or a LAPP) stack.

By Vicki Nunn — Own work, Public Domain,

We could end it here, assuming that readers will be able to connect the various pieces and have a good time, but we won’t. Some of the stories I write here get hundreds of thousands of eyeballs on them, so I have to assume there are some fresh faces that have made it this far and would appreciate something like a “Hello World” exercise to get all of this working and connected. It is for you that I continue :-)

Getting things connected and working

Sometimes life as a software engineer feels something like this image here. Actually, I’ve seen much worse IRL. At least in my world there are always problems to untangle. Engineering in general can be categorized as problem solving, even solving train-wreck-tier problems. This sort of thing is fun for folks like us, and if you’ve made it this far in this article, I imagine you, probably, like me, enjoying solving difficult problems. So, let’s continue.

Let’s test out Apache and make sure he is happy.

Now you’re in the directory that, by default, Apache is going to serve to your browser. Create a basic html file here. Something like:

Then paste some html content like:

Then just type into your browser and you should see something like this:

Let’s make sure Apache and PHP are playing well together

In order for Apache and PHP to become friends on your local setup, you must make a few more configuration changes to httpd.conf

Add this to the end of your httpd.conf:

This will work, but you might like to organize this a little differently by placing the at the end of the Include list section and the and in the LoadModule list if you want to be more a bit more tidy. Functionally, putting all three lines at the end accomplishes the same thing.
After these changes, restart Apache again:

Now, you can test things out in the terminal and in the browser.
Create a file in /srv/http called info.php

Populate it with this content:

Make it executable like this:
Run it from the terminal with:
Then try it from the browser:
Now, you should see something like this in your browser:

Now Apache and PHP are friends.

only showing public repos from github for obvious reasons

You can continue to work directly in /srv/http, but that’s probably not going to be a great experience. Rather, let’s create a symlink from here to the local copy of a Git repo you want to work in, or perhaps the local directory where you keep all of your Git repos, or something like that. In order to accomplish this, you need to have “FollowSymLinks” in your /etc/httpd/conf/httpd.conf file, but chances are, it’s already there by default, like this:

I removed the comments for brevity, but here we can see that “Indexes” and “FollowSymLinks” options are enable by default.
The problem you’ll probably encounter has to do with permissions based on where to you want to symlink to. Let me give you a concrete example.
Instead of putting my code in /srv/http directly, I want to create a symlink from there to wherever my directory of Git repos lives. The catch is that there has to be executable permissions all the way to that directory down the entire file path. The solution is to put your “repos” directory here: “/repos”, or somewhere you don’t mind having executable permission from “/” to. Let me walk you through the steps I took:
1. Move my “repos” directory from /home/beach/repos to /repos

2. Set appropriate permissions
3. Create the symlink from /srv/http to /repos

Now, when we visit http://localhost/repos/ in the browser we can see everything in our /repos directory.
Our browser is following the symlink we put in /srv/http, and we can continue to work from a centralized “repos” directory.

To triple check, create a new directory in your repos directory and name it something like “aMediumTest.” In that directory name a new file “helloWorld.php” and populate it with the contents:

Then navigate to http://localhost/repos/aMediumTest/helloWorld.php and validate that you are seeing it show up in the browser.

We could walk through instantiating a database cluster, filling it with a test database, connecting to it and querying it through php, but this article is already getting a little too long, and if you’ve made it this far, I can probably assume you can get connected to a DB from here.
I will however include those steps in another article in the near future, at which point I will come back to this one and link to it from here. If you’re reading this and you don’t see the link, it means I haven’t gotten to writing that sister article yet.

Thanks for reading and I do hope someone found this helpful.
Tim Beach

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store