How to set up Perlite for Obsidian

Install the dependancies

sudo apt install nginx php php-fpm php-yaml cron git zip python3-certbot-nginx certbot apache2-utils

Install perlite

sudo mkdir /srv
wget https://github.com/secure-77/Perlite/releases/download/1.6/Perlite_1.6.zip #or your version of perlite
unzip Perlite_1.6.zip
mv perlite/* /srv/perlite/

Create your nginx config

rm /etc/nginx/sites-available/default
vim /etc/nginx/sites-available/notes.soulsender.me
cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/notes.soulsender.me

The config file:

server {
        server_name notes.soulsender.me;

        root /srv/perlite/;
        index index.php index.html index.htm;

        location / {
                try_files $uri $uri/ /index.php;
        }

        location ~ \.php$ {
               include snippets/fastcgi-php.conf;
               # make sure this path is for your correct php version
               fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

        location ~* ^/(.*)/.obsidian/appearance.json$ {
                allow all;
        }

        location ~* ^/(.*)/.obsidian/(.*)/theme.css$ {
                allow all;
        }

        #added for this specific setup, thanks sec77!
        location ~* ^/.obsidian/(.*)/theme.css$ {
                allow all;
        }

        location ~ \.(git|github|obsidian|trash) {
                deny all;
        }

        location ~ \.(md|json)$ {
                deny all;
        }
}

Make sure your dns record points to your server!!!

Request a certificate

sudo certbot --nginx -d notes.soulsender.me

Do this thing idk

sudo mkdir -p /etc/nginx/auth/
sudo htpasswd -c /etc/nginx/auth/default.htpasswd nothing

Edit the perlite config

vim /srv/perlite/settings.php

Your Notes

Your obsidian vault goes at the root of /srv/perlite/. I wanted it to automatically update so I created a cronjob to git pull every 5 minutes.

*/5 * * * * cd /srv/perlite/Notes && /usr/bin/git pull

Enable & start nginx

sudo pkill -f nginx & wait $!
sudo systemctl enable nginx --now