Setup Apache and Install WordPress on AWS EC2 Instance Ubuntu 16.04

In this blog post you will be going to learn how to setup apache and install wordpress on AWS EC2 ubuntu 16.04 instance. Before starting this tutorial I assume you have already logged in to your aws EC2 ubuntu instance. If you do not know how to connect then please refer
how to connect to aws ec2 instance

STEP 1: Update Packages and Install Apache2

Run below commands to update packages and install apache2

sudo apt-get update
sudo apt-get install apache2

Run below command to start apache2

sudo service apache2 start

STEP 2: Install Mysql Server

Run below commands to install mysql server

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation

STEP 3: Install PHP and PHP Extensions

Add repository for php installation

sudo add-apt-repository ppa:ondrej/php

Update Packages

sudo apt-get update
sudo apt-get upgrade

Out of below 3 commands run only one depending which php version you want to install.

sudo apt-get install php7.0 # for PHP 7.0
sudo apt-get install php5.6 # for PHP 5.6
sudo apt-get install php5.5 # for PHP 5.5

Install php extensions, again depending on your php version update the command accordingly. Below command is for php version5.6.

sudo apt-get install php56-curl php56-gd php56-mbstring php56-mcrypt php56-xml php56-xmlrpc

STEP 4: Create database and user for wordpress installation

Run below commands to create database for wordpress and create a user with access to the wordpress database.

GRANT ALL ON wordpressdb.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

STEP 5: Download WP and Extract

Run below command to download wordpress and move files to respective document root for site.

cd /tmp
curl -O
tar xzvf latest.tar.gz
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
sudo cp -a /tmp/wordpress/. /var/www/html

STEP 6: Setup file and folder Permissions

Run below commands to change file and folder permissions and ownerships for wordpress to install and work properly.

usermod -a -G www-data apache
chown -R ubuntu:www-pub /var/www/html
find /var/www/html -type d -exec chmod 2775 {} \;
find /var/www/html -type f -exec chmod 0664 {} \;

STEP 7: WordPress Installation Screen

Open your domain on web server and you should see wordpress installation screen. Put in database information and further installation steps on inerface.

Add a Comment

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