Tweaking the Bitnami WordPress Stack on AWS LightSail


I no longer use Bitnami on AWS LightSail due to the steps required to get sane application behaviour and performance are not worth it. Leaving this up for any searches leading here and will recommend for a similar level of serviced hosting, try DigitalOcean or Vultr.

Tired of clunkily updating a GitHub gist, herein lie my notes used when provisioning an AWS LightSail instance with Bitnami WordPress for quick migration/debugging of an existing user’s WordPress site.

  • copy public key via the virtual terminal in AWS Console
  • set a DNS entry to point dev domain to the instance’s IP
  • access site at dev domain
  • rm bitnami banner
    • sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
    • sudo /opt/bitnami/ restart apache
  • SSH in using dev domain
  • enable SSL
    • sudo mkdir /opt/bitnami/letsencrypt
    • cd /opt/bitnami/letsencrypt
    • sudo wget
    • sudo chmod a+x ./certbot-auto
    • sudo ./certbot-auto
    • sudo ./certbot-auto certonly --webroot -w /opt/bitnami/apps/wordpress/htdocs/ -d
    • sudo ln -s /etc/letsencrypt/live/[DOMAIN]/fullchain.pem /opt/bitnami/apache2/conf/server.crt
    • sudo ln -s /etc/letsencrypt/live/[DOMAIN]/privkey.pem /opt/bitnami/apache2/conf/server.key
    • Make sure that the certificate file name and path is correct. If you receive an error that file already exists, use the below command to rename the files:
    • mv /opt/bitnami/apache2/conf/server.key /opt/bitnami/apache2/conf/serverkey.old
    • mv /opt/bitnami/apache2/conf/server.crt /opt/bitnami/apache2/conf/servercrt.old
    • sudo /opt/bitnami/ restart apache
  • adjust wp-config to use https
    • sed -i 's/http/https/' /opt/bitnami/apps/wordpress/htdocs/wp-config.php
    • sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/
  • force https in top of file: /opt/bitnami/apps/wordpress/conf/httpd-prefix.conf
    • RewriteEngine On
    • RewriteCond %{HTTPS} !=on
    • RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  • Restart server to enforce https
    • sudo /opt/bitnami/ restart apache
  • backup wp-config somewhere
    • sudo cp /opt/bitnami/apps/wordpress/htdocs/wp-config.php /opt/bitnami/apps/wordpress/wp-config-backup-randstring.php
  • disable mod pagespeed
    • sudo vim /opt/bitnami/apache2/conf/pagespeed.conf
    • ModPagespeed on > ModPagespeed off
    • sudo /opt/bitnami/ restart apache
  • copy existing site’s files into WP dir
  • backup existing wp-config
    • sudo cp /opt/bitnami/apps/wordpress/htdocs/wp-config.php
  • restore Bitnami’s wp-config
  • copy any custom define’s or code from existing wp-config
  • import users DB
    • delete bitnami_wordpress
    • create bitnami_wordpress
    • import .sql
  • rewrite any hard links within DB
    • sudo wp --allow-root search-replace '' ''
  • change admin user email and pwd
    • sudo wp --allow-root user update 1 --user_pass="PASSWORD"
  • rewrite any hard links within site (optional, careful of mailto links, etc)
    • find -name '*.css' -exec sed -i 's/' {} +
  • reset file permissions
    • sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/
    • sudo find /opt/bitnami/apps/wordpress/htdocs/ -type f -exec chmod 664 {} \;
    • sudo find /opt/bitnami/apps/wordpress/htdocs/ -type d -exec chmod 775 {} \;
    • also php-fpm restart sudo /opt/bitnami/ restart php-fpm
  • enable debugging

define( 'WP_DEBUG', true );

tailing WP logs

tail -f /opt/bitnami/apache2/logs/error_log

connect to db

mysql -u bn_wordpress -p bitnami_wordpress # and pwd from wp-config

check plugin options

select * from wp_options where option_name = 'wp-static-html-output-options' \G;

  • working_directory option can persist the old sever’s paths

modify PHP ini

not yet needed, seems to have large max_execution_time already

  • disable opcache
  • disable mod pagespeed
  • use development level error logging
  • increase memory
  • extend max execution time

sudo vim opt/bitnami/php/etc/php.ini

Basic Auth

less noisy error log

sudo echo 'ErrorLogFormat "\n \"%M\" \n "' >> /opt/bitnami/apache2/conf/httpd.conf

^ needed re-rediting to affect the CR’s, look to fix

Scratch notes

  • deal with (70007) The timeout specified has expired errors from proxy_fcgi:error:

Timeout 900 ->

in /opt/bitnami/apache2/conf/httpd.conf

import vim and tmux confs

--output ~/.tmux.conf

--output ~/.vimrc

not working without additional domain verification overrides: – enable mail sending (consider Amazon has a limit for LightSail) not verified, erros with – sudo apt install sendmailsudo vim opt/bitnami/php/etc/php.ini – uncomment sendmail_path = "env -i /usr/sbin/sendmail -t -i"sudo /opt/bitnami/ restart apache

Share on twitter
Share on reddit
Share on telegram
Share on email
Share on print

Site made with love of these open source tools

The beautifully-crafted OS that forces you to learn how to do things properly.

For better or worse, WordPress powers 30% of the web. ClassicPress reduces some of the bloat.

Text is my material. Learn one text editor well.

Version controlling all the things.

Retaining workspaces on local and remote servers.

Supporting the OpenBSD community with opinionated VMs. €10/yr donated to the OpenBSD Foundation.

To Roman Zolotarev, for helping us Master the Web. My family and friends for enduring my voluntary financial hardship while pursuing my passions.