Technology

Installing Multiple WordPress sites on one Amazon ec2 instance

Today I terminated my old bitnami ec2 instance that hosted my original wordpress site and instead setup a new ec2 instance which is running three wordpress sites. As usual, it took some time, as it’s never always simple, is it?

To get this working, I followed the guides available here:

https://nouveauframework.org/blog/ultimate-guide-to-hosting-wordpress-on-aws-ec2-for-complete-beginners/

http://nouveauframework.org/blog/vhosts-running-multiple-sites-on-a-single-aws-ec2-instance/

What needed Changing from the original guide

The guide doesn’t really show how to create the database schema or the user. I followed the instructions here, but they could be expanded a little better. http://webvaultwiki.com.au/(S(iungfwenvz2f5c55pioeinil))/Default.aspx?Page=Create-Mysql-Database-User-Workbench&NS=&AspxAutoDetectCookieSupport=1

The instructions set the user to ec2-user when it should be apache, this stops the themes and plugins from working.

sudo chown -R apache:apache /var/www/html/

The instructions install an old (and slower) version of php. Here’s how to install php 7.1:

sudo yum install -y php71-devel php71-mysqlnd php71-pdo php71-mbstring
sudo yum install -y php71-opcache
sudo yum install -y php71-pecl-memcached

More information:
https://tecadmin.net/install-apache24-php7-on-amazon-linux/

Vhost Configuration and Advanced DNS

In the vhost configuration we need to add the ServerAlias, for example:

ServerName harmel.co.uk
ServerAlias www.harmel.co.uk

In the Advanced DNS section of your name provider, you need two A Record entries. You do not need a CNAME record. The first A Record is @ and points to the IP address of your ec2 instance. The second A Record is www and also points to the IP address.

ServerName harmel.co.uk
ServerAlias www.harmel.co.uk

Also, it’s better for the website to be in /var/www/html and not vhosts folder, as the instructions deviate at one stage from its own advice…

Leave a Reply

Your email address will not be published. Required fields are marked *