George McKinney Adventures in Software Development

October 3, 2024

Deploying WordPress on AWS Lightsail

Filed under: AWS,Lightsail,Linux — georgemck @ 8:31 am

After logging into AWS and launching the Lightsail service, it is necessary to create an instance. The instance for WordPress is based on the Linux Debian operating system packaged by Bitnami. Lightsail applications run standalone from AWS at large though can be integrated with it. When an instance is created, with the Route 53 service an hosted zone is created for the domain. It is barebones containing only the SOA and NS records. If it’s necessary to migrate an existing website into AWS/Lighstail, you must add the name service records for MX, CNAME, TXT, etc. This can be done by exporting the existing zone and then importing them into Route 53 but not adding the SOA and NS records (optional, depends on if you will still need them.)

Accessing the database directly is not allowed. To use the phpmyadmin included in Lightsail, you must create an SSH tunnel. Bitnami documents the procedure on this page and specifically with this video.

In order to access SFTP with a program like Filezilla on AWS, follow the documentation here.

If you add files to WordPress, it is likely that there will be permissions issues. You will see in the admin dashboard messages about not being to access certain files or folders. You can change the permission by connecting to the instance using SSH. This procedure is shown as a prerequisite for opening phpmyadmin. After successfully connecting, you can change ownership of the problematic files and folders with the following command which must be updated for the target machine.

sudo chown -R daemon:daemon uploads
sudo chown -R daemon:daemon application/config
sudo chown -R daemon:daemon /opt/bitnami/apache/htdocs/temp

In order for the domain name to resolve on the internet, you will need to update the Hosted Zone. In the hosted zone, add an A record pointing to the IP address of the Lightsail instance. This will work but will not support https (that is there is no SSL certificate). AWS documents how to add an SSL certificate to Lightsail. However, Bitnami has a better solution for this.

November 8, 2022

Sending Mail from AWS Lightsail using WP MAIL SMTP by Shared Hosting (Mochahost!)

Filed under: AWS,Lightsail,Mochahost,PHP,WordPress — georgemck @ 9:21 pm

AWS Lightsail enables Amazon Web Services customers to host “simple web applications, use pre-configured development stacks like LAMP, Nginx, MEAN, and Node.js.” This includes WordPress-powered websites. Lightsail creates a Debian-based virtual server to host these applications allowing SSH connections. Unfortunately, unlike traditional shared hosting services,  mail functionality is not included. This prevents WordPress from sending emails normally including for password resets. Fortunately, there is an easy to use plugin (WP MAIL SMTP) that provides a number of options for sending email including  SendLayer, SMTP.com, Sendinblue, Mailgun, SendGrid, Postmark, SparkPost, Gmail, Microsoft, Amazon SES, Zoho, and All Other SMTP providers.

Since web services do not need to be provided by the same server address or even the same company. It is possible to split web application hosting from mail server hosting via customizing the DNS zone settings (That topic is not addressed here). The goal of this post is to point out the settings necessary to enable the Lightsail application to use mail settings from one of the “All Other SMTP” providers, specifically Mochahost.

First off, you must create an email account on Mochahost. By doing so, you will immediately know the username and password. The configuration for setting up a mail client are available. However, instead of using the website’s domain it is necessary to use the mail server domain in this case, mochaXXXX.mochahost.com. The port will be 587. Encryption will be TLS. Finally, authentication with username and password are required.

Here is an example of the WP MAIL SMTP plugin settings:

 

 

Now, send a test email:

 

And check your email:

 

All these companies provide great servers and, when you need to scale, you will be in good hands.

 

 

Powered by WordPress