I found it tedious trying to change all of my websites (6 in total) to Amazon’s Lightsail Bitnami WordPress box. There are many instructions on how to do this using the WordPress Multisite feature, but not if you actually need individual WordPress installations on the same box.
Anyway, after destroying a couple of boxes because of incorrect configurations I was finally able to develop a process to get myself going and here is that process.
(I’ve assumed from the start you’ve been able to start up an AWS Lightsail Bitnami instance and have successfully SSH’d into it)
Step 1: Download WordPress & Bitnami’s WordPress Module Installer
From inside your shell, download the files needed.
- Download the latest Bitnami WordPress module for Linux:
$ sudo wget https://bitnami.com/redirect/to/1135599/bitnami-wordpress-5.5.3-0-module-linux-x64-installer.run
Step 2: Run Bitnami WordPress Module
We’ll first start with Bitnami doing it’s thing in setting up a new WordPress installation alongside the default
wordpress one in the
- First, make the newly downloaded file executable.
$ sudo chmod +x bitnami-wordpress-5.5.3-0-module-linux-x64-installer.run
2. Before you execute the file, fetch the MySQL password:
$ cat bitnami_application_password
The resulting output will need to be copied and pasted somewhere for use later.
3. Now execute the Bitnami module, changing the name
NEW_WORDPRESS_FOLDER_NAME to a more succinct name for your new WordPress installation.
$ sudo ./bitnami-wordpress-5.5.3-0-module-linux-x64-installer.run --wordpress_instance_name NEW_WORDPRESS_FOLDER_NAME
For example, if I was creating a website called
scripteverything.com maybe I’d like to call the directory where everything will reside
se, therefore my command would look like this:
$ sudo ./bitnami-wordpress-5.5.3-0-module-linux-x64-installer.run --wordpress_instance_name se
Follow through the prompts providing the necessary answers, here were some of my responses:
- Location of Bitnami stack:
- If prompted for an admin username, create one (perhaps use your first and last name as the admin user).
- Paste in the MySQL password from step 2 when prompted.
- Give your blog a name.
- You could enable mail support, but I didn’t.
- Then when you’re almost done it will ask if you’d like to launch the Bitnami stack: Y
4. When the module has finished installing we would like to add our domain to the newly installed directory, this will require the following command:
$ sudo ~/apps/YOUR_NEW_WORDPRESS_FOLDER/bnconfig --appdomain YOUR_DOMAIN_NAME
For example, if I were to continue with the same example previously of using this very domain,
scripteverything.com then I would be running the following:
$ sudo ~/apps/se/bnconfig --appdomain scripteverything.com
This shouldn’t take as long as the first command, but a little patience is required. You could also modify the previous command by running the following if you wanted to disable the Bitnami banner:
$ sudo ~/apps/se/bnconfig --appdomain scripteverything.com --disable_banner 1
Step 3: Create SSL Certificate
Using Cloudflare Free SSL
If you use Cloudflare as your DNS provided, then an easy and free way to get going is to use their SSL service. Simply login to Cloudflare, click on your domain then on the SSL/TLS tile.
Within this area set the mode to Full (Strict), then click on the sub-tab labelled Origin Server and then click on the button labelled Create Certificate.
I’ve left everything as default, so Generate private key and CSR with Cloudflare is selected, I’ve left the domains as listed, and left the Certificate validity option as 15 years.
When you click on the Create button you will be presented with two hashes: one representing a PEM hash, and the other a KEY hash.
Back to your server navigate within your app to the certs folder:
$ cd ~/apps/YOUR_WORDPRESS_DIRECTORY/conf/certs
Then create your first
$ sudo vi server.pem
Copy and paste the first hash in Cloudflare into the editor. You should see the entire contents of the hash on the screen. When you’re happy it’s all there close and save the file. Then do the same for the key:
$ sudo vi server.key
Copy and paste the second hash from Cloudflare into the VIM editor on screen. When you’re happy you’ve copied everything across save and close the file.
As we don’t want to make the KEY file accessible to the outside world we will need to change its permissions. Run the following to make the following permission changes to the
$ sudo 0600 chmod server.key
Lastly, we then need to check our virtual hosts configuration file to check we’re pointing to the correct files.
$ sudo vi ~/apps/YOUR_WORDPRESS_DIRECTORY/conf/httpd-vhosts.conf
In this file you want to check the lines that start with:
Generally I’ve found I’ve only needed to edit the
SSLCertificateFile reference as the file the Apache config looks for ends in
crt whereas ours needs to end in
pem. Once I’ve made the amendment I save the file, and then restart to Apache to make sure everything works.
Step 4: Modify
The last thing you might want to modify is the
wp-config.php file to be
https by default. Simply edit your file and find the line that defines the SITE and append to the
http portion to make it
$ sudo vi ~/apps/YOUR_WORDPRESS_DIRETORY/htdocs/wp-config.php
Find in this file the following lines:
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/'); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');
And then modify them to what I have done below:
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/'); define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');
(I hope you can see the added
http in the new code!)
By navigating to your website’s
https domain you should see a Hello World WordPress theme up. Congratulations, you can now log in with your password (see the
bitnami_application_password at step 1 above).
“But I don’t use Cloudflare?”
If you don’t use Cloudflare there is another free option available to get SSL on your website. It does require a few more little steps, but thankfully the Bitnami stack has helped to automate and help the process along.
Here’s what you would need to do:
Below is the old method not using Cloudflare, kept here for posterity:
Modify httpd-vhosts.conf File
Before running this step you need to comment out the references to the SSL certificates in the httpd-vhosts.conf file. Open this file up and edit:
$ vi ~/apps/YOUR_WORDPRESS_DIRECTORY/conf/httpd-vhosts.conf
The lines you will want to comment out for now will be the following:
# SSLCertificateFile "/opt/bitnami/apps/WP_DIR/conf/certs/server.crt" # SSLCertificateKeyFile "/opt/bitnami/apps/WP_DIR/conf/certs/server.key"
Where WP_DIR is YOUR_WORDPRESS_DIRECTORY and # represents the commenting out of those lines. Save and close the file.
Check DNS Records
One final check before you progress is to ensure that your DNS points to the IP address of your server. You will want the A-record of your domain to point to your IP address and the www CNAME of your website to either similarly point to your IP address or to be redirected to root.
Run Let’s Encrypt
Next we’ll run the
bncert-tool to create an SSL certificate for our new domain:
$ sudo /opt/bitnami/bncert-tool
Here you’ll progress through another series of prompts about the domain you want to register. Read each prompt carefully.
Here were the prompts and my corresponding responses for registering this domain:
|Bitnami HTTPS Configuration Tool – Prompt||My Response|
|Please provide a valid space-separated list of domains for which you wish to configure your web server.|
Domain list :
|The following domains were not included: www.scripteverything.com. Do you want to add them? [Y/n]:||Y|
Please select the redirections you wish to enable or disable on your Bitnami installation.
Enable HTTP to HTTPS redirection [Y/n]:
Enable non-www to www redirection [Y/n]:
|Changes to perform|
The following changes will be performed to your Bitnami installation:
Stop web server
Configure web server to use a free Let's Encrypt certificate for the domains: scripteverything.com www.scripteverything.com
Configure a cron job to automatically renew the certificate each month
Configure web server name to: scripteverything.com
Enable HTTP to HTTPS redirection (example: redirect
http://scripteverything.com to https://scripteverything.com)
Enable www to non-www redirection (example: redirect
www.scripteverything.com to scripteverything.com)
Start web server once all changes have been performed
Do you agree to these changes? [Y/n]:
|Create a free HTTPS certificate with Let's Encrypt|
Please provide a valid e-mail address for which to associate your Let's Encrypt certificate.
Domain list: scripteverything.com www.scripteverything.com
Server name: scripteverything.com
E-mail address :
|I entered my email address|
|The Let's Encrypt Subscriber Agreement can be found at:|
Do you agree to the Let's Encrypt Subscriber Agreement? [Y/n]:
You may get an error at the end of the process stating that your web server failed to start. Go back to your httpd-vhosts.conf file and change the commented lines to point to the newly created certificates.
You can check the certificates have been created by navigating here first:
$ cd /opt/bitnami/apache2/conf
Then check the list of files in this folder and you should see:
$ ls scripteverything.com.crt scripteverything.com.key
This location is now what you need to replace into your httpd-vhosts.conf file.
Once you have successfully created the certificates, you’ll need to modify your app’s Apache configuration to point to these new files:
$ sudo vi ~/apps/YOUR_WORDPRESS_DIRECTORY/conf
Here you’ll see a listing of the files in the
conf directory, using your arrow keys on the keyboard navigate down to the
httpd-vhosts.conf file and hit Enter to open this file up in Vim.
You will need to edit the following lines in the file to point to your newly created SSL files, here are the two lines you need to change, they start with
SSLCertificateFile "/opt/bitnami/apache2/conf/scripteverything.com.crt" SSLCertificateKeyFile "/opt/bitnami/apache2/conf/scripteverything.com.key"
You need to point these files to where the files are located in the
Close the file by saving your edits – in Vim to edit you need to hit the
i key, then when you’ve finished editing hit the Escape key and to save your edits enter
To finally check that everything is working fine you need to restart:
$ sudo /opt/bitnami/ctlscript.sh restart apache
You should then see something like this if everything is okay:
Unmonitored apache Syntax OK /opt/bitnami/apache2/scripts/ctl.sh : httpd stopped Syntax OK /opt/bitnami/apache2/scripts/ctl.sh : httpd started at port 80 Monitored apache
You can then navigate to your URL and you should see a blank WordPress installation!
To login in use your admin username you created above, and use the password you provided, or the MySQL password.
In this article we discovered how to add another WordPress installation to our Bitnami WordPress box, without using the Multisite instance.
You can install as many instances as you wish, and if you ever want to remove an installation simply run the following command:
$ sudo ~/apps/WORDPRESS_FOLDER_NAME/uninstall
This will completely remove all the files in that folder, and when prompted even the data in the MySQL database if desired.