How to set up a Wordpress site on AWS

A no-BS guide featuring all the code snippets you’ll need

Follow sections 1 to 5 of the guide in the link below in order to create a new server on AWS Lightsail, load it with Wordpress and get the admin credentials for it:

Adding your domain

Once you are done with step 5, create the following DNS record for your domain (you can usually do this in the dashboard of your DNS provider):

Type: A

Value: The static IP address that you just attached on AWS in step 5

TTL: Any value will work here

Now all that’s left is waiting for the change to propagate, it shouldn’t take longer than 1 hour.

Add an SSL certificate to your site, enabling https

Once the DNS change has propagated and you can see the Wordpress page at your domain, access the shell and execute the following commands, replacing YOURDOMAIN.com with your domain:

sudo apt-get update

sudo apt-get install software-properties-common

sudo apt-add-repository ppa:certbot/certbot -y

sudo apt-get update -y

sudo apt-get install certbot -y

DOMAIN=YOURDOMAIN.com

WILDCARD=*.$DOMAIN

sudo certbot -d $DOMAIN -d $WILDCARD --manual --preferred-challenges dns certonly

For a short tutorial on how to connect using your own ssh client, instead of the horrendous web shell AWS provides, check the appendix at the bottom of this article

Follow certbot’s instructions and once you are done with the process and have received the certificates, run the following commands in order to instruct your webserver to use them and enable https:

sudo /opt/bitnami/ctlscript.sh stop

sudo mv /opt/bitnami/apache2/conf/server.crt /opt/bitnami/apache2/conf/server.crt.old

sudo mv /opt/bitnami/apache2/conf/server.key /opt/bitnami/apache2/conf/server.key.old

sudo mv /opt/bitnami/apache2/conf/server.csr /opt/bitnami/apache2/conf/server.csr.old

sudo ln -s /etc/letsencrypt/live/$DOMAIN/privkey.pem /opt/bitnami/apache2/conf/server.key

sudo ln -s /etc/letsencrypt/live/$DOMAIN/fullchain.pem /opt/bitnami/apache2/conf/server.crt

sudo /opt/bitnami/ctlscript.sh start

Remove the bitnami banner

Run these commands:

sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1

sudo reboot

Congrats, you’re done! Enjoy your new Wordpress site!

Appendix: Connect using your own ssh client

Go to your Lightsail account page. Click on the “Download” button that’s next to the region where you just created your server. Connect via ssh using this command:

Replace 1.2.3.4 for the IP of your AWS server and “LightsailDefaultKey-eu-central-1.pem” for the filename of the downloaded file.