Bitnami WordPress Cheatsheet for AWS Lightsail

I'm currently working on two WordPress websites that have been pre-configured by Bitnami within a Virtual Private Cloud. Below are a few select commands I use all the time but only found them while scouring through forums and comment boxes. I hope this collection helps other WordPress managers save time.


How to install

Pick one:


Bitnami Specific Tricks

Remove Bitnami branding.

sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1

Change machine hostname.

sudo /opt/bitnami/apps/wordpress/bnconfig --machine_hostname subdomain.domain.com

Files, Paths, Directories

Apache Specific

Apache error logs.

nano /opt/bitnami/apache2/logs/

Virtual Host.

nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf 

WordPress Specific

Access wp-config.php

nano ~/apps/wordpress/htdocs/wp-config.php

Access wp-content directory.

cd /opt/bitnami/apps/wordpress/htdocs/wp-content/

Themes directory

cd /opt/bitnami/apps/wordpress/htdocs/wp-content/themes/

Plug-ins directory.

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

SSL

Path to pre-installed SSL certificate.

/opt/bitnami/apache2/conf/server.crt

Path to pre-installed private key.

/opt/bitnami/apache2/conf/server.key

Redirect non-www to www.

Bitnami disables .htaccess by default files for security and performance reasons (Source, Source 2). Therefore, you can solve this problem in a few different ways.

Method 1

Modify httpd-app.conf.

vim ~/apps/wordpress/conf/httpd-app.conf 
<Directory "/opt/bitnami/apps/wordpress/htdocs">
...

    RewriteEngine On
    #RewriteBase /wordpress/

    # MODIFICATIONS START ----------
    
    RewriteBase /
    
    # Redirect non-www to www
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # MODIFICATIONS END -----------


    RewriteRule ^index\.php$ - [S=1]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]

    Include "/opt/bitnami/apps/wordpress/conf/banner.conf"
</Directory>

Method 2

Open up bitnami.conf.

vim /opt/bitnami/apache2/conf/bitnami/bitnami.conf

Add this VirtualHost

<VirtualHost _default_:80>
...
  # Bitnami applications installed with a prefix URL (default)
  # BEGIN EDIT BELOW
</VirtualHost>


<VirtualHost *:80>
    ServerName domain.com
    Redirect permanent / http://www.domain.com/
</VirtualHost>

Source

Method 3

Modify htaccess.conf. This is the Bitnami approach instead of modifying .htaccess directly.

vim /opt/bitnami/apps/wordpress/conf/htaccess.conf

Restart Servers

Restart everything.

sudo /opt/bitnami/ctlscript.sh restart  

Restart Apache only.

sudo /opt/bitnami/ctlscript.sh restart apache

Restart MySQL only.

sudo /opt/bitnami/ctlscript.sh restart  mysql

Ownership and Permissions

Plugins Directory

I see this error happen from time-to-time. You try to install a plugin and get an error about not creating a directory. More often than not, it has to do with permissions.

Change ownership.

sudo chown -R bitnami:daemon wp-content/

Change permissions.

sudo chmod -R g+w wp-content/

Robots.txt

This topic is slightly more complex, so I created a dedicated tutorial. Read more