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 guide for firing up a fast reliable server for hosting multiple WordPress sites with successful email delivery and security. We are using Lightsail boxes from AWS and Serverpilot for the

Firstly, create a Lightsail server

  • Select region – OS only – Ubuntu – Choose a size for you. It is possible to upgrade so you can start on a lower tier.
  • Create a static IP ( main page – networking tab ) Same name as the server -IP

We assume 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

and

Enter these Match rules at the bottom of


$ sudo nano /etc/ssh/sshd_config


Match User root,ubuntu
PasswordAuthentication no

Then, navigate to the Networking tab. 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.

see https://serverpilot.io/community/articles/how-to-create-a-server-on-amazon-lightsail.html

Install ServerPilot

Connect to server – paste in the static IP and the root password – choose a plan – hit save.

Make a default App on Server Pilot. See others. 0default. This stops incorrect domain settings bring up other website and shows a default SP page.

If you will be sending mail from your server you need up set up your server’s Hostname.

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

your_server_name.thriveweb.com.au

In terminal enter:

 
$ sudo hostname your_server_name

and


$ sudo hostnamectl set-hostname your_server_name.thriveweb.com.au

eg. sudo hostname your_server_name.thriveweb.com.au

Now in terminal enter:


$ sudo nano /etc/hostname

Replace with your_sub_domain if needed.

and


$ sudo nano /etc/hosts

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

eg. 127.0.0.1 longfin.thriveweb.com.au

Now edit


$ sudo nano /etc/postfix/main.cf 

and change my hostname and smtp_helo_name

eg.myhostname = $myhostname.example.com
to myhostname = $myhostname

Set up a wildcard DNS

We suggest you set up a wildcard domain 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. Simply add 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 *.longfin – See a screenshot below.

We suggest you check your email spammyness after these changes on a live domain using mail-tester.com

Install htop


$ sudo apt install htop

Disable Errors:

Try this and if you get an error a PHP version my no exist anymore. 5.6 will be the next to go remove it and change it for the new version supported.


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 &&
echo 'display_errors = false' | sudo tee --append /etc/php7.3-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 &&
cat /etc/php7.3-sp/php.ini &&
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 &&
sudo service php7.3-fpm-sp restart

We recomend 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 > https://aws.amazon.com/forms/ec2-email-limit-rdns-request?catalog=true&isauthcode=true

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 https://yourdomain.com/ and build websites for our clients.

  • Include the static IP in the ‘Elastic IP Address 1’ field below.
  • Enter a FQDN ( like asterix.thriveweb.com.au ) domain name that points to the server in “Reverse DNS Record for EIP 1” – They setup 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

Sharing is caring:

Created Nov 15, 2019 Made on the Gold Coast

Leave a Reply