Project – Create an AWS Lightsail instance with WordPress site

Create an Ubuntu server instance on AWS Lightsail

We start by creating an AWS instance.

On the next section, create a SSH Key Pair. We’ll need this to access the instance via SSH over the internet. Save the SSH Key Pair created on your computer.

Select the following parameters for the instance being launched.

  • Instance location: Singapore (ap-southeast-1)
  • Instance image: Ubuntu 16.04 LTS (OS Only)
  • SSH key pair: select the new key pair you’ve just created
  • Instance plan: 512MB, 1vCPU, 20GB SSD should suffice for now (we’ll see if we need to upgrade in the future or separate the wordpress site from the unifi controller)
  • Instance name: “Ubuntu 16.04-WP-Unifi”
  • Create instance

In a few moments we should see the instance in “running” state.

Configure Static IP and DNS Zone for AWS Lightsail

Go to the “Networking” section and start by creating a static IP for our running instance.

Attach the created static IP to your instance.

Go back to “Home” and on the “Networking” section tab “Create DNS Zone”

Enter the domain you have registered and proceed by clicking “Create DNS Zone”

On the DNS records, “Add record”.

Place “@” on the Subdomain section and then select the static IP created.

Add 1 more DNS records (CNAME record), which resolves to wheresmypacket.com

  • Subdomain
    • www.wheresmypacket.com
  • Maps to
    • wheresmypacket.com

Take note of the “Name servers” created for the DNS record.

Update AWS Route 53 NS list

Go to your AWS Route 53 console and click on the registered domain we’d want to associate with our AWS Lightsail instance.

Click on the “Add or edit name servers” and update the values from what we got on our AWS Lightsail DNS zone.

Testing DNS and instance access

Let’s test if our DNS configurations have taken effect (might take some time).

Test SSH to server via web browser

Test SSH access via putty/puttygen.

Open Puttygen.

Load an existing private key file.

Select the *.pem file we have previously download when we first created the AWS Lightsail instance.

Save the generated private key.

Open Putty and connect to our AWS Lightsail instance.

Under “Connection-SSH-Auth”, select the private key file generated via PuttyGen.

Hit “Yes” on the Putty key prompt, then login using username “ubuntu” (default for Ubuntu server).

Install WordPress on Ubuntu server
Step 1: Update the system via “apt-get update”

login as: ubuntu
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-1052-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    https://www.ubuntu.com/business/services/cloud

106 packages can be updated.
1 update is a security update.


*** System restart required ***
Last login: Fri May 31 17:05:33 2019 from 54.240.199.41
ubuntu@ip-172-26-5-115:~$ sudo su
root@ip-172-26-5-115:/home/ubuntu#
root@ip-172-26-5-115:/home/ubuntu# apt-get update

Step 2: Install LAMP stack using the command “apt-get install lamp-server^”

root@ip-172-26-5-115:/home/ubuntu#
root@ip-172-26-5-115:/home/ubuntu# apt-get install lamp-server^

During the installation, you’ll be prompted to enter a password for the MySQL “root” user.

Step 3: Create a database for our WordPress

root@ip-172-26-5-115:/home/ubuntu# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> CREATE DATABASE wordpressdb;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER wordpressuser@localhost IDENTIFIED BY 'wordpresspassword';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
root@ip-172-26-5-115:/home/ubuntu#

Step 4: Download and unzip wordpress

root@ip-172-26-5-115:/home/ubuntu# cd /tmp
root@ip-172-26-5-115:/tmp#
root@ip-172-26-8-252:/tmp# wget https://wordpress.org/latest.zip
--2019-06-11 14:56:38--  https://wordpress.org/latest.zip
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://wordpress.org/latest.zip [following]
--2019-06-11 14:56:38--  https://wordpress.org/latest.zip
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12119857 (12M) [application/zip]
Saving to: ‘latest.zip’

latest.zip                    100%[================================================>]  11.56M  3.57MB/s    in 4.3s

2019-06-11 14:56:44 (2.67 MB/s) - ‘latest.zip’ saved [12119857/12119857]

root@ip-172-26-8-252:/tmp#
root@ip-172-26-8-252:/tmp# apt-get install unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  zip
The following NEW packages will be installed:
  unzip
0 upgraded, 1 newly installed, 0 to remove and 184 not upgraded.
Need to get 158 kB of archives.
After this operation, 530 kB of additional disk space will be used.
Get:1 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main amd64 unzip amd64 6.0-20ubuntu1 [158 kB]
Fetched 158 kB in 0s (13.4 MB/s)
Selecting previously unselected package unzip.
(Reading database ... 52507 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-20ubuntu1_amd64.deb ...
Unpacking unzip (6.0-20ubuntu1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up unzip (6.0-20ubuntu1) ...
root@ip-172-26-8-252:/tmp#
root@ip-172-26-5-115:/tmp#
root@ip-172-26-5-115:/tmp# unzip -q latest.zip -d /var/www/html/
root@ip-172-26-5-115:/tmp#
root@ip-172-26-5-115:/tmp# cd /var/www/html/
root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-5-115:/var/www/html# ls
index.html  wordpress
root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-5-115:/var/www/html# rm index.html
root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-8-252:/var/www/html# mv -v /var/www/html/wordpress/* /var/www/html
'/var/www/html/wordpress/index.php' -> '/var/www/html/index.php'
'/var/www/html/wordpress/license.txt' -> '/var/www/html/license.txt'
'/var/www/html/wordpress/readme.html' -> '/var/www/html/readme.html'
'/var/www/html/wordpress/wp-activate.php' -> '/var/www/html/wp-activate.php'
'/var/www/html/wordpress/wp-admin' -> '/var/www/html/wp-admin'
'/var/www/html/wordpress/wp-blog-header.php' -> '/var/www/html/wp-blog-header.php'
'/var/www/html/wordpress/wp-comments-post.php' -> '/var/www/html/wp-comments-post.php'
'/var/www/html/wordpress/wp-config-sample.php' -> '/var/www/html/wp-config-sample.php'
'/var/www/html/wordpress/wp-content' -> '/var/www/html/wp-content'
'/var/www/html/wordpress/wp-cron.php' -> '/var/www/html/wp-cron.php'
'/var/www/html/wordpress/wp-includes' -> '/var/www/html/wp-includes'
'/var/www/html/wordpress/wp-links-opml.php' -> '/var/www/html/wp-links-opml.php'
'/var/www/html/wordpress/wp-load.php' -> '/var/www/html/wp-load.php'
'/var/www/html/wordpress/wp-login.php' -> '/var/www/html/wp-login.php'
'/var/www/html/wordpress/wp-mail.php' -> '/var/www/html/wp-mail.php'
'/var/www/html/wordpress/wp-settings.php' -> '/var/www/html/wp-settings.php'
'/var/www/html/wordpress/wp-signup.php' -> '/var/www/html/wp-signup.php'
'/var/www/html/wordpress/wp-trackback.php' -> '/var/www/html/wp-trackback.php'
'/var/www/html/wordpress/xmlrpc.php' -> '/var/www/html/xmlrpc.php'
root@ip-172-26-8-252:/var/www/html#
root@ip-172-26-5-115:/var/www/html# rm -r wordpress
root@ip-172-26-5-115:/var/www/html# ls
index.php    wp-activate.php     wp-comments-post.php  wp-cron.php        wp-load.php   wp-settings.php   xmlrpc.php
license.txt  wp-admin            wp-config-sample.php  wp-includes        wp-login.php  wp-signup.php
readme.html  wp-blog-header.php  wp-content            wp-links-opml.php  wp-mail.php   wp-trackback.php
root@ip-172-26-5-115:/var/www/html# clear
root@ip-172-26-5-115:/var/www/html# rm -r wordpress
rm: cannot remove 'wordpress': No such file or directory
root@ip-172-26-5-115:/var/www/html#

Step 5: Update the folder permissions, then restart the apache server.

root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-5-115:/var/www/html# chown -R www-data:www-data /var/www/html/
root@ip-172-26-5-115:/var/www/html# chmod -R 755 /var/www/html/
root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-5-115:/var/www/html# mkdir -p /var/www/html/wp-content/uploads
root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-5-115:/var/www/html# chown -R www-data:www-data /var/www/html/wp-content/uploads
root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-5-115:/var/www/html#
root@ip-172-26-5-115:/var/www/html# service apache2 restart
root@ip-172-26-5-115:/var/www/html#

Step 6: Access the WordPress site.

Enter the database details for database name, username, and password.

Step 7: Log into the WordPress Dashboard.

Install SSL certificate using Let's Encrypt (auto-renew via certbot)

Step 1: Install Certbot Client

wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto
login as: ubuntu
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-1052-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    https://www.ubuntu.com/business/services/cloud

116 packages can be updated.
18 updates are security updates.


*** System restart required ***
Last login: Wed Jun  5 13:40:12 2019 from 124.104.231.154
ubuntu@ip-172-26-5-115:~$
ubuntu@ip-172-26-5-115:~$
ubuntu@ip-172-26-5-115:~$ sudo su
root@ip-172-26-5-115:/home/ubuntu# wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto
--2019-06-06 15:57:14--  https://dl.eff.org/certbot-auto
Resolving dl.eff.org (dl.eff.org)... 151.101.8.201, 2a04:4e42:2::201
Connecting to dl.eff.org (dl.eff.org)|151.101.8.201|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 68023 (66K) [application/octet-stream]
Saving to: ‘certbot-auto’

certbot-auto                   100%[===================================================>]  66.43K  --.-KB/s    in 0.002s

2019-06-06 15:57:14 (36.0 MB/s) - ‘certbot-auto’ saved [68023/68023]

root@ip-172-26-5-115:/home/ubuntu#

Step 2: Generate Certificates

./certbot-auto certonly --webroot -w /var/www/html/ -d wheresmypacket.com -d www.wheresmypacket.com
root@ip-172-26-5-115:/home/ubuntu# ls
certbot-auto
root@ip-172-26-5-115:/home/ubuntu# ./certbot-auto certonly --webroot -w /var/www/html/ -d wheresmypacket.com -d www.wheresmypacket.com
Bootstrapping dependencies for Debian-based OSes... (you can skip this with --no-bootstrap)
Hit:1 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Hit:3 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:4 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main Sources [336 kB]
Get:5 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [966 kB]
Get:6 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [384 kB]
Get:7 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [750 kB]
Get:8 https://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Get:9 https://security.ubuntu.com/ubuntu xenial-security/main Sources [149 kB]
Get:10 https://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [669 kB]
Get:11 https://security.ubuntu.com/ubuntu xenial-security/main Translation-en [270 kB]
Get:12 https://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [438 kB]
Fetched 4,180 kB in 3s (1,218 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssl is already the newest version (1.0.2g-1ubuntu4.15).
The following additional packages will be installed:
  binutils cpp cpp-5 gcc-5 gcc-5-base libasan2 libatomic1 libc-dev-bin libc6 libc6-dev libcc1-0 libcilkrts5 libexpat1-dev libgcc-5-dev
  libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0 libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev libpython2.7-minimal
  libpython2.7-stdlib libquadmath0 libstdc++6 libtsan0 libubsan0 linux-libc-dev python-minimal python-pip-whl python-pkg-resources
  python2.7 python2.7-dev python2.7-minimal python3-virtualenv zlib1g-dev
Suggested packages:
  augeas-doc binutils-doc cpp-doc gcc-5-locales gcc-multilib make manpages-dev autoconf automake libtool flex bison gdb gcc-doc
  gcc-5-multilib gcc-5-doc libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg
  libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg augeas-tools glibc-doc python-doc python-tk python-setuptools python2.7-doc binfmt-support
Recommended packages:
  manpages-dev libssl-doc
The following NEW packages will be installed:
  augeas-lenses binutils cpp cpp-5 gcc gcc-5 libasan2 libatomic1 libaugeas0 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libexpat1-dev
  libffi-dev libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0 libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev
  libpython2.7-minimal libpython2.7-stdlib libquadmath0 libssl-dev libtsan0 libubsan0 linux-libc-dev python python-dev python-minimal
  python-pip-whl python-pkg-resources python-virtualenv python2.7 python2.7-dev python2.7-minimal python3-virtualenv virtualenv zlib1g-dev
The following packages will be upgraded:
  ca-certificates gcc-5-base libc6 libstdc++6
4 upgraded, 45 newly installed, 0 to remove and 105 not upgraded.
Need to get 65.0 MB of archives.
After this operation, 171 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.4 [339 kB]
Get:2 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1ubuntu0~16.04.4 [1,261 kB]
Get:3 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-minimal amd64 2.7.12-1~16.04 [28.1 kB]
Get:4 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6 amd64 2.23-0ubuntu11 [2,577 kB]
Get:5 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1ubuntu0~16.04.4 [1,880 kB]
Get:6 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1ubuntu0~16.04.4 [224 kB]
Get:7 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython-stdlib amd64 2.7.12-1~16.04 [7,768 B]
Get:8 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 python amd64 2.7.12-1~16.04 [137 kB]
Get:9 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB]
Get:10 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5-base amd64 5.4.0-6ubuntu1~16.04.11 [17.3 kB]
Get:11 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libstdc++6 amd64 5.4.0-6ubuntu1~16.04.11 [393 kB]
Get:12 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 ca-certificates all 20170717~16.04.2 [167 kB]
Get:13 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 augeas-lenses all 1.4.0-0ubuntu1.1 [263 kB]
Get:14 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.8 [2,312 kB]
Get:15 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB]
Get:16 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.11 [7,660 kB]
Get:17 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main amd64 cpp amd64 4:5.3.1-1ubuntu1 [27.7 kB]
Get:18 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcc1-0 amd64 5.4.0-6ubuntu1~16.04.11 [38.8 kB]
Get:19 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgomp1 amd64 5.4.0-6ubuntu1~16.04.11 [55.0 kB]
Get:20 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libitm1 amd64 5.4.0-6ubuntu1~16.04.11 [27.4 kB]
Get:21 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libatomic1 amd64 5.4.0-6ubuntu1~16.04.11 [8,896 B]
Get:22 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasan2 amd64 5.4.0-6ubuntu1~16.04.11 [264 kB]
Get:23 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblsan0 amd64 5.4.0-6ubuntu1~16.04.11 [105 kB]
Get:24 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtsan0 amd64 5.4.0-6ubuntu1~16.04.11 [244 kB]
Get:25 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libubsan0 amd64 5.4.0-6ubuntu1~16.04.11 [95.4 kB]
Get:26 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcilkrts5 amd64 5.4.0-6ubuntu1~16.04.11 [40.1 kB]
Get:27 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libmpx0 amd64 5.4.0-6ubuntu1~16.04.11 [9,748 B]
Get:28 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libquadmath0 amd64 5.4.0-6ubuntu1~16.04.11 [131 kB]
Get:29 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.11 [2,229 kB]
Get:30 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5 amd64 5.4.0-6ubuntu1~16.04.11 [8,417 kB]
Get:31 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main amd64 gcc amd64 4:5.3.1-1ubuntu1 [5,244 B]
Get:32 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libaugeas0 amd64 1.4.0-0ubuntu1.1 [154 kB]
Get:33 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu11 [68.5 kB]
Get:34 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-libc-dev amd64 4.4.0-150.176 [863 kB]
Get:35 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu11 [2,086 kB]
Get:36 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libexpat1-dev amd64 2.1.0-7ubuntu0.16.04.3 [115 kB]
Get:37 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7 amd64 2.7.12-1ubuntu0~16.04.4 [1,071 kB]
Get:38 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-dev amd64 2.7.12-1ubuntu0~16.04.4 [27.8 MB]
Get:39 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython-dev amd64 2.7.12-1~16.04 [7,840 B]
Get:40 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.1 [168 kB]
Get:41 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-dev amd64 1.0.2g-1ubuntu4.15 [1,344 kB]
Get:42 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7-dev amd64 2.7.12-1ubuntu0~16.04.4 [276 kB]
Get:43 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-dev amd64 2.7.12-1~16.04 [1,186 B]
Get:44 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python-pip-whl all 8.1.1-2ubuntu0.4 [1,110 kB]
Get:45 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main amd64 python-pkg-resources all 20.7.0-1 [108 kB]
Get:46 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python-virtualenv all 15.0.1+ds-3ubuntu1 [46.6 kB]
Get:47 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python3-virtualenv all 15.0.1+ds-3ubuntu1 [43.2 kB]
Get:48 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 virtualenv all 15.0.1+ds-3ubuntu1 [4,342 B]
Get:49 https://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/main amd64 libffi-dev amd64 3.2.1-4 [161 kB]
Fetched 65.0 MB in 1s (37.5 MB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database ... 77686 files and directories currently installed.)
Preparing to unpack .../libpython2.7-minimal_2.7.12-1ubuntu0~16.04.4_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../python2.7-minimal_2.7.12-1ubuntu0~16.04.4_amd64.deb ...
Unpacking python2.7-minimal (2.7.12-1ubuntu0~16.04.4) ...
Selecting previously unselected package python-minimal.
Preparing to unpack .../python-minimal_2.7.12-1~16.04_amd64.deb ...
Unpacking python-minimal (2.7.12-1~16.04) ...
Preparing to unpack .../libc6_2.23-0ubuntu11_amd64.deb ...
Unpacking libc6:amd64 (2.23-0ubuntu11) over (2.23-0ubuntu10) ...
Setting up libc6:amd64 (2.23-0ubuntu11) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for man-db (2.7.5-1) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
(Reading database ... 77923 files and directories currently installed.)
Preparing to unpack .../libpython2.7-stdlib_2.7.12-1ubuntu0~16.04.4_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../python2.7_2.7.12-1ubuntu0~16.04.4_amd64.deb ...
Unpacking python2.7 (2.7.12-1ubuntu0~16.04.4) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../libpython-stdlib_2.7.12-1~16.04_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.12-1~16.04) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Setting up python2.7-minimal (2.7.12-1ubuntu0~16.04.4) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up python-minimal (2.7.12-1~16.04) ...
Selecting previously unselected package python.
(Reading database ... 78432 files and directories currently installed.)
Preparing to unpack .../python_2.7.12-1~16.04_amd64.deb ...
Unpacking python (2.7.12-1~16.04) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../libmpc3_1.0.3-1_amd64.deb ...
Unpacking libmpc3:amd64 (1.0.3-1) ...
Preparing to unpack .../gcc-5-base_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking gcc-5-base:amd64 (5.4.0-6ubuntu1~16.04.11) over (5.4.0-6ubuntu1~16.04.10) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up gcc-5-base:amd64 (5.4.0-6ubuntu1~16.04.11) ...
(Reading database ... 78492 files and directories currently installed.)
Preparing to unpack .../libstdc++6_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libstdc++6:amd64 (5.4.0-6ubuntu1~16.04.11) over (5.4.0-6ubuntu1~16.04.10) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Setting up libstdc++6:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
(Reading database ... 78492 files and directories currently installed.)
Preparing to unpack .../ca-certificates_20170717~16.04.2_all.deb ...
Unpacking ca-certificates (20170717~16.04.2) over (20170717~16.04.1) ...
Selecting previously unselected package augeas-lenses.
Preparing to unpack .../augeas-lenses_1.4.0-0ubuntu1.1_all.deb ...
Unpacking augeas-lenses (1.4.0-0ubuntu1.1) ...
Selecting previously unselected package binutils.
Preparing to unpack .../binutils_2.26.1-1ubuntu1~16.04.8_amd64.deb ...
Unpacking binutils (2.26.1-1ubuntu1~16.04.8) ...
Selecting previously unselected package libisl15:amd64.
Preparing to unpack .../libisl15_0.16.1-1_amd64.deb ...
Unpacking libisl15:amd64 (0.16.1-1) ...
Selecting previously unselected package cpp-5.
Preparing to unpack .../cpp-5_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking cpp-5 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package cpp.
Preparing to unpack .../cpp_4%3a5.3.1-1ubuntu1_amd64.deb ...
Unpacking cpp (4:5.3.1-1ubuntu1) ...
Selecting previously unselected package libcc1-0:amd64.
Preparing to unpack .../libcc1-0_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../libgomp1_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libgomp1:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../libitm1_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libitm1:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../libatomic1_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libatomic1:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libasan2:amd64.
Preparing to unpack .../libasan2_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libasan2:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../liblsan0_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking liblsan0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../libtsan0_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libtsan0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libubsan0:amd64.
Preparing to unpack .../libubsan0_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libubsan0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libcilkrts5:amd64.
Preparing to unpack .../libcilkrts5_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libmpx0:amd64.
Preparing to unpack .../libmpx0_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libmpx0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../libquadmath0_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package libgcc-5-dev:amd64.
Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package gcc-5.
Preparing to unpack .../gcc-5_5.4.0-6ubuntu1~16.04.11_amd64.deb ...
Unpacking gcc-5 (5.4.0-6ubuntu1~16.04.11) ...
Selecting previously unselected package gcc.
Preparing to unpack .../gcc_4%3a5.3.1-1ubuntu1_amd64.deb ...
Unpacking gcc (4:5.3.1-1ubuntu1) ...
Selecting previously unselected package libaugeas0.
Preparing to unpack .../libaugeas0_1.4.0-0ubuntu1.1_amd64.deb ...
Unpacking libaugeas0 (1.4.0-0ubuntu1.1) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../libc-dev-bin_2.23-0ubuntu11_amd64.deb ...
Unpacking libc-dev-bin (2.23-0ubuntu11) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../linux-libc-dev_4.4.0-150.176_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.4.0-150.176) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../libc6-dev_2.23-0ubuntu11_amd64.deb ...
Unpacking libc6-dev:amd64 (2.23-0ubuntu11) ...
Selecting previously unselected package libexpat1-dev:amd64.
Preparing to unpack .../libexpat1-dev_2.1.0-7ubuntu0.16.04.3_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.3) ...
Selecting previously unselected package libpython2.7:amd64.
Preparing to unpack .../libpython2.7_2.7.12-1ubuntu0~16.04.4_amd64.deb ...
Unpacking libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Selecting previously unselected package libpython2.7-dev:amd64.
Preparing to unpack .../libpython2.7-dev_2.7.12-1ubuntu0~16.04.4_amd64.deb ...
Unpacking libpython2.7-dev:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Selecting previously unselected package libpython-dev:amd64.
Preparing to unpack .../libpython-dev_2.7.12-1~16.04_amd64.deb ...
Unpacking libpython-dev:amd64 (2.7.12-1~16.04) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../libssl-dev_1.0.2g-1ubuntu4.15_amd64.deb ...
Unpacking libssl-dev:amd64 (1.0.2g-1ubuntu4.15) ...
Selecting previously unselected package python2.7-dev.
Preparing to unpack .../python2.7-dev_2.7.12-1ubuntu0~16.04.4_amd64.deb ...
Unpacking python2.7-dev (2.7.12-1ubuntu0~16.04.4) ...
Selecting previously unselected package python-dev.
Preparing to unpack .../python-dev_2.7.12-1~16.04_amd64.deb ...
Unpacking python-dev (2.7.12-1~16.04) ...
Selecting previously unselected package python-pip-whl.
Preparing to unpack .../python-pip-whl_8.1.1-2ubuntu0.4_all.deb ...
Unpacking python-pip-whl (8.1.1-2ubuntu0.4) ...
Selecting previously unselected package python-pkg-resources.
Preparing to unpack .../python-pkg-resources_20.7.0-1_all.deb ...
Unpacking python-pkg-resources (20.7.0-1) ...
Selecting previously unselected package python-virtualenv.
Preparing to unpack .../python-virtualenv_15.0.1+ds-3ubuntu1_all.deb ...
Unpacking python-virtualenv (15.0.1+ds-3ubuntu1) ...
Selecting previously unselected package python3-virtualenv.
Preparing to unpack .../python3-virtualenv_15.0.1+ds-3ubuntu1_all.deb ...
Unpacking python3-virtualenv (15.0.1+ds-3ubuntu1) ...
Selecting previously unselected package virtualenv.
Preparing to unpack .../virtualenv_15.0.1+ds-3ubuntu1_all.deb ...
Unpacking virtualenv (15.0.1+ds-3ubuntu1) ...
Selecting previously unselected package libffi-dev:amd64.
Preparing to unpack .../libffi-dev_3.2.1-4_amd64.deb ...
Unpacking libffi-dev:amd64 (3.2.1-4) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for install-info (6.1.0.dfsg.1-5) ...
Setting up libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Setting up python2.7 (2.7.12-1ubuntu0~16.04.4) ...
Setting up libpython-stdlib:amd64 (2.7.12-1~16.04) ...
Setting up python (2.7.12-1~16.04) ...
Setting up libmpc3:amd64 (1.0.3-1) ...
Setting up ca-certificates (20170717~16.04.2) ...
Setting up augeas-lenses (1.4.0-0ubuntu1.1) ...
Setting up binutils (2.26.1-1ubuntu1~16.04.8) ...
Setting up libisl15:amd64 (0.16.1-1) ...
Setting up cpp-5 (5.4.0-6ubuntu1~16.04.11) ...
Setting up cpp (4:5.3.1-1ubuntu1) ...
Setting up libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libgomp1:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libitm1:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libatomic1:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libasan2:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up liblsan0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libtsan0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libubsan0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libmpx0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.11) ...
Setting up gcc-5 (5.4.0-6ubuntu1~16.04.11) ...
Setting up gcc (4:5.3.1-1ubuntu1) ...
Setting up libaugeas0 (1.4.0-0ubuntu1.1) ...
Setting up libc-dev-bin (2.23-0ubuntu11) ...
Setting up linux-libc-dev:amd64 (4.4.0-150.176) ...
Setting up libc6-dev:amd64 (2.23-0ubuntu11) ...
Setting up libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.3) ...
Setting up libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Setting up libpython2.7-dev:amd64 (2.7.12-1ubuntu0~16.04.4) ...
Setting up libpython-dev:amd64 (2.7.12-1~16.04) ...
Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
Setting up libssl-dev:amd64 (1.0.2g-1ubuntu4.15) ...
Setting up python2.7-dev (2.7.12-1ubuntu0~16.04.4) ...
Setting up python-dev (2.7.12-1~16.04) ...
Setting up python-pip-whl (8.1.1-2ubuntu0.4) ...
Setting up python-pkg-resources (20.7.0-1) ...
Setting up python-virtualenv (15.0.1+ds-3ubuntu1) ...
Setting up python3-virtualenv (15.0.1+ds-3ubuntu1) ...
Setting up virtualenv (15.0.1+ds-3ubuntu1) ...
Setting up libffi-dev:amd64 (3.2.1-4) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for ca-certificates (20170717~16.04.2) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
./certbot-auto has insecure permissions!
To learn how to fix them, visit https://community.letsencrypt.org/t/certbot-auto-deployment-best-practices/91979/
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): ********@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for wheresmypacket.com
http-01 challenge for www.wheresmypacket.com
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/wheresmypacket.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/wheresmypacket.com/privkey.pem
   Your cert will expire on 2019-09-04. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

root@ip-172-26-5-115:/home/ubuntu#

Take note of the following folder location /etc/letsencrypt/live/wheresmypacket.com/

Step 3: Configure the Certificates

Edit the following file.

root@ip-172-26-5-115:/home/ubuntu#
root@ip-172-26-5-115:/home/ubuntu# ls /etc/apache2/sites-available/
000-default.conf  default-ssl.conf
root@ip-172-26-5-115:/home/ubuntu# sudo nano /etc/apache2/sites-available/default-ssl.conf

Add the following highlighted lines 7-12. Comment out (#) the following highlighted lines 41-42 while adding the following highlighted lines 43-45.

GNU nano 2.5.3                                   File: /etc/apache2/sites-available/default-ssl.conf                                                                    Modified

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin webmaster@localhost

                <Directory /var/www/html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                </Directory>

                DocumentRoot /var/www/html

                # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
                # error, crit, alert, emerg.
                # It is also possible to configure the loglevel for particular
                # modules, e.g.
                #LogLevel info ssl:warn

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                # For most configuration files from conf-available/, which are
                # enabled or disabled at a global level, it is possible to
                # include a line for only one particular virtual host. For example the
                # following line enables the CGI configuration for this host only
                # after it has been globally disabled with "a2disconf".
                #Include conf-available/serve-cgi-bin.conf

                #   SSL Engine Switch:
                #   Enable/Disable SSL for this virtual host.
                SSLEngine on

                #   A self-signed (snakeoil) certificate can be created by installing
                #   the ssl-cert package. See
                #   /usr/share/doc/apache2/README.Debian.gz for more info.
                #   If both key and certificate are stored in the same file, only the
                #   SSLCertificateFile directive is needed.
                #SSLCertificateFile     /etc/ssl/certs/ssl-cert-snakeoil.pem
                #SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
                SSLCertificateFile "/etc/letsencrypt/live/wheresmypacket.com/cert.pem"
                SSLCertificateKeyFile "/etc/letsencrypt/live/wheresmypacket.com/privkey.pem"
                SSLCertificateChainFile "/etc/letsencrypt/live/wheresmypacket.com/chain.pem"

Step 4: Enable HTTPS Redirect

Configure Apache server to only serve HTTPS. Edit the following file.

root@ip-172-26-5-115:/home/ubuntu#
root@ip-172-26-5-115:/home/ubuntu# ls /etc/apache2/sites-available/
000-default.conf  default-ssl.conf
root@ip-172-26-5-115:/home/ubuntu# sudo nano /etc/apache2/sites-available/000-default.conf

Add the following highlighted lines.

GNU nano 2.5.3                                   File: /etc/apache2/sites-available/000-default.conf                                                                    Modified

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ServerName www.wheresmypacket.com
        ServerAlias wheresmypacket.com
        Redirect permanent / https://wheresmypacket.com/

        <Directory />
        Options FollowSymLinks
        AllowOverride None
        </Directory>
        <Directory /var/www/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        </Directory>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
        </Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

^G Get Help     ^O Write Out    ^W Where Is     ^K Cut Text     ^J Justify      ^C Cur Pos      ^Y Prev Page    M-\ First Line  M-W WhereIs Next^^ Mark Text    M-} Indent Text
^X Exit         ^R Read File    ^\ Replace      ^U Uncut Text   ^T To Spell     ^_ Go To Line   ^V Next Page    M-/ Last Line   M-] To Bracket  M-^ Copy Text   M-{ Unindent Text

Step 5: Restart Apache Server

sudo a2ensite default-ssl
sudo a2enmod ssl
sudo service apache2 restart 
root@ip-172-26-8-213:~# sudo a2ensite default-ssl
Enabling site default-ssl.
To activate the new configuration, you need to run:
  service apache2 reload
root@ip-172-26-8-213:~# sudo a2enmod ssl
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Module socache_shmcb already enabled
Module ssl already enabled
root@ip-172-26-5-115:/etc/apache2/sites-available# sudo service apache2 restart
root@ip-172-26-5-115:/etc/apache2/sites-available#

Step 6: Update WordPress URLs

Go to your WordPress dashboard. Under Settings-General Settings, update the WordPress Address (URL) and Site Address (URL).

Step 7: Configure SSL Auto-Renewal

Start by moving the certbot package to the letsencrypt directory.

root@ip-172-26-8-213:~# ls
certbot-auto
root@ip-172-26-8-213:~# ls /etc/letsencrypt/
accounts  archive  csr  keys  live  renewal  renewal-hooks
root@ip-172-26-8-213:~#
root@ip-172-26-8-213:~# sudo mv certbot-auto /etc/letsencrypt/
root@ip-172-26-8-213:~#
root@ip-172-26-8-213:~# ls /etc/letsencrypt/
accounts  archive  certbot-auto  csr  keys  live  renewal  renewal-hooks
root@ip-172-26-8-213:~#

Add to crontab

root@ip-172-26-5-115:/home/ubuntu# sudo crontab -e
no crontab for root - using an empty one

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/vim.basic
  4. /usr/bin/vim.tiny

Choose 1-4 [2]: 2

Add the following highlighted line on crontab.

  GNU nano 2.5.3                     File: /tmp/crontab.zOgnYl/crontab                                       Modified

# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
45 2 * * 6 cd /etc/letsencrypt/ && ./certbot-auto renew && /etc/init.d/apache2 restart


^G Get Help      ^O Write Out     ^W Where Is      ^K Cut Text      ^J Justify       ^C Cur Pos       ^Y Prev Page
^X Exit          ^R Read File     ^\ Replace       ^U Uncut Text    ^T To Spell      ^_ Go To Line    ^V Next Page

Leave a Reply