Day 45 Task: Deploy Wordpress website on AWS

Day 45 Task: Deploy Wordpress website on AWS

ยท

3 min read

Table of contents

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 on Day 44**
    Login to the Aws console and go to RDS to create a database.**

    Name your database.

    Created database.

  • Now create an instance for WordPress.

    Now connect your instance and update the system then install MySQL
    sudo apt install mysql-client
    mysql -h <endpoint-name> -P <port-name> -u <username> -p

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

Check whether your database was created or not

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

  • An Amazon EC2 instance to install and host the WordPress application.
    Now install Apache on your EC2 instance for WordPress run.
    use
    sudo apt-get install apache2

    Check whether your instance ip apache web server is working or not.

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

  • Set up the server and post your new WordPress app.
    Now Download and uncompress the software by using the below commands.

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

    Now extract the tar file.

        tar -xvzf latest.tar.gz
    

    Now change the directory and copy the default configuration file

        cd wordpress
        cp wp-config-sample.php wp-config.php
    
  • Now edit the wp-config.php file

  • Open the wp-config.php file

    • DB_NAME: your RDS database name

    • DB_USER: The name of the user you created in the database in the previous steps

    • DB_PASSWORD: The password for the user you created in the previous steps

    • DB_HOST: The hostname of the database means your database endpoint

      vim wp-config.php

To configure the Authentication Unique Keys and Salts section in the WordPress wp-config.php file, you can replace the entire content in that section with the following content:

      define('AUTH_KEY',         'N[D)?+J-}Wx<c*jX$AuW!pz>2{M[>_YT- 7tY`aT3y;*F! _LeM}Kj[t4o2v3qMm');
      define('SECURE_AUTH_KEY',  '9+>M!va% jq|B|f>kc9saFwE-cS|9-4B$xGu+2pI&3yis%-zzka =TAxq]+.Q7Fp');
      define('LOGGED_IN_KEY',    '>s4a)kHXSc(~i|$/P}SgvJPBiFp+tET.xdaW4Y%3mR~#P6;GK B)oADegQK#u)gV');
      define('NONCE_KEY',        'W-3_,k/oZcX.Mg6![$epnW@r/@z*9B@P=p#=mSIF-R9Z9X.Q+2-[+%L`]qBOQ++h');
      define('AUTH_SALT',        '<UFNBNl<x:%EuS#K+p-__>[EtE-tea]xP6-i_wz$8[%uU>>ia2_]z)-`MA}i,T8q');
      define('SECURE_AUTH_SALT', 'I`|%6X&* 0I-W%^^NlHN^{jg6`J;[^h))&?-R4&OfyF!U_^hh?P@+-:iqdgeI%AJ');
      define('LOGGED_IN_SALT',   'g96e[e61f|BG MUHkk~]Yoy%lyVHvS)5CAEjJ3]#^?ZB@~y2R<a/OM0d&ezwv.FN');
      define('NONCE_SALT',       ',FI>G~/$`NFqoAO?U~Lsw[Ko{ubrN&-]N$HT4s+U4<s0W(v9]f(bn1r_`OjV#LMH');

Deploy the WordPress site and install dependencies.

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

Copy the WordPress file to the Apache root directory.

      cd ..
      sudo cp -r wordpress/* /var/www/html/
      sudo systemctl restart apache2

      #Check your wordpress wedsite is working or not
      http://<public-ip>/wp-admin
      http://3.86.95.61/wp-adm  #Check your wordpress wedsite is working or not
  • Happy Learning :)

    If you find my blog valuable, I invite you to like, share, and join the discussion. Your feedback is immensely cherished as it fuels continuous improvement. Let's embark on this transformative DevOps adventure together! ๐Ÿš€ #devops #90daysofdevop #AWS

ย