Installing wordpress using EC2 instance .

I’ve been working in this industry not longer than 6 months and in that time I’ve learned to set up an ec2 server and using it further to install wordpress plugin that helps me to create and design website as I like.

What is wordpress and what is used for?

WordPress is a content management system (CMS) that allows you to host and build websites. WordPress contains plugin architecture and a template system, so you can customize any website to fit your business, blog, portfolio, or online store. It started out as a blogging platform in 2003 but soon transformed into a CMS and later a full-fledged website building platform.

Before installing  a wordpress plugin we need to create to an ec2 instance by logging into the AWS management console. The steps to set up an EC2 instance are on another article titled “AWS Lab: Setting up an EC2 instance as a Web Server”. After setting up an EC2 server we need to insert series of codes in  the command line interface which will help up install the wordpress plugin.

The steps to installing wordpress might seem lengthy but it’s easy to understand and execute.

Setting up mariaDb, httpd and user permissions.

We’ll need to install maria db which is a database which will store data then install httpd which will provide a channel for user to acces the site. The command below would be used for the mentioned tasks.

sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
sudo yum install -y httpd mariadb-server
sudo yum install -y mod_ssl
sudo wget -r –no-parent -A ‘epel-release-*.rpm’
sudo rpm -Uvh*.rpm
sudo yum-config-manager –enable epel*

After all that the command should be inserted “sudo yum update –y” which will allow users and system administrator to easily install, update, remove or search software packages on a systems.

The next step is to use the usermod command which allows you to make a lot of different changes to user accounts without having to carefully edit files like /etc/passwd, /etc/shadow and /etc/group. … In addition, sudo permissions will be required for this command since superuser access is required to set up or change nearly all user account settings.

sudo usermod -a -G apache ssm-user
groups ssm-user
sudo chown -R ssm-user:apache /var/www
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;

To start and check the status of the http, the following command  will execute it respectively.

sudo systemctl start httpd
sudo systemctl status httpd

Installing  wordpress.

To start the installation of wordpress the following series of commands need to be executed.

tar -xzf latest.tar.gz
sudo systemctl start mariadb
mysql -u root -p
CREATE USER ‘wpnx3admin’@’localhost’ IDENTIFIED BY ‘Insert username‘;
CREATE DATABASE `Insert databasename-db`;
GRANT ALL PRIVILEGES ON `nx3wordpress-db`.* TO ‘wpnx3admin’@’localhost’;

User has to insert username and databasename of his/her choice where the Insert username and insert databasename is written respectively.

After creating database and username , setting up  login credentials is needed to login into wordpress.

cp wordpress/wp-config-sample.php wordpress/wp-config.php 
vi wordpress/wp-config.php 

Next command is to install the php-gd .GD is used for the dynamic creation of images,  creating PNG, JPEG and GIF images and is commonly used to generate charts, graphics, thumbnails .

sudo yum install php-gd
sudo yum list installed | grep php-gd

For the final step you need to change the file and directory ownerships to apache for the the wordpress to work. It can be done by the following commads:

sudo chown -R apache /var/www
sudo chgrp -R apache /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;

After all the above commands restart the httpd with sudo systemctl restart httpd and your wordpress is ready to be used.

Seeing all the commands mightnget you think that the process of setting up wordpress is quite burdensome but once you get the hang of it’ll be able to do it within minutes, as  guy who has been introduced to this in a short time can do this, then everyone will be able to do it.

Haulal Guite

Cloud Engineer Trainee Recent graduate. Studied history and philosophy, now going to the Cloud!

Leave a Reply

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

Scroll to top


* indicates required