To this point, you have done a lot of configuration setup. You created an RDS instance and an EC2 instance. You allowed network access from your EC2 instance to your RDS instance. You learned how to SSH into your EC2 instance and configured a database user to be used by WordPress.

In this module, you will finish up the work to make your WordPress site live. You will install the WordPress application and dependencies on the EC2 instance. At the end of this module, you will have a WordPress installation that is accessible in the browser from anywhere in the world.

To complete the steps in this module, you will need to SSH into your EC2 instance. Please review the steps in the previous module if you need to reconnect to your EC2 instance via SSH.

Time to Complete Module: 15 Minutes

  • Step 1: Installing the Apache web serverUpdating an item

    To run WordPress, you need to run a web server on your EC2 instance. The open source Apache web server is the most popular web server used with WordPress.

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

    sudo yum install -y httpd

    You should see some terminal output of the necessary packages being installed.

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

    sudo service httpd start

    You can see that your Apache web server is working and that your security groups are configured correctly by visiting the public DNS of your EC2 instance in your browser.

    Go to the EC2 Instances page and find your instance. In the Description below, find the Public DNS (IPv4) of your instance. 


    (Click to enlarge)


    Enter this value into your web browser, and you should see an Apache test page.


    (Click to enlarge)


    Now that your Apache web server is working, it’s time to download and configure WordPress.

  • Step 2: Download and Configure WordPress

    In this step, you will download the WordPress software and set up the configuration.

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

    tar -xzf latest.tar.gz

    If you run “ls” to view the contents of your directory, you will see a tar file and a directory called wordpress with the uncompressed contents.

    $ ls
    latest.tar.gz  wordpress

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

    cd wordpress
    cp wp-config-sample.php wp-config.php

    Then, open the wp-config.php file using the nano editor by running the following command.

    nano wp-config.php

    You need to edit two areas of configuration.

    First, edit the database configuration by changing the following lines:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define( 'DB_NAME', 'database_name_here' );
    /** MySQL database username */
    define( 'DB_USER', 'username_here' );
    /** MySQL database password */
    define( 'DB_PASSWORD', 'password_here' );
    /** MySQL hostname */
    define( 'DB_HOST', 'localhost' );

    The values should be:

    DB_NAME: “wordpress”

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

    DB_PASSWORD: The password for the user you created in the previous module.

    DB_HOST: The hostname of the database that you found in the previous module.

    The second configuration section you need to configure is the Authentication Unique Keys and Salts. It looks as follows in the configuration file:

     * Authentication Unique Keys and Salts.
     * Change these to different unique phrases!
     * You can generate these using the {@link secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     * @since 2.6.0
    define( 'AUTH_KEY',         'put your unique phrase here' );
    define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
    define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
    define( 'NONCE_KEY',        'put your unique phrase here' );
    define( 'AUTH_SALT',        'put your unique phrase here' );
    define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
    define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
    define( 'NONCE_SALT',       'put your unique phrase here' );

    Go to this link to generate values for this configuration section. You can replace the entire content in that section with the content from the link.

    You can save and exit from nano by entering CTRL + O followed by CTRL + X.

    With the configuration updated, you are almost ready to deploy your WordPress site. In the next step, you will make your WordPress site live.

  • Step 3: Deploying WordPress

    In this step, you will make your Apache web server handle requests for WordPress.

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

    sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

    Second, change to the proper directory by running the following command:

    cd /home/ec2-user

    Then, copy your WordPress application files into the /var/www/html directory used by Apache.

    sudo cp -r wordpress/* /var/www/html/

    Finally, restart the Apache web server to pick up the changes.

    sudo service httpd restart

    You should see the WordPress welcome page and the five-minute installation process.


    (Click to enlarge)


    That’s it. You have a live, publicly-accessible WordPress installation using a fully-managed MySQL database on Amazon RDS.

    In the next module, you will clean up your resources and see some next steps for your WordPress installation.