Day 45: Deploy Wordpress website on AWS

Day 45: Deploy Wordpress website on AWS

Over 30% of all websites on the internet use WordPress as their content management system (CMS). It is most often used to run blogs, but it can also be used to run e-commerce sites, message boards, and many other popular things. This guide will show you how to set up a WordPress blog site.

Task-01

As WordPress requires a MySQL database to store its data, create an RDS as you did in Day 44

Go to the Amazon RDS console. Click "Create database".

No alt text provided for this image

Select "MySQL" as the engine type.

No alt text provided for this image

Choose the "Free tier" template for "DB instance class".

No alt text provided for this image

Enter a unique name for the "DB instance identifier".

Set the "Master username" and "Master password" for the database.

No alt text provided for this image

Set the "Virtual Private Cloud (VPC)" and "Subnet group" to create the instance in. Leave the other settings at their default values.

No alt text provided for this image
No alt text provided for this image

Choose 'Default VPC'

No alt text provided for this image
No alt text provided for this image

Click on "create database"

No alt text provided for this image

Database is created.

No alt text provided for this image

To configure this WordPress site, you will create the following resources in AWS:

An Amazon EC2 instance to install and host the WordPress application.

Go to the Amazon EC2 console., Click "Launch Instance", Choose a Linux AMI.

Choose an instance type, such as t2.micro, Choose a VPC and subnet.

Configure security group rules to allow inbound traffic on the appropriate port for the type of database you are using (e.g. port 3306 for MySQL).

No alt text provided for this image


An Amazon RDS for MySQL database to store your WordPress data.

Choose the MySQL database you created, go to the?Connectivity & security?tab in the display and choose the security group listed in?VPC security groups. The console will take you to the security group configured for your database.

No alt text provided for this image

Select the?Inbound rules?tab, then choose the?Edit inbound rules?button to change the rules for your security group.

No alt text provided for this image
No alt text provided for this image

Change the?Type?property to?MYSQL/Aurora, which will update the?Protocol?and?Port range?to the proper values.

Choose the?security group that you used for your EC2 instance.

No alt text provided for this image

SSH into your EC2 instance

No alt text provided for this image

run the following command in your terminal to install a MySQL client to interact with the database.

sudo apt install mysql-client-core-8.8        
No alt text provided for this image

Run the following command in your terminal to connect to your MySQL database. Replace “<user>” and “<password>” with the master username and password you configured when creating your Amazon RDS database. -h is host which is RDS database endpoint.

mysql -h <rds-database-endpoint> -P <port-no> -u <user> -p <password>        


No alt text provided for this image

Finally, create a database user for your WordPress application and give the user permission to access the?wordpress?database.

Run the following commands in your terminal:

CREATE DATABASE wordpress;
CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-pass';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
FLUSH PRIVILEGES;
Exit        

?you should use a better password than wordpress-pass?to secure your database.

No alt text provided for this image

To run WordPress, you need to run a web server on your EC2 instance.

To install Apache on your EC2 instance, run the following command in your terminal:

sudo apt-get install apache2        
No alt text provided for this image

To start the Apache web server, run the following command in your terminal:

systemctl restart apache2        


You can see that your Apache web server is working by browsing public-ip of your ec2 instance.

No alt text provided for this image

Setup the server and post your new Wordpress app.

First, download and uncompressed the software by running the following commands in your terminal:

wget https://wordpress.org/latest.tar.g
tar -xzf latest.tar.gzz        
No alt text provided for this image

you will see a tar file and a directory called?wordpress?with the uncompressed contents using ls command.

No alt text provided for this image

Change the directory to the wordpress directory and create a copy of the default config file using the following commands

open the?wp-config.php?file?

No alt text provided for this image

Edit the database configuration by changing the following lines:

No alt text provided for this image

  1. DB_NAME: your RDS database name
  2. DB_USER: The name of the user you created in the database in the previous steps
  3. DB_PASSWORD: The password for the user you created in the previous steps
  4. DB_HOST: The hostname of the database means your database endpoint

The second configuration section you need to configure is the?Authentication Unique Keys and Salts.

You can replace the entire content in that section with the below content:

define('AUTH_KEY',         '@VZ<pXEL?vb-kiz(Zfp_R9f9|.+T-O/P$Z9|T-q%~|KX@,/(RZk00K{ybHA=6nT6')
define('SECURE_AUTH_KEY',  '12Ip[Ts<IA>Vc+R#_X>i85OjMMRtks-o^E2(,$P[Q=f~Zt:@FrW1r$,` vqs|%@|');
define('LOGGED_IN_KEY',    'o*_:obJ!+wtc8&]QhK}-xEVv+eVD!hFbBzkxKn@}(gK{-{d|l-?9b)8+)tfx8zjl');
define('NONCE_KEY',        'Ue<fX0Z71vg7Y&F+~CqM-G%N~ozMe%?qrp-@|tTVh??zJ4:~Sm,VhTKBE0C7DY(?');
define('AUTH_SALT',        'v.Z^1,QR66F-CDW=t<daxxk-;|M3cC{XzF`rn#l[U]f-fboHZYY/c8nvYU(uM`a]');
define('SECURE_AUTH_SALT', 'Cz$[Mq>)Hc=BSo,&Q%;,r}Eu7!:>nj4N91WeIx|7jp=fc+S64lMXCNj|h&a9Q5[D');
define('LOGGED_IN_SALT',   'Y{[of`B<!<<Za+|YtiMJkd33@a}+I%-0u}EPmAx?hW~$_(( u iuIJ2UQUJIv7(Q');
define('NONCE_SALT',       'g<!-Nhqy2E{X{87!|x{Amg3v:Z%e8d(z3l9x|g-T uB62u4xuw?uyjS_>1Yl]~Kw');;        
No alt text provided for this image

First, install the application dependencies you need for WordPress. In your terminal, run the following command.

sudo apt install php libapache2-mod-php php-mysql -y        
No alt text provided for this image

Copy your WordPress application files into the?/var/www/html?directory used by Apache.

sudo cp -r wordpress/* /var/www/html/        
No alt text provided for this image

Finally, restart the Apache web server

systemctl restart apache2        


Browse "ec2-public-ip/wp-admin/" you should see the WordPress welcome page.


No alt text provided for this image

Thank you for reading!

Divyakant Bariha

1xAWS Certified | DevOps | Git | Github | Docker | Linux | CICD | Terraform | Scripting | AWS

1 年

4-5 time i setup the wordpress and i don't know what the mistake but your post help me , so thanks Amazing work..??

回复
Mohammed Gouse

?? DevOps Engineer | Linux | ?? Docker | Jenkins | Git | Git Hub | Ansible | Terraform | Maven | Grafana | Prometheus

2 年

Your information is valuable

Shubham Londhe

Helping Students and Professionals build their Careers | Experience in DevOps | Python | AWS | PySpark | SQL | NoSQL | 1000+ Learners placed

2 年

Amazing, I recommend everyone to go through this article and do their aws rds + wordpress setup kudos to you Sayali Shewale

要查看或添加评论,请登录

Sayali Shewale的更多文章

  • DevOps Project-3

    DevOps Project-3

    Project Description The project involves hosting a static website using an AWS S3 bucket. Amazon S3 is an object…

    7 条评论
  • DevOps Project-2

    DevOps Project-2

    Project Description The project is about automating the deployment process of a web application using Jenkins and its…

    2 条评论
  • Day 80: DevOps Project-1

    Day 80: DevOps Project-1

    Project Description The project aims to automate the building, testing, and deployment process of a web application…

    4 条评论
  • Day 73 - Setup Grafana on AWS EC2 Instance

    Day 73 - Setup Grafana on AWS EC2 Instance

    Task: Setup grafana in your local environment on AWS EC2. Go to the AWS console and Launch an EC2 instance Open port…

    2 条评论
  • Day 72 - Grafana

    Day 72 - Grafana

    What is Grafana? Grafana is an open-source data visualization and monitoring tool that allows you to query, visualize…

    3 条评论
  • Day 70 - Terraform Modules

    Day 70 - Terraform Modules

    Modules are containers for multiple resources that are used together. A module consists of a collection of .

    2 条评论
  • Day 69 - Meta-Arguments in Terraform

    Day 69 - Meta-Arguments in Terraform

    When you define a resource block in Terraform, by default, this specifies one resource that will be created. To manage…

    1 条评论
  • Day 68 - Scaling with Terraform

    Day 68 - Scaling with Terraform

    Understanding Scaling Scaling is the process of adding or removing resources to match the changing demands of your…

  • Day 67: AWS S3 Bucket Creation and Management using terraform

    Day 67: AWS S3 Bucket Creation and Management using terraform

    AWS S3 Bucket Amazon S3 (Simple Storage Service) is an object storage service that offers industry-leading scalability,…

    1 条评论
  • Day 66 - Terraform Hands-on Project - Build Your Own AWS Infrastructure with Ease using Infrastructure as Code (IaC)

    Day 66 - Terraform Hands-on Project - Build Your Own AWS Infrastructure with Ease using Infrastructure as Code (IaC)

    Task: 1.Create a VPC (Virtual Private Cloud) with CIDR block 10.

    3 条评论

社区洞察

其他会员也浏览了