Get Started with Bitnami WordPress on AWS Marketplace (for Intermediate Users)

Introduction

WordPress is one of the most popular blogging platforms in the world, in use on over 60 million websites (according to Wikipedia). It's not hard to understand why: WordPress is incredibly easy to use, comes with thousands of extensions and themes, and is completely free and open source.

If you're looking to create a personal or small business website or blog, the Bitnami WordPress Stack is the quickest and easiest way to get started with WordPress. It comes with a pre-configured, secure and up-to-date installation of WordPress that you can immediately deploy and begin working with.

This guide will assume that you already know the basics of using the Bitnami WordPress Stack and will walk you through more complex tasks, such as connecting to the WordPress MySQL database, installing an SSL certificate, and using a custom domain.

Assumptions and prerequisites

The guide assumes that:

Connect to the WordPress server using SSH

While you can perform many WordPress configuration tasks using the WordPress Dashboard, there are some tasks which can only be performed directly from the AWS server command prompt. Therefore, you should become familiar with connecting to the AWS cloud server using a Secure Shell (SSH) login and executing commands at the console prompt.

You will connect to the server using an SSH client from your Windows, OS X or Linux desktop. As a necessary pre-requisite, you will need the SSH private key (PEM file) that you used to deploy the AWS server.

  • If you're using a Windows desktop, you should download and install PuTTY, a free SSH client for Windows and UNIX platforms.
  • If you're using a Linux or OS X desktop, you can use the SSH client that is already built in to these operating systems.

Windows

By default, your AWS private key would have been delivered as a PEM file. Before you can use this private key with PuTTY, it is necessary to convert it to PuTTY's own PPK key file format. To do this:

  • Launch the PuTTY Key Generator by double-clicking the puttygen.exe file in the PuTTY installation directory.
  • Click the "Load" button and select the AWS private key file in PEM format.

    PuTTY key conversion

  • Once the private key has been imported, click the "Save private key" button to convert and save the key in PuTTY's PPK key file format.

    PuTTY key conversion

You can now connect to the AWS server using PuTTY as follows:

  • Launch PuTTY by double-clicking the putty.exe file in the PuTTY installation directory.
  • In the PuTTY configuration window, enter the host name or public IP address of your server into the "Host Name (or IP address)" field, as well as into the "Saved Sessions" field.
  • Click "Save" to save the new session so you can reuse it later.

    PuTTY session

  • In the "Connection -> SSH -> Auth" section, select the private key file in PPK format.

    PuTTY key selection

  • In the "Connection -> Data" section, enter the username bitnami into the "Auto-login username" field, under the "Login details" section.

    PuTTY username selection

  • In the "Session" section, click on the "Save" button to save the current configuration.
  • Select the saved session and click the "Open" button to open an SSH session to the server.
  • PuTTY will ask you to confirm the server's host key and add it to the cache. Go ahead and click "Yes" to this request.

You should now be logged in to your server and be able to run commands at the server command prompt. Here is an example of what you'll see:

Server console

Linux and OS X

The SSH clients bundled with Linux and Mac OS X can directly work with private keys in PEM format. To connect to the AWS server, follow these steps:

  • Open a new terminal window on your local system (for example, using "Finder -> Applications -> Utilities -> Terminal" in Mac OS X or the Dash in Ubuntu).
  • Set the permissions for your private key file in PEM format to 600 using a command like the one below:

     $ chmod 600 KEYFILE
    
  • Connect to the server using the command below:

     $ ssh -i KEYFILE bitnami@SERVER-IP
    

    Remember to replace KEYFILE in the previous commands with the path to your private key file in PEM format, and SERVER-IP with the public IP address or hostname of your server.

  • Your SSH client might ask you to confirm the server's host key and add it to the cache before connecting. Accept this request by typing or selecting "Yes" (learn more).

You should now be logged in to your server and be able to run commands at the server command prompt. Here is an example of what you'll see:

Server console

Use a custom domain with your WordPress deployment

Up until this point, you would probably have been accessing your WordPress blog or website using the public IP address associated with it. However, if you already have a domain name, it's easy to associate this domain name with your WordPress deployment.

Associate a static IP address with the AWS server

AWS instances are launched with a dynamic IP address by default, which means that the IP address changes every time the server is stopped and restarted. If you wish to use a custom domain with the Bitnami WordPress Stack, you must first add a static IP address (also known as an "elastic IP") to your AWS server.

To configure a static IP address:

  • Log in to the AWS EC2 Console.
  • In the left navigation bar, select the "Network & Security -> Elastic IPs" menu item.
  • Click the "Allocate New Address" button.

    Server console

  • Click "Allocate" in the next screen.

A new static IP address will be generated and will appear in the list of available IP addresses.

Server console

Next:

  • From the "Actions" drop-down menu, select the "Associate Address" menu item.

    Server console

  • In the resulting dialog box, enter the instance ID of your server and click the "Associate" button.

The elastic IP address will now be assigned to your server and will persist even if you shut it down or reboot it.

Update the domain's DNS record with the static IP address

Once you've created and associated a static IP address, update your domain's DNS settings, specifically by adding an A record that points to the static IP address of your cloud server. Log in to your domain name provider's management console and make the necessary changes. Step-by-step instructions for some popular providers are listed below:

Remember that once you make the necessary changes, it can take up to 48 hours for the change to propagate across other DNS servers. You can verify the new DNS record by using the Global DNS Propagation Checker and entering your domain name into the search field.

Once the DNS information has been updated and propagated, entering your domain name into the browser address bar should take you to the Bitnami WordPress Stack on the AWS cloud server.

Update WordPress to use the domain name

The final step is to tell WordPress about the domain name, so that is it correctly used in application URLs. Follow these steps:

  • Log in to the server using SSH.
  • Open the file /opt/bitnami/apps/wordpress/htdocs/wp-config.php in a text editor and find the following lines:

     define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
     define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');
    

    Replace them with the lines below, remembering to replace the DOMAIN placeholder with the actual domain name you wish to use:

     define('WP_SITEURL', 'http://DOMAIN/');
     define('WP_HOME', 'http://DOMAIN/');
    

You should now be able to browse to the specified domain name and see your WordPress blog/website.

Remove the Bitnami badge

By default, the Bitnami WordPress Stack has a Bitnami badge at the bottom left corner of the welcome page.

Clicking this badge displays a page with information about the installed application and links to documentation. While this is useful when you first deploy WordPress and are trying it out, you should remove it once your WordPress blog/site starts receiving "real" visitors.

To remove the Bitnami badge, follow these steps:

NOTE: The steps above only remove the badge. You can still access the Bitnami information page by manually browsing to http://SERVER-IP/bitnami/index.html, where SERVER-IP is the public IP address of your server.

Secure WordPress with a Let's Encrypt SSL certificate

Let's Encrypt is a free Certificate Authority (CA) that issues SSL certificates. You can use these SSL certificates to secure traffic to and from your WordPress blog or website.

Before proceeding, make sure that you have successfully completed the steps to use a custom domain with WordPress and that requesting your domain in your browser correctly displays your WordPress blog or website. Then, follow these steps:

  • Log in to the server using SSH.
  • Create a directory for the Let's Encrypt data by executing these commands:

     $ sudo mkdir -p /opt/bitnami/apps/wordpress/letsencrypt/live
     $ sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/letsencrypt
     $ sudo find /opt/bitnami/apps/wordpress/letsencrypt -type d -exec chmod 0775 {} \;
     $ sudo find /opt/bitnami/apps/wordpress/letsencrypt -type f -exec chmod 0664 {} \;
    
  • Edit the /opt/bitnami/apps/wordpress/htdocs/wp-config.php file in a text editor and add the line below to the end of the file. Save the changes.

     define('WP_ENCRYPT_SSL_CERTIFICATES_DIR_PATH', '/opt/bitnami/apps/wordpress/letsencrypt/live');
    
  • Log in to the WordPress Dashboard using the administrator account (if you're not already logged in).
  • Select the "Plugins -> Add New" option.
  • Type "wp encrypt" in the search box.
  • Install the "WP Encrypt" plugin by clicking the "Install Now" button.

    WP Encrypt installation

  • Once installed, click the "Activate" button to activate the plugin.

    WP Encrypt activation

  • On the "Settings -> WP Encrypt -> Account Settings" page, enter the organization name, country name and country code. These values are required to generate a certificate. Click "Save Changes" to save the settings.

    WP Encrypt account settings

  • Click the "Register Account" button to register an account with Let's Encrypt.

    WP Encrypt account registration

  • Once the account has been successfully registered, click the "Generate Certificate" button to generate the actual certificate.

    WP Encrypt certificate generation

  • Log back in to the server using SSH.
  • Link your SSL certificate and certificate key file to the correct locations by executing the following commands. Remember to replace the DOMAIN placeholder with your actual domain name.

     $ sudo ln -s /opt/bitnami/apps/wordpress/letsencrypt/live/DOMAIN/fullchain.pem /opt/bitnami/apache2/conf/server.crt
     $ sudo ln -s /opt/bitnami/apps/wordpress/letsencrypt/live/DOMAIN/private.pem /opt/bitnami/apache2/conf/server.key
    
  • Edit the /opt/bitnami/apps/wordpress/conf/httpd-prefix.conf file in a text editor and add the following lines to the top of the file:

     RewriteEngine On
     RewriteCond %{HTTPS} !=on
     RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
    
  • Restart the Apache server:

     $ sudo /opt/bitnami/ctlscript.sh restart apache
    

Now, when you browse to your domain, you should automatically be redirected to a secure (HTTPS) page, indicated by the appearance of a padlock icon in the browser address bar. Clicking the padlock icon should display the details of the SSL certificate generated by Let's Encrypt.

WP Encrypt certificate in action

Upload a custom WordPress theme or plugin

There may be occasions when you need to upload one or more files to your WordPress installation. Typically, the need for this will arise if you wish to install a custom theme or plugin, or if you are developing your own theme or plugin.

You can upload custom plugins through the WordPress Dashboard, as described below:

  • Log in to the WordPress Dashboard using the administrator account (if you're not already logged in).
  • Navigate to the "Plugins -> Add New" page and click the "Upload Plugin" button.

    Plugin upload

  • Click the "Browse…" button and select the ZIP file containing the plugin you wish to install.
  • Once the plugin has been uploaded, click the "Install Now" button to install it.

    Plugin installation

  • Activate the new plugin using the "Plugins -> Installed Plugins" page.

You can upload custom themes through the WordPress Dashboard, as described below:

  • Log in to the WordPress Dashboard using the administrator account (if you're not already logged in).
  • Navigate to the "Appearance -> Themes" page and click the "Add New" button.

    Theme selection

  • On the resulting page, click the "Upload Theme" button.

    Theme upload

  • Click the "Browse…" button and select the ZIP file containing the theme you wish to install.

    Theme upload

  • Once the theme has been uploaded, click the "Install Now" button to install it.
  • Activate the new theme using the "Appearance -> Themes" page.

By default, the Bitnami WordPress Stack uses "pretty permalinks", wherein each post is identified by a unique URL containing the year, month, day and human-readable post title, such as http://DOMAIN/2017/08/07/my-first-post. However, you can customize how these URLs are generated, by changing the sequence of items or adding others such as the category name or author name.

To customize the permalink structure, follow these steps

  • Log in to the WordPress Dashboard using the administrator account (if you're not already logged in).
  • Navigate to the "Settings -> Permalinks" page.

    Permalink configuration

  • Select the "Custom Structure" option and edit the format to reflect your requirements. Here's an example of a permalink structure that only include the author name and post title:

    Permalink customization

    You will find a complete list of supported placeholders in the WordPress documentation.

  • Click "Save Changes" to save and activate the new permalink structure.
NOTE: Changes made to permalink structure will also affect previously published posts and pages. To avoid broken links, use a plugin like the Redirection plugin to redirect users from the older, broken URLs to the newer ones.

Transfer files using Secure FTP (SFTP)

There may be occasions when you need to upload a file to the WordPress server, or download a file from it, using an FTP client. Follow these steps:

  • Download and install FileZilla.
  • Launch FileZilla and use the "Edit -> Settings" command to bring up FileZilla's configuration settings.
  • Within the "Connection -> SFTP" section, use the "Add keyfile" command to select the private key file for the server. FileZilla will use this private key to log in to the server.

    SFTP key addition

  • Use the "File -> Site Manager -> New Site" command to bring up the FileZilla Site Manager, where you can set up a connection to your server.
  • Enter your server host name and specify bitnami as the user name.
  • Select "SFTP" as the protocol and "Ask for password" as the logon type.

    SFTP connection

  • Use the "Connect" button to connect to the server and begin an SFTP session. You might need to accept the server key, by clicking "Yes" or "OK" to proceed. You should now be logged into the /home/bitnami directory on the server.
  • Using the file navigator, browse to the correct directory. For example, /opt/bitnami/apps/wordpress/htdocs/ is the default location for the WordPress files.

    Filezilla usage

You can now transfer files by dragging and dropping them from the local server window to the remote server window, or vice-versa.

Manage the WordPress database with phpMyAdmin

One of the most important components of the Bitnami WordPress Stack is its MySQL database. All your pages, posts and comments are stored in the database, together with user credentials, configuration options and other important bits of information.

The Bitnami WordPress Stack includes a Web-based MySQL administration tool named phpMyAdmin. phpMyAdmin provides a point-and-click interface to many common database management tasks, making it easy to work with the WordPress database using your Web browser.

For security reasons, phpMyAdmin is accessible only when using 127.0.0.1 as the hostname. To access it from a remote system, you must create an SSH tunnel that routes requests to the Apache Web server from 127.0.0.1. This implies that you must be able to connect to your server over SSH in order to access it remotely.

NOTE: phpMyAdmin is a powerful database management tool and using it incorrectly could corrupt your WordPress installation. Before making any changes to your database using phpMyAdmin, it is a good idea to back up your WordPress deployment so that you can easily recover it in the event of an error.

Assuming you were able to connect to the server over SSH, you should be able to make some minor changes and access phpMyAdmin following the steps below:

Create an SSH tunnel

Windows

When configuring your SSH session as described in the section on connecting to the WordPress server over SSH, use the "Connection -> SSH -> Tunnels" section to create a secure tunnel by forwarding port 80 on the AWS server to port 8888 on your local Windows system. Click the "Add" button to add the secure tunnel configuration to the session, as shown below:

SSH tunnel creation

After configuring this tunnel, continue connecting as usual.

Linux and OS X

Connect to the server using the following command instead of the one shown in the section on connecting to the WordPress server over SSH:

$ ssh -N -L 8888:127.0.0.1:80 -i KEYFILE bitnami@SERVER-IP

Remember to replace KEYFILE in the previous command with the path to your private key file in PEM format, and SERVER-IP with the public IP address or hostname of your server.

Connect to phpMyAdmin

Once connected with the tunnel active, use your Web browser to browse to the URL http://127.0.0.1:8888/phpmyadmin. Here is an example of what you should see:

phpMyAdmin login

Log in to phpMyAdmin with the username root and the randomly-generated password generated when the server was deployed.

Once logged in, you should be able to access and manage the WordPress MySQL database, which by default is named bitnami_wordpress.

phpMyAdmin usage

Reset the WordPress administrator password with phpMyAdmin

In case you forget the administrator password for the WordPress Dashboard, you can reset it using phpMyAdmin. Follow these steps:

  • Log in to phpMyAdmin.
  • Select the bitnami_wordpress database.
  • Select the "SQL" menu item.
  • In the "Run SQL query" field, enter the following SQL query. Remember to update the NEW-PASSWORD placeholder with the new administrator password.

     UPDATE wp_users SET user_pass=MD5('NEW-PASSWORD') WHERE ID='1';
    
  • Click "Go" to run the query.

Password reset

You should now be able to log in to the WordPress dashboard using the new password.

Change the WordPress administrator username with phpMyAdmin

By default, the Bitnami WordPress Stack set the username for the WordPress administrator account to user. If you wish to change this username, you can do so using phpMyAdmin. Follow these steps:

  • Log in to phpMyAdmin.
  • Select the bitnami_wordpress database.
  • Select the "SQL" menu item.
  • In the "Run SQL query" field, enter the following SQL query. Remember to update the NEW-USERNAME placeholder with the new administrator username you wish to use.

     UPDATE wp_users SET user_login='NEW-USERNAME' WHERE ID='1';
    
  • Click "Go" to run the query.

Username reset

You should now be able to log in to the WordPress dashboard using the new username.

Optimize the WordPress database using phpMyAdmin

As you continue adding to, and deleting content from, your WordPress blog or website, your WordPress database will become fragmented. You can defragment it and thereby gain some improvement in performance by following these steps:

  • Log in to phpMyAdmin.
  • Select the bitnami_wordpress database.
  • Select all the available tables using the "Check all" checkbox.
  • From the available list of operations, select the "Table maintenance -> Optimize table" menu item.

Your tables will now be optimized and phpMyAdmin will display a summary of the results.

Database optimization

If you've worked your way through all the above steps, you should have a good understanding of how to perform more advanced tasks with the Bitnami WordPress Stack. To learn more about the topics in this guide, visit the following links:

aws

Bitnami Documentation