How to Install WordPress on AWS Apache 2 Ubuntu 18.04

Who is the Best cloud hosting provider?

  • Amazon EC2

    Votes: 0 0.0%
  • AliBaba Cloud

    Votes: 0 0.0%

  • Total voters
  • This poll will close: .


Staff member
May 13, 2020
Installing WordPress on amazon AWS ubuntu. Here, we will teach you how to install WordPress and configure it on amazon AWS ubuntu 18.04 with Lamp stack.

WordPress installation and configuration on Amazon AWS ubuntu web server are very simple things. Because the Ubuntu community provides several commands to install and configure Lamp (Linux, Apache, MySQL, and PHP) on the AWS server. As well as the WordPress community.

This tutorial will teach you first on how to install a lamp stack on ubuntu 18.04 ec2 AWS. Then how to install WordPress on AWS.

How To Install WordPress And Configure With Lamp Stack On Amazon EC2 Ubuntu Instance
Use the below steps to install lamp(Linux, Apache 2, PHP and MySQL) and WordPress on ubuntu 18.04 amazon(AWS) ec2:

  • Step 1: Launch New AWS ec2 Instance
  • Step 2: Connecting your AWS EC2 Instance from SSH
  • Step 3: Install Apache 2 on ubuntu 18.04
  • Step 4: Install MySql
  • Step 5: Install PHP 7.3
  • Step 6: Install WordPress And Configure
Step 1 – Launch New AWS ec2 Instance
First of all, you need to launch AWS ec2 instance. If you have already launched a new ec2 instance, so you can move the next step. Otherwise, you need to read this tutorial how to launch ec2 instance in AWS step by step for launch AWS ec2 instance.

Step 2 – Connecting your AWS EC2 Instance from SSH
In this step, you need to connect your AWS ec2 instance from the ssh terminal. If you are new to connect AWS ec2 instance with windows, ubuntu, and mac system. So you can read this tutorial “How to Connect to ec2 Instance From Putty and SSH Terminal” to connect your ec2 instance from ssh.

Step 3 – Install Apache 2 on ubuntu 18.04
In this step, use the following ubuntu commands to install ubuntu on your virtual server:

3.1 – Update Ubuntu System Repositories
sudo apt update
3.2 – Update Ubuntu System Repositories
sudo apt install apache2
3.3 – List the UFW application profiles
sudo apt install apache2
3.4 – sudo ufw allow ‘Apache Full’
sudo ufw allow 'Apache Full'
3.5 – Verify that the Apache service is running
sudo systemctl status apache2
3.6 – Open Browser and type EC2 instance IP
Finally, open your browser and type your AWS ec2 instance IP address. And, it will be looks like the Apache 2 page in the following picture:

install apache 2 web server on amazon ec2
install apache 2 web server on amazon ec2Step 4 – Install MySQL
4.1 – Installing MySQL server

Now, open your ssh terminal and type the following command to install MySql Server:

sudo apt-get install mysql-server

4.2 – Securing MySQL server in Apache aws ec2
Then, secure the MySql server by using the following command. So, you will need to set the root password of the database and secure it using the following command :

sudo mysql_secure_installation
When you run this command. Then the questions given below in the prompt will appear:

  • You will be presented with a screen where MySQL asks whether you would like to activate the VALIDATE PASSWORD PLUGIN. For now, keeping things simple, type no.
  • In the next type the root password of your choice. Confirm it again.
  • In the next screen, MySql will ask whether to remove anonymous users. Type yes
  • Disallow root login remotely? Type No
  • Remove test database and access to it? Type Yes
  • Reload privilege tables now? Type Yes
  • After the password has been set you can check the weather MySQL is working correctly by logging into the database with the command :
sudo mysql -u root -p
The above command will ask for the password. The password is the same that was set in the previous step.

4.3 – Create MySQL User
Now, Create a user named ‘test’. you can choose the user name anything you want.

mysql> CREATE USER 'test'@'localhost' IDENTIFIED BY 'Password';
4.4 – Grant Permission To User
Now, type the following command on the ssh terminal to grant permission of the user.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';
4.5 – Reload all privileges
4.6 – Create Database For WordPress Website
Now create a new database for WordPress website. So, type the following command on your ssh terminal to create database that named wp-aws:

mysql> CREATE DATABASE wp-aws;
Now, use the exit command to exit from MySql:

Step 5 – Install PHP 7.3
5.1 – Install PHP and Common Extensions

Now, install PHP with it’s common extensions. So open your ssh terminal and type the following command:

sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip php-mbstring
5.2 – Edit dir.conf File
After successfully installed PHP on ubuntu amazon ec2 instance. Now, you need to configure dir.conf file by using the following sudo nano command:

sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:

<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.php index.xhtml index.htm
Move the PHP index file to the first position after the DirectoryIndex specification, like this:

<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.xhtml index.htm
5.3 – Restart Apache Web Server
After successfully installed PHP MySQL and configure these on ubuntu amazon ec2 instance.

Finally, You need to restart the Apache 2 server by using the following command:

sudo service apache2 restart
Step 6 – Install WordPress And Configure
6.1 – Installing WordPress

Use the below command to download the latest version of WordPress on the EC2 instance:

6.2 – Extract WordPress setup tar file
Type the below command on your ssh terminal to extract the WordPress setup tar file:

tar -xvzf latest.tar.gz
6.3 – Move the extracted file contents to /var/www/html Directory
Use the below command to move all extracted file contents of WordPress to /var/www/html direcotry:

sudo mv -f wordpress/* /var/www/html
6.4 – Enable Permission to Apache 2 User
Type the following command on ssh terminal to enable permissions on the WordPress folder to the apache2 user:

sudo chown -R www-data:www-data /var/www/html
6.5 – Type Your instance Ip Address On Browser
Now, you need to type AWS instance ip address on the browser and looks like the following screen:

Then click on let’s go button. After that, you need to add your database name, username, password, Sitename, and email on the next screen.

Congratulation, you have successfully installed Lamp (Linux, Apache 2, PHP and MySQL) and WordPress on amazon(AWS) ec2 ubuntu.