By: Suriyal
In this tutorial we will learn how to install WordPress in Amazon EC2 Ubuntu instance. If you have the following queries in mind keep reading this tutorial
(1) If you do not have aws account you can create a free account. Click on the Create a Free Account button and follow the instructions.
(2) Once the account is created successfully click on the Sign In to the Console button to sign In to the AWS Management Console
(3) Enter the credential and click on the next button to enter the password.
(1). Click on services as shown in the following image
(2). Click on the compute menu item as shown in the following image
(3). Click on the EC2 as shown in the following image
(4). Click on instances as shown in the following image
(5). Click on launch instances to create new ec2 instance as shown in the following image
(6). Name and tags : Enter the name of your virtual machine
(7). Application and OS Images : We are using Ubuntu for this tutorial. Select Ubuntu free tier eligible
(8). Select instance type : We are using t2.micro for this tutorial. Select t2.micro free tier eligible
(9). Click on the create new key pair
(9.1). Enter you key pair name (you can enter any name of your choice)
(9.2). Select key pair type, we are using RSA
(9.3). Select key file format, we are using pem
(9.4). Click on the Create key pair button
Network settings
(10). Configure storage
(10.1). We are using 30GiB storage
(11). Advance details
(11.1). We are using default setting in this section
(11.2). Click on the Launch Instance button and wait for few minutes to complete the process
(12). The instance is running now
(1). Click on the load button to select the .pem key file from you local system
(2). Select the file
(3). Click on the Save private key button and save the file as .ppk
Note : If you have not installed Putty in your system download and install putty first.
(1). Open Putty
(2). Click on Session as shown in the following image
(3). Enter host name or IP address
(4). Click on the Auth
(5). Click on Browse button
(6). Select the .ppk file from your system
(7). Click on the Open button
(8). Click on Accept button
(9). Enter user name ubuntu and press enter key
(10). You have successfully connected to you virtual machine. See the below image and terminal
Now you are connected to your VM and ssh terminal is looking good! Install the Apache now
Extra Info & Optional: Apache HTTP Server is a free and open-source cross-platform web server.
(1). Update Ubuntu System Repositories : Type the following command on the terminal and press enter key
sudo apt update
(2). To install the Apache web server type the following commands and press enter key
sudo apt install apache2
or
sudo apt install apache2 -y
You can learn more about UFW (UncomplicatedFirewall) Click here
(1). Check the list of the applications profiles that need access
sudo ufw app list
(2). We will use Apache Full profile for enabling different network activities
sudo ufw allow 'Apache Full'
(3). Check the status of traffic on port 80 and 443
sudo ufw app info "Apache Full"
(4). Check apache2 service status
sudo systemctl status apache2
(5). Enter the public IP address in browser (remove ‘s’ from https:// if you have not installed ssl) and check if you able to see the similar Apache2 Default Page as shown below, if yes, you have installed the Apache successfully
(1). Type the following command and press enter key to install the MySQL server
sudo apt-get install mysql-server
or
sudo apt-get install mysql-server -y
(2) To secure the MySQL server in Apache2 enter the following command and hit enter
sudo mysql_secure_installation
(2.1). Enter Y and follow instructions as shown in the following screen
(2.2). If screen stuck terminate the session and login again and go to the next step to create database and user
(1). Type the following command and hit enter key in terminal to use SQL prompt
sudo mysql -u root -p
CREATE USER 'user1'@'localhost' IDENTIFIED BY 'EnterPassword';
CREATE USER 'user1'@'%' IDENTIFIED BY 'EnterPassword';
CREATE USER 'user1'@'%' IDENTIFIED WITH caching_sha2_password BY 'Enter Password';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user1'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql>exit;
Enter the following command and press to create new database. Refer the following image
create database wordpressdb;
(5). To check the status of MyQL services enter the following commands and press enter
systemctl status mysql.service
(1). Finalise list of packages
(a). Common files for PHP packages – php-common
(b). PHP MySQL extension – php-mysql
(c). A graphics drawing library – php=gd
(d). PHP Command Line Interface – php-cli
(2). Type the following command and press enter
sudo apt install php php-mysql php-gd php-cli php-common
Extra Info & Optional : To get list of available extensions , type the following command and hit tab twice
sudo apt install php-
Type the following command and press enter to edit the dir.conf file
(1). Press ‘i’ from your keyboard and move the index.php file to first position as shown in the following image
(2). Once done press Esc key from your keyboard
(3). After Esc key press type :wq and hit enter key to save changes
sudo vi /etc/apache2/mods-enabled/dir.conf
(4). Restart Apache Web Server
sudo service apache2 restart
(1). Open your ssh terminal and type the following command and press enter key
sudo apt install phpmyadmin
(2). Press space bar to select Apache2 and press enter key
(3). Press tab once and hit enter
(1). Type the following commands to install wget pakage and press enter key
wget: This is a non-interactive command line tool and a software package for retrieving files using HTTP, HTTPS, FTP and FTPS protocols
sudo apt install wget unzip -y
(2). Type the following command and press enter to download the WordPress
sudo wget https://wordpress.org/latest.zip
(3). Type the following command to unzip the downloaded latest version of WordPress
sudo unzip latest.zip
(4). Type the following command to copy all unzipped file to the html directory
sudo cp -r wordpress/* /var/www/html/
(5). Make sure that the directory you are writing to allows for www-data to write to it. Enter the following command and press enter key
sudo chown www-data:www-data -R /var/www/html/
Info: sudo chown $USER:www-data /var/www/mysite
(6). Delete index.html in /var/www/html type the following command and press enter key
// to go to the path " /var/www/html " type cd /var/www/html
sudo rm -rf index.html
(7). Enter the the url / public ip address / domain name / Public IPv4 DNS in the browser. If you have not install SSL certificate please remove ‘s’ from the http://
(8). You will see the following screen once you entered the public ip in the browser. Click on Continue button and Let’s go! button
(9). The following screen will get displayed after the click. Now click on the submit button
(10). Click on the Run the installation button
(11). After the button click the following screen will get displayed
(12). Click on login button
(13). Login and enjoy wonderful blogging using WordPress
(14). Admin panel of WordPress
This is the home page you your newly created website. Enjoy!
Thank you for reading this “Install WordPress on Amazon EC2 Ubuntu 22.04 Instance or Virtual Machine” tutorial
Have a great learning experience !
Note : The details provided in this tutorial are for educational or testing purpose only. Use the configuration as suggested by your IT team.
Leave a Reply