Bobcares

Deploy WordPress on Elastic Beanstalk 

by | Sep 25, 2022

Let us take a closer look at how to deploy wordpress on elastic beanstalk with the support of our WordPress support services at Bobcares.

 

How to install WordPress on AWS Elastic Beanstalk?

Deploy WordPress on Elastic Beanstalk 

What Is AWS Elastic Beanstalk? Amazon Web Services (AWS) is a massive public cloud that provides a wide range of cloud computing services, each of which is designed to complete distinct tasks.

 

AWS Elastic Beanstalk is one of them; it is designed to swiftly install apps in the AWS Cloud, which is less complicated than dealing with ordinary cloud computing stuff. AWS Elastic Beanstalk can be used with fewer restrictions and more control.

 

We may upload apps such as WordPress to Elastic Beanstalk to execute them efficiently and scalably. Another advantage of adopting Beanstalk is that it decreases administrative work by automating application monitoring and handling other elements like storage load balancing and scaling.           

 

When building or developing an app, the platforms on which one can install his codes are Go, Java,.NET, Node.js, PHP, Python, and Ruby. Docker is also an alternative.

 

Aside from the AWS Management Console, the application can be managed or installed using the AWS Command Line Interface (AWS CLI) or eb, a high-level CLI created exclusively for Elastic Beanstalk.

 

Here we are specifically talking about WordPress installation on AWS Elastic Beanstalk.

 

Set Up a Highly Available WordPress Site Using Elastic Beanstalk + RDS

The installation process necessitates piecing together pages of AWS documentation as well as hundreds of Stack Overflow ideas. To save time, use the procedures below to create a highly available WordPress site on AWS.

 

Set up Elastic Beanstalk

To setup the Elastic Beanstalk follows the steps given below:

  1. Using this link, we can launch an EBS app: https://console.aws.amazon.com/elasticbeanstalk/home#/newApplication?environmentType=LoadBalanced.
     
  2. We can enter any necessary value for the fields such as Application name, Environment name, and Domain (option to leave blank).
     
  3. Choose PHP as the platform. At the time of writing, PHP 8.0 running on 64bit Amazon Linux 2 is the recommended and supported choice for Platform Branch. Continue to use the Platform Version as the recommended version.
     
  4. Leave Sample Application chosen for the Application code.
     
  5. Select Review and Launch.  
  6. Examine the remaining EBS alternatives.
     
  7. Select the Create app.
     
  8. After we have built the environment, Increase the type of instance. This option can always be changed afterward. Change the Scaling Triggers section to reflect the following:
     

    Metric: CPUUtilization
    Statistic: Average
    Unit: Percent
    Period: 1 Min
    Breach duration: 1 Min
    Upper threshold: 10 Percent
    Scale up increment: 3 EC2 instances
    Lower threshold: 1 Percent
    Scale down increment: -1 EC2 instances

     
  9. Set the Memory limit to 2G in the Software options.
     
  10. Change the settings for Rolling updates and deployments. Change the Deployment policy to Rolling at the very least, and the Rolling update type to Rolling based on Health.
 

Set up RDS

We have to set up the RDS to deploy wordpress on the elastic beanstalk. Follow the steps given below to set up the RDS:

  1. Launch a database using this link: https://console.aws.amazon.com/rds/home#launch-dbinstance:gdb=false;s3-import=false.
     
  2. Select Amazon Aurora as the Engine type (Edition: Amazon Aurora with MySQL compatibility).
     
  3. In the DB cluster identification setting, enter a name for the database.
     
  4. Edit the master username and password, and always make a note of the configuration settings for future configurations.
     
  5. Change the DB instance class size to one that can handle the workload.
     
  6. Select Create an Aurora Replica or Reader node in a different AZ under Multi-AZ deployment.
     
  7. Expand Additional configuration and enter the name of the initial database.
  8. Select Create database.
 

Set up RDS

The next most vital step in deploy wordpress on elastic beanstalk:

 

1. Download and unzip the most recent version of WordPress.

 

~$ curl https://wordpress.org/wordpress-4.9.5.tar.gz -o wordpress.tar.gz
~$ tar -xvf wordpress.tar.gz
~$ mv wordpress wordpress-beanstalk
~$ cd wordpress-beanstalk

 

2. Make a WordPress-specific Nginx configuration file.

 

(from the root wordpress-beanstalk directory)
~$ nano .platform/nginx/conf.d/elasticbeanstalk/nginx.confPaste in the following content:location = /favicon.ico {
log_not_found off;
access_log off;
}location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}

 

3. Thirdly we have to set up the wp-config.php file. To set this up type in the following command:

 

(from the root wordpress-beanstalk directory)
~$ nano wp-config.phpPaste in the following content:?php
define('DB_NAME', $_SERVER['RDS_DB_NAME']);
define('DB_USER', $_SERVER['RDS_USERNAME']);
define('DB_PASSWORD', $_SERVER['RDS_PASSWORD']);
define('DB_HOST', $_SERVER['RDS_HOSTNAME'] . ':' . $_SERVER['RDS_PORT']);
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
define('AUTH_KEY', $_SERVER['AUTH_KEY']);
define('SECURE_AUTH_KEY', $_SERVER['SECURE_AUTH_KEY']);
define('LOGGED_IN_KEY', $_SERVER['LOGGED_IN_KEY']);
define('NONCE_KEY', $_SERVER['NONCE_KEY']);
define('AUTH_SALT', $_SERVER['AUTH_SALT']);
define('SECURE_AUTH_SALT', $_SERVER['SECURE_AUTH_SALT']);
define('LOGGED_IN_SALT', $_SERVER['LOGGED_IN_SALT']);
define('NONCE_SALT', $_SERVER['NONCE_SALT']);
$table_prefix = 'wp_';
define('WP_DEBUG', false);
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');

 

4. Include the following in the.gitignore file.

 

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/config.yml
!.elasticbeanstalk/*.global.yml

 

Connect RDS DB to EBS

  1. Firstly, find the EBS environment we created previously.
     
  2. Select Configuration from the left sidebar, then Edit from the Software category.
     
  3. In the Environment properties section, define the variables shown below:
     

    To discover the required values, go to the RDS cluster we previously made (https://console.aws.amazon.com/rds/home -> pick DB Instances -> select the cluster one level higher than the reader and writer we generated).

     

    RDS_HOSTNAME - On the Connectivity & security tab, copy the "Writer" EndpointRDS_PORT
    - On the Connectivity & security tab, copy the "Writer" PortRDS_DB_NAME
    - On the Configuration tab, copy the DB NameRDS_USERNAME
    - On the Configuration tab, copy the Master usernameRDS_PASSWORD
    - Cannot be copied from the RDS Console. We have made a note of this password when launching the database. To generate the following:AUTH_KEY
    SECURE_AUTH_KEY
    LOGGED_IN_KEY
    NONCE_KEY
    AUTH_SALT
    SECURE_AUTH_SALT
    LOGGED_IN_SALT
    NONCE_SALT

 

Launch the WordPress repository on EBS

After all of the configurations on the WordPress installation, we have successfully set up the WordPress site.

 

Prerequisite —If we haven’t previously, install the EB CLI.

  • From the local repository, we can set it up, in the terminal, run eb init.
     
  • Choose the region where the EBS environment is located in the first “Select a default region” step.
     
  • Select the application you generated in the preceding steps in the “Select an application to utilize” phase.
     
  • Enter no in the “Do you want to continue with CodeCommit?” step.
     
  • Execute eb deploy.

This is the final step in the configuration process.

 

[Need assistance with similar queries? We are here to help]

 

Conclusion

To conclude were have learned how to deploy wordpress on elastic beanstalk by setting up the RDS and WordPress installation configurations with the assistance of our WordPress support services.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

     

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.