website design gold coast
website design gold coast

AWS Lightsail For Serverpilot

Our server setup guide for hosting with Lightsail and Serverpilot.

This is Thrive’s complete guide for firing up a fast reliable server for hosting multiple WordPress sites with successful email delivery and tight security. We are using Lightsail boxes from AWS and ServerPilot for the fast, hassle-free server and site management.

Firstly, create a Lightsail server with ServerPilot installed

Create a lightsail server. Please see ServerPilot’s setup guide

You need to enable root logins for the serverpilot setup. In the guide, they mention that you need a manual install but that is not the case. You need to enable root logins. Login via the Lightsail console and run:

$ sudo nano /etc/ssh/sshd_config

PermitRootLogin yes

Restart SSH

sudo systemctl restart ssh

Don’t forget to create a static IP ( main page – networking tab ) – This can’t be undone…

Then setup ServerPilot on the server. See ServerPilot’s setup guide

We assume at this point you have SSH logged into the server as Ubuntu.

Logins and Passwords

Enable passwords logins for all user accounts. Edit sshd_config:

$ sudo nano /etc/ssh/sshd_config

PasswordAuthentication yes

Now disable password logins for the Root and Ubuntu accounts. We can get into the terminal app via the Lightsail website or by adding your public key to the server.

PermitRootLogin no


Enter these Match rules at the bottom of the file /etc/ssh/sshd_config

Match User ubuntu
PasswordAuthentication no

Restart SSH

sudo systemctl restart ssh

This will disable the password login for the root account ubuntu but keep it active for the other app user accounts.

Then, navigate to the Networking tab in the Lightsail admin. Here you’ll see the default firewall rules. Click +Add another.

Now, select HTTPS from the new rule’s drop-down list and click Save.


Firstly, stop the server resetting the hostname on a reboot.

In terminal enter:

$ sudo nano /etc/cloud/cloud.cfg

and set the parameter “preserve_hostname” from “false” to “true”

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: true

Now, make a new fully qualified subdomain. You can use any subdomain you own and point it back to your server IP.


Such as

In terminal enter:

$ sudo hostname your_server_name

( there is no domain just the subdomain )


$ sudo hostnamectl set-hostname your_sub_domain.your_domain

eg. sudo hostname

Now in terminal enter:

$ sudo nano /etc/hostname

Replace with your_sub_domain.your_domain if needed. There should only be the your_sub_domain.your_domain in this file.


$ sudo nano /etc/hosts

Replace the generated name ( just edit the last line, ip-{your static ip}) with your_sub_domain.your_domain if needed.


Now edit

$ sudo nano /etc/postfix/ 

and change my hostname and smtp_helo_name

from myhostname = $
to myhostname = your_sub_domain.your_domain

Set up a wildcard DNS record

We suggest you set up a wildcard subdomain in Cloudflare which you can do for free. This will allow you to have anything.server.domain and will automatically point the A record to the server without having to go into your domain control panel to make temporary domains. You still need to add it into Serverpilot under the appropriate app of course.

To do this create a new A record in Cloudflare with your server nickname name and add a * in front. eg *.asterix – See a screenshot below.

Test the Spammyness of your server’s emails

To make sure all of this has worked we suggest you check your email spammyness after these changes on a live domain using – Use a live domain for the best results.

Create a simple PHP script on an app that will send an email to the test email address you are given from

  $from = "";
  $to = "";
  $subject = "PHP Mail Test script";
  $message = "This is a test to check the PHP Mail functionality.";
  $headers = "From:" . $from;
  echo mail($to,$subject,$message, $headers);
  echo " Test email sent to " . $to ;

Edit and fire this code to send the email and check your results!

Install htop

This is useful for checking the health and performance of your server.

$ sudo apt install htop

Disable PHP Errors:

Run this command and if you get an error relating to a missing PHP file then remove the lines that relate to that version of PHP. ( Copy all the lines together )

echo 'display_errors = false' | sudo tee --append /etc/php5.5-sp/php.ini && 
echo 'display_errors = false' | sudo tee --append /etc/php5.6-sp/php.ini && 
echo 'display_errors = false' | sudo tee --append /etc/php7.0-sp/php.ini && 
echo 'display_errors = false' | sudo tee --append /etc/php7.1-sp/php.ini &&
echo 'display_errors = false' | sudo tee --append /etc/php7.2-sp/php.ini && 
cat /etc/php5.5-sp/php.ini &&
cat /etc/php5.6-sp/php.ini &&
cat /etc/php7.0-sp/php.ini &&
cat /etc/php7.1-sp/php.ini &&
cat /etc/php7.2-sp/php.ini &&
sudo service php5.5-fpm-sp restart &&
sudo service php5.6-fpm-sp restart && 
sudo service php7.0-fpm-sp restart && 
sudo service php7.1-fpm-sp restart && 
sudo service php7.2-fpm-sp restart

We recommend using Statuscake server monitoring

  • Go to the server monitoring page
  • Create a new server
  • Set a name
  • Put in 75% for all
  • Contact groups = dean email and slack notify
  • Hit save & generate install code
  • Login through ssh into the server
  • Run curl code 2 times if you see an error.

AWS have limits on your email send count. You need to fill out their form to request this limit is removed.

Un limit port 25 >

In the form include a note similar to the below:

*** Please note this is a Lightsail server. ***
We are using the server for websites and will in no way use the server for spam. We are using the server for websites and will in no way use the server for spam. We also want to host some busy WooCommerce shops that send a lot of email notifications. We run and build websites for our clients.

  • Include the static IP in the ‘Elastic IP Address 1’ field below.
  • Enter a FQDN ( like ) domain name that points to the server in “Reverse DNS Record for EIP 1” – They set up the reverse DNS.
  • And Send it.

Read more about Reverse DNS here

We hope you have found this useful! Please post comments or suggestions if you have any.

Let's work together!

Get in touch Request a quote

Created Nov 15, 2019 - Last modified on March 3rd, 2021 - Web Design Gold Coast

Leave a Reply