DEV Community

Zahraa Jawad
Zahraa Jawad

Posted on

Our WordPress site installation by AWS

WordPress is a popular content management system (CMS) that allows users to create and manage websites without extensive coding knowledge. Originally developed as a blogging platform, WordPress has evolved into a versatile tool for creating websites of all kinds, from personal blogs to e-commerce sites to corporate portals. 43% of the web is built on WordPress. More bloggers, small businesses, including notable brands and publications such as The New York Times, Forbes, and Sony Music.

On a slightly more technical level, WordPress is an open-source content management system licensed under GPLv2, which means that anyone can use or modify the WordPress software for free. A content management system is basically a tool that makes it easy to manage important aspects of your website – like content – without needing to know anything about programming.
The end result is that WordPress makes building a website accessible to anyone – even people who aren’t developers.

WordPress is licensed under the General Public License (GPLv2 or later) which provides four core freedoms:

  1. The freedom to run the program for any purpose.
  2. The freedom to study how the program works and change it to make it do what you wish.
  3. The freedom to redistribute.
  4. The freedom to distribute copies of your modified versions to others. And the some Features of WordPress:

• Easy-to-use interface with a visual editor and drag-and-drop functionality.

• Thousands of customizable themes and plugins to enhance functionality and design.

• Built-in SEO tools to optimize content for search engines.

WordPress.org and WordPress.com

The difference between WordPress.org and WordPress.com in a lot more detail, but here’s the short version:

• WordPress.org, often called self-hosted WordPress, is free, open-source WordPress software that you can install on your own web host to create a website that’s 100% your own.

• WordPress.com is a for-profit, paid service that is powered by the WordPress.org software. It’s simple to use, but you lose much of the flexibility of the self-hosted WordPress. Most of the time, when people say “WordPress”, they mean the self-hosted WordPress available at WordPress.org. If you want to truly own your website, self-hosted WordPress.org is almost always the best option.

Secure and Reliable of WordPress

WordPress is highly secure and reliable, thanks to its dedicated team continuously working on improving its security features and addressing vulnerabilities. With regular updates, robust user authentication, and a vast plugin ecosystem for enhanced security, WordPress provides a trustworthy platform for businesses and bloggers to protect their valuable data and ensure a stable online presence.

Kinds of Websites that Can Make Using WordPress

Any type of website imaginable can be made with WordPress. Users from all over the world use WordPress to make money online. It's simple enough to quickly create small websites and flexible enough to run e-commerce operations.

Here are some of the types of websites you can build with WordPress:

• Start a blog
• Make a small business website
• Create an online store
• Build a membership community
• Sell online courses
• and many more

Creation of WordPress by AWS: A Step-By-Step:

Some simple steps that we will implement to install WordPress: begin, first create an AWS account if you don't already have one. This will give you access to all the necessary tools and services for deploying WordPress on AWS.

• launch an instance in your AWS account, This will provide the virtual server that will host your WordPress site.

• Connect to the instance

• Execute some commands to install WordPress, With WordPress installed, it's time to configure your site. This includes setting up your database, selecting a theme, and installing any necessary plugins.

• Log in to WordPress

Step 1: launch an instance in your AWS account

  • When logging into the AWS account, we select the EC2 service through Services or through the search box

Image description

  • Click on Launch instance

Image description

Under Name and tags

  • Enter a name to identify your instance, For this tutorial, name the instance (WordPress)

Image description

Under Application and OS Images:

  • From Quick Start, choose an AMI that meets your web server needs
  • Here we choose Ubuntu (which is free tier eligible)

Image description

Under Instance type:

  • Choose the type of instance, here we choose t2.micro (free tier)

Image description

Under Key pair (login):

  • Choose the key pair

Image description
or create new key pair

  • Give a name to the key pair, then click Create key pair

Image description

Under Network settings: under Firewall (security groups)

  • Choose to Create security groups
  • To Allow SSH traffic by clicking on the check box
  • To Allow HTTP traffic from the internet by clicking on the check box

Image description

Leave all other configurations as they are (default settings)

  • In the Summary panel, review your instance configuration and then choose Launch instance.

Image description

Choose View all instances to close the confirmation page and return to the console. Your instance will first be in a Pending state, and will then go into the Running state.

Image description

Step 2: Connect to the instance

  • To connect to your instance, select the instance and choose Connect.

Image description

  • There are many ways to connect to ec2, here we will choose the SSH client to connect.

After selecting the "SSH Client" section, copy and execute the following commands in the terminal as per the following steps:

Image description

  • Open Terminal (here we use Git Bash)

Image description

  • Change the directory with the cd command (change directory), where you have downloaded your pem file(key pair).

  • In this article, the pem file is stored in the downloads folder.

Execute the cd command to change the path to the location of the encryption key
cd Download/

Image description

  • Execute the following commands sequentially

1. Chmod 400 [key pair name].pem

2. ssh -i /path/key-pair-name.pem instance-user-name@instance-public-dns-name

Image description

  • After the command is executed you will be prompted to type “Yes” to continue with the connection

Image description

  • And that’s it! Now we’re logged in to our AWS instance.

Before installing WordPress on an EC2 instance:

  • We get root permission by executing the sudo -i command

Image description
Executing the command "sudo -i" means booting as root on Linux. The main feature of this command is that it gives you full admin (root user) privileges, allowing you to perform commands and operations that require root user privileges.

  • Update the list of online software repositories: to obtain the latest list of packages available for installation and update. This procedure helps to obtain the latest versions and updates for the programs installed on your system. This is done by executing the sudo apt-get update command

Image description

Step 3: Execute some commands to install WordPress

  1. Execute the command: sudo apt install apache2 -y

Installs Apache Web Server (Apache HTTP Server) on Linux using a package manager Software APT (Advanced Packaging Tool) This command assumes that it is running on an APT-based system Ubuntu, Debian, or Linux-derived systems.
Once this command is executed, the system will download and install the Apache web server on your system, and you are all set
To use it to host web pages and web applications on your own server.

Image description
To make sure that the web server has been installed successfully, we go to the EC2 instance and copy the public IPv4 address to any browser. We note that the installation has been completed successfully.

Image description

Image description

  1. Installing php runtime on our ec2 (because WordPress is built on PHP) and a MySQL connector for PHP)

sudo apt install php libapache2-mod-php php-mysql -y

Image description

  1. Install MySQL server for the database, To create and manage databases on our server.

sudo apt install mysql-server -y

Image description

  1. Change our MySQL authentication plugin to a MySQL native password so that we can log in to the MySQL server with a normal password which is what is required in order to install WordPress.

sudo mysql -i

Image description

  1. To change how the root user account (root) in the MySQL database authenticates to the default user root ((localhost). It is assumed that you execute this command when you set up a new database for a WordPress website, for example.

ALTER USER 'root'@localhost IDENTIFIED WITH mysql_native_password BY ‘[any password]';

Our password here is “wordpresspassword

Image description

  1. Create a new database to use with WordPress

create database [Name your database];

The name of the database here is “ wordpressdatabase

Image description

  1. To assign all the privileges on the database to the user:

grant all privileges on [name of database].* to (root)‘root’@localhost;

Image description

Then exit from the MySQL prompt by the exit command or ctrl d from the keyboard.

Now go to install WordPress:

Image description

  • Execute the wget command with the download link that we copied from the web page

wget https://wordpress.org/latest.tar.gz

Image description

  • Then unzip the file that we are downloaded

tar xzf latest.tar.gz

Image description

  • Now use the ls command to show the downloaded file

Image description
-To move the WordPress folder to the document root of Apache, by the command:
sudo mv wordpress/ /var/www/html/

Image description
Enter to the document root of apache /var/www/html/ by change directory command cd

Image description
-use the ls command to show the WordPress file is moving to the root of Apache /var/www/html/

Image description

Go back to the browser and type in our public ipv4 address / wordpress. It will open the WordPress installation screen.

  • Enter the database name, username, and password, then click on Submit

Image description

-It shows us there is an error that it is unable to write to the wp-confige.php file

-To fix this error, copy all the code and go back to the terminal

Image description

-Go to the WordPress directory and create the new file name wp-confige.php by the nano command :

Nano wp-confige.php

Image description

  • And past the code by ctrl u from the keyboard

Image description

-To exit from the file: from the keyboard by ctrl x then y (to save the file) then click enter

Image description

  • Click Run the installation and show then the error is fixed by the following screen appears.

Image description

  • By This screen, give a name to our site, username, and email, here we name the site "WPSite" and the user name “MyWordPress”.

Image description

The WordPress installation is in a success and click on Log in to go to the log in screen.

Image description

  • Enter the username or email and password to log in to the site

Image description

This is our WordPress Dashboard and we can begin our work

Image description

Important note: assign the instance an elastic IP address to be static so anyone can know where our website is hosted, so need the IP address to be static. Note that attaching an elastic IP address is not free, but imposes a certain fee on it.

So, we attach a elastic IP address to the instance before we take the steps to connect to the instance, through the following steps:

On the left side of the instance dashboard, we choose elastic IPs

Image description
-Then click on Allocate Elastic IP address

Image description

• Created successfully
• Choose the IP and click on Action and choose Associate Elastic IP address

Image description

  1. Define the instance type

2 . Choose the instance to which the elastic IP will be attached

3 . Click on Allocate

Image description

The elastic IP address is associated with the instance and will remain unchanged even when the instance is stopped and restarted.

Image description

References:

https://kinsta.com/knowledgebase/what-is-wordpress/

https://www.bluehost.com/blog/what-is-wordpress/

https://wordpress.org/about/

https://www.wpbeginner.com/beginners-guide/what-is-wordpress/

Top comments (0)