chkconfig vs systemctl on Amazon T3 intances.

I was a bit surprised when installing Apache 2.4 on Amazon EC2 T3 instance that chkconfig did not work like it does on my T2 instances; instead you use systemctl.

Here is a bit of a conversion table for the two.

List processes

# chkconfig –list

# systemctl list-units
Enable a service

# chkconfig <servicename> on

# systemctl enable <servicename>.service
Disable a service

# chkconfig <servicename> off

# systemctl disable <servicename>.service
Start a service

# service <servicename> start

# systemctl start <servicename>.service
Stop a service

# service <servicename> stop

# systemctl stop <servicename>.service
Check the status of a service

# service <servicename> status

# systemctl status <servicename>.service

I believe this is because the Amazon T3 instances have updated Centos, Rhel and Fedora features.

If we take a peak at the operating system we see



Making sure you install the correct version with yum

This has happened to me more than once so I thought I’d jot it down. Many times when you read tutorials on how to install different software packages on Linux you will simply see

sudo yum install package_name

However this may not install the version of the software you actually intended.

For example, say you want to install Apache httpd server.

A tutorial will say

sudo yum install httpd

Apache at the time of this writing is Apache 2.4 and running the above common on my Amazon instance would actually install Apache 2.1.

So here are some steps to walk through to make sure you install what you think you are installing when using a package manager.

1) See if the software package is installed and if it is the version you intend to install.

you list all installed software packages with

yum list intalled

but why not narrow it down if you know the package name. Use wildcard for good measure in case there are multiple version out there.

yum list httpd*

2) If it is not listed, then you need to install it but check to see what version would be installed.

For example,

sudo yum install httpd will install Apache HTTP Server 2.2

3) Install the version you want

First we need to see what versions are available in our repositories.

There we are the Apache HTTP version we want, 2.4.

My Must Install Drupal 8 Modules.


Must have for human readable urls instead of urls like /node/1


You will want to control each pages title tags and meta description for search results listing and SEO.

Google Analytics

You will want data on who is visiting you website and their interactions. This modules allows you to track customize which roles you track.

Simple XML sitemap

You will need this for SEO and Google Webmasters tools et al.


If you plan to let users sign up and sign in this is a must have module. Spam bots can easily detected Drupal’s login url and form so protect yourself before you have a lot of annoying accounts to delete.

The evolution of an Apache virtual host


The simplest virtual hosts

When an HTTP request comes into the IP address and Port 80, the Apache server will detect the hostname in the request and route the request to the directory declared in the DocumentRoot.

Adding www

It is still not uncommon for people to search for domains by adding www, for example and

To make them both route to the same place we simply add a ServerAlias declaration in our virtualhost. Now when someone visits or they will be served the same files.

This is of course assuming you have set up your DNS to point www to your IP address.

Serving files from a user’s home directory.

Writing Apache error and access logs to a user’s home directory.

580 days sober: Two brothers.

I have been sober 580 days.

Last Sunday my brother turned 39. We both have struggled with addiction most of our adult lives.

There is much debate whether addiction is influenced by nature (genetics), nurture (learned) or choice (free will).

I cannot help but look at my brother and myself through a scientific lens. Our life is as close as I can get to observing addiction with a semblance of scientific method. We were born 3 years apart, in the same small town to the same parents with similar DNA and elementary education.

If anything, life is a grand experiment in circumstance and choice.

We do not choose when we are born, where we are raised or the genes in our DNA. We start life as a propagation of statistical probabilities influence by randomness and decisions, fortune and misfortune, made by our parents and our ancestors.

Is it your choice to be born with a hereditary predisposition to alcoholism?

Could anyone have predicted we live in a time when opioids are mass produced as medicine for the profits of others?

Or that economic and cultural disparities between rural counties and urban centers would leave little opportunity for your personal growth, entertainment and fulfillment?

Is it really a choice at age 14 to smoke your first joint when your older brother is modeling that behavior?

Have we not all made choices to hide insecurities and garner approval?

Do I hold this up as an excuse for an addict’s behavior? No. Why? Because none of this matters today. It is in the past. The only thing that matters is now and next.

I write this to help others understand that addiction is not as simple as a moral decision nor can it be excused as a hereditary disease.

These conditions, circumstances and choices leave impressions on your mind and form patterns in your brain. This determines behavior.

These impressions and patterns can be changed. I promise you. At age 39 I was a drunk and saw very little reason to live. Now I am beyond grateful for the life I have.

Nature. Nurture. Choice. It simply does not fucking matter. What matters is that we don’t give up. What matters is that we help as many people as we can.

Make a new impression. Start a new pattern.

Adding and removing a module from Drupal 8 using Composer

To add a module navigate to the directory that has your applications composer.json
You might take a look at the contents of composer.json
$nano composer.json
Then install the module from the command line using:
$composer require drupal/address
You can revisit composer.json and see that it is installed.

If you want to remove it you can simply

$composer update

Changing Apache MPM fro Prefork to Event

This post will depend on your distribution.

If you need to know what Apache MPM module you are using you can use a command similar to this.

$ httpd -V | grep -i 'version\|mpm'

This will tell you the current loaded Apache MPM module

If you want to change you you need to go to the Apache configuration files.

On Centos mpm has its own configuration files inside a configurations modules directory.

$ cd /etc/httpd/conf.modules.d/00-mpm.conf
$ sudo nano 00-mpm.cong

You can see in this Apache module configuration file the preform MPM is enabled (by not being commented out, #)

We simply comment out the prefork MPM and uncomment the event MPM

Save and close this file and restart Apache.

I then usually check top to see if I have my expected result. If moving from a process to threaded MPM you should see less Apache processes.


Or check out my process list

ps -f -u apache

Moving sites from old VPS cpanel sever to EC2

Just some notes as I had to do this a number of times today. There are likely still some efficiencies to be gained but this is pretty quick.

I am running  Apache 2.4 with per user web directories for this post. One of the reason’s this works os well with per user web directories is that I can visibly see progress without having to change my local machine’s host files, and I can name my EC2 servers user accounts the same as my cpanel server’s accounts, and it makes the commands a bit less confusing.

Adding a user to your EC2 Apache server configured with per user web directories means if I add a user I can serve files from whatever directory you configure in your .conf files


The UserDir directive specifies a directory out of which per-user content is loaded.

I have my server configured read files in public_html inside of each user home directory.

If I visit the URL

I will see any files i have put into /Home/rbown/public_html on my new server. This is  similar to how my old cpanel server is configured.

Let’s start, and again there are a plethora of ways one could do this. This is just how I did it today.

sudo adduser butlerraines

This command will create a new home directory and user on my EC2 instance.

sudo su butlerraines
cd ~

Here I switch user (su) and impersonate butlerraines. The command sudo will allow me to switch users easily and without a password (note I didn’t set one when I added the user)

The command cd ~ puts me in the home directory of the current user so now my current path is /home/butlerraines

Let’s make our public_html directory.

mkdir public_html

Now let’s check your permissions.

Ok! So let’s navigate to public_html

We will use an absolute path just to make sure we know where we are.

cd /home/butlerraines/public_html

Now we have files over on the old Hostgator cpanel server we want to move. And granted you could pull all these files down by FTP, either zipped or unzipped and push the back up. Or really a ton of different ways to do this.

In this post I simply use rsync.

As always I like to make sure programs and utilities are on my machine so I run the which command.

which rsync

and it tells me it is in fact on my machine, and I can tell it is in path. If “path” is a foreign concept to you just know if the command or executable is in the path you can run with from just about anywhere.

[butlerraines@ip-xxx-xx-x-xxx public_html]$ which rsync

It’s there!

Cool. Ok here we go. I am in /home/butlerraines/public_html and about to sync the files from my old Hostgator Cpanel VPS to my EC instance.

rsync -azvv /home/butlerraines/public_html/


Let’s go through this because it could be confusing, and I purposely did it this way for simplicity. Yeah I know. Sounds backwards.

Using the rsync command I am going to attempt to log into my old server, and go to the path holding the files I want to copy

The trailing slash / tells rsync to only get the contents of /home/butlerraines/public_html/ and not the directory public_html itself.

Then once I have logged into this directory successfully, make a copy of those files on my EC2 instance which I have purposely set up with the same username and directory structure.

When I click enter it will ask for the password to user butlerraines on my old Hostgator VPS, and if successful start making copies of the files.

Step 2. Move the database

Exporting the database tables from the old VPS

Since my old VPS  is utilizing cpanel, I’m going to make an assumption here and say anyone reading this is probably used to managing their database in a GUI interface like phpMyAdmin. We could do all this from the command line on the old VPS server but here we do it from cpanel and phpMyAdmin.

On my old VPS I log into my account via cpanel and navigator to phpMyAdmin

I select the database I need and export the tables from that database. Why is that underlined, well you can export the database itself but I just want the tables for this post.

I exported the tables from the database to my local machine. It is not pictured here but I selected the option to gzip my .sql file. You don’t have to depending on the size of you database. You probably don’t have to at all, but I did. Ok moving on.

This exported to my Downloads folder on my local machine.

Copying the exported .sql file to a EC2 instance

Now that I have my exported database on my local machine I need to move it to my remote EC2 instance.

Since I am already able to SSH into my EC2 machine with my SSH keys (if I couldn’t I wouldn’t have even been able to do the first part of this post), I can easily apply that to a similar protocol, scp.

SSH into an EC2 instance looks like this


ssh -i /Users/username/.ssh/filename.pem</code>

The first part is an example path on a local machine to a private ssh key.

The second part is the standard way to connect to a remote machine username@ipaddress.

scp looks very similar


scp -pr -i /Users/username/filename.pem /Users/username/Downloads/database_1.sql.gz


Basically we are copying the database file from the Downloads folder on a local machine to the ec2-user home directory of the EC2 instance. Don’t be confused by the fact am putting in /home/ec2-user instead of the specific user directory where we placed our original files. MySql is a bit agnostic to where the .sql files is stored. We just need to know where to find the sql quickly, and it will be in /home/ec2-user

Importing the tables to the new database

We have exported the database (well the tables from the database) from the old VPS and now have pushed the .sql file into home directory of the ec2-user on the new EC2 instance.


Now let’s log back into our EC2 instacne


ssh -i /Users/username/.ssh/filesname.pem


This should put us in the home directory of ec2-user. If you want to be sure you can always


cd ~


I always like to take a peek by listing all the files if the directory. You should see your database file in there ie database_1.sql.gz




Now you need to login to mysql from the command line on the EC2 instance.


mysql -u username -ppassword



  • I set up mysql on this machine long before I wrote this post and setting up mysql is out of scope of this post.
  • You mysql username and password is mostly likely not nor it should be the same password as your Linux users on your EC2 machine.
  • That is not a typo above. The flag is -p for accepting a password and then there is no space after the -p. Alternatively you can simply put ‘mysql -u username -p’ and upon enter it will ask for a password.
  • I’ve already created the database I want to import so yes I cheated a bit.

Now that your end your command prompt will change a bit


mysql> show databases;


mysql> show databases will show you all the databases you have created.


mysql> use database_1;


use database_1 selects the database you will be using. Put if your database name of course.


mysql> source database_1.sql;


source database_1.sql puts the tables in the export into the database_1 (or whatever you named it).


mysql> exit;


mysql> exit gets you back to the normal command line.

Step 3. Hook up the files and the database.

Today I was moving Drupal and WordPress sites from my old Hostgator VPS to a new Amazon EC2 instance.

Inevitably you will have to make some adjustments to each web applications configuration files.

This particular example was a WordPress site. You can tell by the database table names. So I will need to edit the wp-config.php files in /home/butlerraines/public_html and add in the new database name, database username and database password.

I find it easier to switch users than to worry with file permissions. Currently I am logged in as ec2-user but I want to edit the wp-config files as butlerraines.

Earlier I showed you how to switch users.


sudo su butlerraines


now let’s go back to /home/butlerraines/public_html


cd /home/butlerraines/public_html


If you look in this directory you will see wp-config.php.




Most Linux machines will have a variety of text editors you can use. The one I like is called nano

You can open and edit the wp-config.php file with nano and make the changes you need to connect your database.

Now go visit visit the URL

and you will see things starting to happen.

Installing Drupal 8 from the command line without Composer or Drush

You might read my tutorial on Installing Drupal 7 from the command line first as it is more in depth. I am troubleshooting an error I have installing Drupal 8 with Composer and trying to discern if it is my LAMP stack or Drupal 8 or Composer by process of elimination.

Since I am using Apache User Directory to serve my web application from public_html in the users directory, I like to make sure I start in the user home.

[user@ip-xxx-xx-x-xxx public_html]$ cd ~

I then go into the public_html directory.

[user@ip-xxx-xx-x-xxx public_html]$ cd public_html

I have a habit of listing the contents of directories I enter just be sure it looks like I want it to.

[user@ip-xxx-xx-x-xxx public_html]$ ls

I download the latest version of Drupal to public_html using wget. I find the latest version of Drupal go to This version at the time of this post is 8.5.5 so I will download it.

[user@ip-xxx-xx-x-xxx public_html]$ wget

I list all the files in public_html and should see drupal-8.5.5.tar.gz

[user@ip-xxx-xx-x-xxx public_html]$ ls

It is a zipped fie. I will unpack the zipped files directly into the directory, public_html.
[user@ip-xxx-xx-x-xxx public_html]$ tar --strip-components=1 -xvzf drupal-8.5.5.tar.gz

This will extract all contents of drupal-8.5.5.tar.gz but also leave the drupal-8.5.5.tar.gz in public_html. If you want to you can remove it from public_html.

[user@ip-xxx-xx-x-xxx public_html]$ rm drupal-8.5.5.tar.gz

Go to the url where you are attempting to install Drupal 8 and start the web installer.

Depending on how your server is set up you might see the following errors. This is because “Drupal” did not have permission to create files or directories  on the server. No worries you will just change them.


So let’s mikes the files directory first in /sites/default/

Starting in public_html

[user@ip-xxx-xx-x-xxx default]$ cd sites

[user@ip-xxx-xx-x-xxx default]$ cd default

[user@ip-xxx-xx-x-xxx default]$ mkdir files


Now back to web installer and refresh. We see a different error.

Since this error has to do with the directory being writable I will just add write permissions for the all, the user, group and other users.

[user@ip-xxx-xx-x-xxx default]$ chmod a+w files

Basically this simply is
chmod who=permissions filename where a = all= user, group, and other and w = write.

That cleans that error up. There is only one more. The Settings file does not exist.

Drupal give you and example settings file you can copy and rename. One thing to note,
in this tutorialyou are currently in the default directory or /sites/default relative to public_html. Relative to your user home directory you are at /user/public_html/sites/default. Relative to the root of your file system you are at /home/user/public_html/sites/default.

It is always good to know where you are. Again if you are following this post you are current in the default directory.

We need to copy default.settings.php and rename it settings.php.

[user@ip-xxx-xx-x-xxx defaultl]$ cp default.settings.php settings.php

Alright we are almost set. One more error. Now we have to make the Settings file writable.


Similar to what we did above. Let’s go ahead and grant write permissions to all. However we will need to lessen the permissions later.

[user@ip-xxx-xx-x-xxx default]$ chmod a+w settings.php


And now let’s finish the install by configuring Drupal to connect to our database. This post assume you have a database set up already.

Installing Drupal 7 from the Command Line

I am messing around installing Drupal 8 using Composer on an Amazon EC2 instance and ran into some errors. To eliminate whether it is Drupal 8 or some other factor, I installed Drupal 7 in another virtual user directory.

For this example I am using Apache 2.4, PHP 7.1 and MySql 5.4 and using Apache per user web directories.

Log into your remote server on using ssh

I like to download and extract files in my home directory.

To make sure you are in the home directory (you most likely will be you) you can type

[user ~]$ cd ~

cd = change directory

You can download Drupal remotely using wget or curl. I will use wget here.

If you are curious if you have wget on your machine you type this into you terminal. It will tell you the file path the webget binary if it is on your machine.

[user ~]$ which wget

The Drupal installation instructions give you an example command:


But if you are new to this you might not realize that you need to replace “.x” with the actual version you want to download. At the time of this writing, the latest Drupal 7 version is 7.5.9

So you command will actually look like this in your terminal

[user ~]$ wget

Hit Enter and it will begin to download

One it is done you might want to look to make sure it is there.

[user ~]$ ls
drupal-7.59.tar.gz public_html

ls simply is a command to list the contents of the directory you are in.

You will see it is zipped up. So we need to unzip it. Just use the exact file name.

tar -xvzf drupal-7.59.tar.gz

Now if you list the contents of the directory again we will see the zipped files, the unzipped directory by the same name, and the directory we want to host our site in, public_html.

[user ~]$ ls
drupal-7.59 drupal-7.59.tar.gz public_html

I have configured Apache to serve my Drupal site from public_html so I need to move my Drupal files , the contents of the drupal-7.59 directory to public_html

We can do this by using the copy command, cp. I prefer cp to mv (move) here simply because if I have done something wrong I have a known good copy.

[user ~]$ cp -R drupal-7.59/* public_html

If you don’t put the -R (recursive) option it won’t cp the directories inside the drupal-7.59 directory.

I like to look and make sure it copied over. So change directories (cd) to public_html and list (ls) the contents of the directory.

[user ~]$ cd public_html
[user public_html]$ ls

Not done yet.

Depending on how your server is set up you may or may not have to create a settings file and a files directory. If you are using the web installer the installer will tell you if Drupal was not able to create these for you.

If Drupal hasn’t created these for you, it will look something like below. It tells you exactly what the error is and what you need to create and modify. If it has you will just be able to proceed.

OK so here is where it gets a little tricky if you aren’t used to navigating in a terminal. If you have been following along in this post, you should be in the public_html which is the root of your Drupal web application.

If you are lost or aren’t sure at any point and need to know where you are relative to the root of machine you are on simply type pwd (present working directory)

Let’s take a look:


[user public_html]$ pwd



In this example you are in the public_html directory (your Drupal root) which is inside your user home directory, /home/user/public_html relative to the root of the directory structure.

If you aren’t there are aren’t sure you can always change directories (cd) and specify the absolute path ie /home/user/public_html where user is your username.

Hopefully that didn’t confuse you too much.

All that to say, you want to be in public_html and you want to work relative to there from here on out.

Let’s tackle this one first.


Because we got the errors we need to create a settings.php file and change its permissions so the web installer will work.

We could do it all in one command like which would make a directory (mkdir) called files in public_html/sites/default

[user public_html]$ mkdir sites/default/files

or just to illustrate, we can transverse each directory then make the new directory (mkdir), files

Starting at public_html

[user public_html]$ cd sites
[user public_html]$ cd default
[user public_html]$ mkdir files

The difference here is the first option leaves you in the public_html directory whereas the second option puts you in the public_html/sites/default directory.

If you go back to web installer you see a different error message. The directory is there but is not writeable by Drupal.

So we need to change the permission on the directory.

We change permission with the command chmod (change mode). Understanding file permissions is beyond the scope of this post. On this particular server we want to the permission of site/default/files to 777.

[user public_html]$ chmod files 777