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 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 launch new ec2 instance, so you can move 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 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 intance 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:
Step 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 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 :
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 whether 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. 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 ssh terminal to grant permission of user.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';
4.5 – Reload all privileges
mysql> FLUSH 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.pl index.php index.xhtml index.htm </IfModule>
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.pl index.xhtml index.htm </IfModule>
5.3 – Restart Apache Web Server
After successfully installed PHP MySQL and configure these on ubuntu amazon ec2 instance.
Finally, You need to restart 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 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 browser and looks like the following screen:
Then click on let’s go button. After that, you need add your database name, username, password, Sitename, and email on next screen.
Congratulation, you have successfully installed lamp (linux, apache 2, php and mysql) and wordpress on amazon(aws) ec2 ubuntu.