AWS Lightsail/WordPress Setup, Troubleshooting, & Maintenance

This page is meant for IT professionals who are comfortable on the command line and includes helpful commands and runbooks to assist in managing WordPress instances hosted on AWS Lightsail (Bitnami).

Regular Updates & Maintenance

AWS Lightsail Bitnami Server Updates & Maintenance

sudo su
apt-get update -y
sudo dpkg --configure -a
apt-get upgrade -y
apt-get autoremove -y
apt-get -f install
apt-get upgrade -y
apt-get autoremove  -y
apt-get autoclean
sudo /opt/bitnami/ctlscript.sh restart
reboot

WordPress Components Updates & Maintenance

sudo su
/opt/bitnami/wp-cli/bin/wp theme update --all
/opt/bitnami/wp-cli/bin/wp plugin update --all 
/opt/bitnami/wp-cli/bin/wp core update 
/opt/bitnami/wp-cli/bin/wp core verify-checksums
/opt/bitnami/wp-cli/bin/wp db optimize
/opt/bitnami/wp-cli/bin/wp cache flush

sudo /opt/bitnami/ctlscript.sh restart   #restart all web services

Initial Setup of AWS Lightsail WordPress server

Sign up and create a site:

  • Create Cloudflare account and log password and delegate access to GHT.

  • Create account for AWS, then go to Lightsail: https://lightsail.aws.amazon.com/ls/webapp/home

  • Create a WordPress Lightsail instance in zone US West 2

  • Assign a static IP to the server in Lightsail

  • Add/edit A record in public DNS Host

  • Enter the console and put in the below commands to set the SERVER timezone:

sudo su
sudo dpkg-reconfigure tzdata
  • Then run this, making sure to update the language in email address and username if desired:

#Start Server updates
apt-get update -y
sudo dpkg --configure -a
apt-get upgrade -y
apt-get autoremove -y
apt-get -f install
apt-get upgrade -y
apt-get autoremove  -y
apt-get autoclean

#Start WordPress config and cleanup
wp plugin delete --all   #deletes all default plugins
wp site empty --yes  #deletes all default pages
wp site empty --uploads --yes   #deletes all default media
sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1  
rm /opt/bitnami/wordpress/readme.html  #deletes readme file
wp option update admin_email webservices@goodhearttech.org  #replace the email address with yours
wp option update default_role subscriber

wp core update 
wp db optimize

#Set Timezone for WordPress
#wp option update timezone_string 'America/New_York'
wp option update timezone_string 'America/Boise'
#wp option update time zone string 'America/Los_Angeles'

#Install The SEO Framework, Cloudflare, Disable Comments, Fluent SMTP, Google Site Kit plugins, and then activate them. 
wp plugin install autodescription cloudflare disable-comments fluent-smtp google-site-kit --activate

#Create a new admin user (replace username and email), make note of the password that is returned by the last command
wp user create goodhearttech webservices@goodhearttech.org --role=administrator
  • THEN Add a S to the HTTP to make it HTTPS to the wp-config file for the site:

nano /opt/bitnami/wordpress/wp-config.php
CHANGE: 
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/' );
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/' );
TO: 
define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
  • Restart the service

sudo /opt/bitnami/ctlscript.sh restart apache

Install the Level RMM Agent (optional)

Install the RMM agent using the command given to you by the Level interface, then change the hostname:

#Change UUID to a random string to allow for Remote Management tools to work.
randomString=$(echo $RANDOM | md5sum | head -c 20; echo;)
sudo /usr/local/bin/level --set-uuid "$randomString"

service Level restart

After the server appears in Level (appears first as ip-123.123.123.123), rename it to the domain name that it will be used to host.

Configure Plugins

  • Configure UpdraftPlus

    • Sign in with GHT's Premium Account

    • Activate products on the site

    • If restoring a site to this new server, don;t both installing the rest of the plugins listed here.

    • Setup AWS S3 Backup in Settings, and use GHT key pair to create credentials and bucket.

  • Configure Fluent SMTP

    • Create SendInBlue Account for the website.

    • Under the SendInBlue settings, Domains, add the domain. Authenticate the domain by adding the DNS records provided

      • If able, add this comment to all DNS records created in the registrar: SendInBlue DKIM for WordPress.

      • In addition, be sure to add this to the SPF record: include:sendinblue.com

    • Generate an API key and store it in a password solution.

    • Install the FluentSMTP plugin and configure the SendInBlue from email using the API key.

    • Send a test email to yourself to very the email is working and goes to Inbox.

  • Upload the Avada premium theme from the GHT SharePoint Internal site.

  • Activate the theme and install the required plugins as directed.

    • Avada - Navigate to the IP of the lightsail instance, upload the Avada theme, and go to the Avada registration tab in WP. Click on Generate Envato token. Create an account and verify by email. Get the token and document it.

  • Install/activate the Google Site Kit plugin and proceed through the setup wizard.

  • Install/activate the Cloudflare plugin and proceed through the setup wizard. Input the API key and Apply recommended Settings

Linode WordPress

These are alternative instructions for if you are running WordPress on Linode.

Get Linode WordPress Credentials

cat /root/.linode_credentials.txt

Linode Edit WP-Config.php file to edit the site URL:

nano /var/www/172-232-163-61.ip.linodeusercontent.com/public_html/wp-config.php

Update these Lines:

define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/' );

define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/' );

SET the Wordpress URL config in the DB:

update wp_options set option_value="http://new.myplacesce.org" where option_name="home" or option_name="siteurl";

Then, we can view the output of the Wordpress uRL config in the DB:

select option_name, option_value from wp_options where option_name="home" or option_name="siteurl";

PHP Configuration File (Changes based on PHP version)

nano /etc/php/8.1/cli/php.ini

General Troubleshooting and Reporting Commands

First Troubleshooting Step - Deactivate all plugins:

sudo wp plugin deactivate --all

Update UUID (allows you to install RMM tools):

sudo su
sudo /usr/local/bin/level --set-uuid "serverNameHere"
# NEXT, run the one-liner RMM agent install to ensure the server gets patched

Update timezone:

sudo dpkg-reconfigure tzdata

Restart All Services:

sudo /opt/bitnami/ctlscript.sh restart

Restart Apache:

sudo /opt/bitnami/ctlscript.sh restart apache

Stop apache server:

sudo /opt/bitnami/ctlscript.sh stop apache

Get admin (root) password:

Username: user

^^ use this username and password to login to your new wordpress instance using the /wp-login page.

cat bitnami_application_password

Get admin (root) password:

Username: user

^^ use this username and password to login to your new wordpress instance using the /wp-login page.

cat bitnami_application_password

Deactivate plugin via command line:

wp plugin deactivate <pluginFolderName>

Delete all plugins:

wp plugin delete --all

Enable WordPress Logging and go to log file

nano /opt/bitnami/wordpress/wp-config.php

: '
Make sure these two lines are in the wp-config file, then save
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

THEN, open the debug file
nano /opt/bitnami/wordpress/wp-content/debug.log

'

Check WordPress Installation and Reinstall

Then change to the WordPress directory to use 'rm' to remove the bad files.

wp core verify-checksums

wp core download --force --skip-content
cd /home/bitnami/stack/wordpress

#rm targetFile.php

Config htaccess for plugin access:

sudo chmod 664 opt/bitnami/wordpress/wp-config.php
sudo /opt/bitnami/ctlscript.sh restart apache

Check Disk Space:

du -ch --max-depth=1 / 2>/dev/null

Check Disk Space on a directory:

du -ch --max-depth=1 /path/here

Reset permissions for WordPress:

chown –R bitnami:daemon /opt/bitnami/wordpress
cd /opt/bitnami/wordpress
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 664 {} \;
chmod 640 /opt/bitnami/wordpress/wp-config.php
sudo chown -R bitnami:daemon /opt/bitnami/wordpress/wp-content
sudo chmod -R g+w /opt/bitnami/wordpress/wp-content

from: https://docs.bitnami.com/general/apps/wordpress/troubleshooting/debug-errors/

Plugins folder path on bitnami instances:

cd /opt/bitnami/wordpress/wp-content/plugins

Reset permissions on the plugins directory:

chmod 755 opt/bitnami/wordpress/wp-content

Access & Other Server Settings

Find files:

find . -name "filename*"

Find and Delete files:

find . -name "filename*" -delete

Edit PHP configuration (like to increase file upload limit):

nano /opt/bitnami/php/etc/php.ini

# Edit the line called max_execution_time.  The default is 30, but it can be increased depending on need.  Some plugins require up to 600 seconds, like Woocommerce Square. 
  • hit F6 to search for php properties, and use this to find their name: https://www.php.net/manual/en/ini.core.php

Edit WordPress functions.php configuration (for Avada):

nano /home/bitnami/stack/wordpress/wp-content/themes/Avada/functions.php

Edit .htaccess file via vi command:

sudo vi /opt/bitnami/apps/wordpress/conf/htaccess.conf

Create .htpasswd file (for custom directory security):

htpasswd -c /opt/bitnami/apps/wordpress/htdocs/FOLDERNAME/.htpasswd userName

Database Management

Connect to the database

mysql bitnami_wordpress -u root -p

Import data into database:

mysql -u root -p bitnami_wordpress < /opt/bitnami/apps/wordpress/path/SQLFILE.sql

Drop Tables after connecting

TRUNCATE wp_fusion_form_submissions;
TRUNCATE wp_fusion_form_entries;

More info on troubleshooting and permissions reset:

Archived Commands

Plugin Setup (no longer needed if using external email service like SendInBlue)

Add AWS SES keys to wp-config:

define( 'WPOSES_AWS_ACCESS_KEY_ID',     'keyIDhere' );
define( 'WPOSES_AWS_SECRET_ACCESS_KEY', 'secretKeyHere' );

Last updated

Copyright © Good Heart Technology