How to set up Perlite for Obsidian

Perlite is a web interface for the note taking app Obsidian. It’s a selfhosted alternative for their cloud vault. I wanted to set it up to allow my classmates to see my notes, and also to check them on computers that aren’t my own.

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!!! ex. A Record - notes.soulsender.me > 11.22.33.44

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