Installing Shimmie2

I’m skeptical of selfhosting, but I do need a way to get my images across devices and I want to try using a booru for that. I chose Shimmie2. This is just my install experience. I might update later with how it goes using it but this is mostly so I can reinstall if I need to later. It’s also set up a bit fast and cheap, because I do expect to redo it in the next few years… hopefully declaratively.

I already have a server running Proxmox so I created a new LXC running Debian.

The plan is to access it over Tailscale, so let’s do that first. Since this container can’t create TUN devices without some extra configuration, I’m going to use Tailscale’s userspace mode. After curl | shing the installer, add FLAGS="--tun=userspace-networking" to /etc/default/tailscaled, then

systemctl restart tailscale
tailscale up

and log in.

Now we need PHP and friends (SQLite and ImageMagick). Shimmie2 asked for PHP 8.4+ and the default version was too old so we need to set up the repo

Then we can install stuff:

apt install php8.5 php8.5-fpm php8.5-sqlite3 php8.5-gd php8.5-mbstring php8.5-xml imagemagick

Then let’s clone Shimmie into /var/www/shimmie2. (I had to fiddle with it a bit because I actually cloned it into /root/shimmie2 but then Caddy couldn’t read it later so I moved it. You might not need to fiddle if you cloned it into the right place from the start?)

git clone https://github.com/shish/shimmie2 /var/www/shimmie2
chown -R www-data:www-data /var/www/shimmie2
chmod -R 755 /var/www/shimmie2

Shimmie has some setup instructions. I installed Composer right into the same directory and told it to install everything. I ran php -S 0.0.0.0:9000 tests/router.php then used Tailscale from my desktop to use the installer at http://shimmie:9000. It worked! I set up my user, uploaded a couple images, and poked through the settings.

The default file size limits are conversative, so I bumped them up a bit by editing /etc/php/8.5/fpm/php.ini and setting

post_max_size = 100M
upload_max_filesize = 100M

followed by systemctl restart php8.5-fpm. I also raised the limits in Shimmie’s board config page.

Finally, let’s set up Caddy as the web server. Set up another repo… then apt install caddy.

Stop Apache from using port 80:

systemctl stop apache2

Actually, I just uninstalled it:

apt remove apache2

Let’s vi /etc/caddy/Caddyfile and write a config. I didn’t need HTTPS since I’m going to access it over Tailscale. When nice URLs are enabled, the two rewrites are necessary for thumbnails and images to be served correctly. This config was LLM-authored with various revisions but it seems to work well enough…

{
    auto_https off
}

:80 {
    root * /var/www/shimmie2
    encode gzip zstd

    @images path_regexp images ^/_images/([0-9a-f]{2})([0-9a-f]{30}).*$
    handle @images {
        root * /var/www/shimmie2/data/images/{re.images.1}
        rewrite * /{re.images.1}{re.images.2}
    }

    @thumbs path_regexp thumbs ^/_thumbs/([0-9a-f]{2})([0-9a-f]{30}).*$
    handle @thumbs {
        root * /var/www/shimmie2/data/thumbs/{re.thumbs.1}
        rewrite * /{re.thumbs.1}{re.thumbs.2}
    }

    file_server
    php_fastcgi unix//run/php/php8.5-fpm.sock
}

And that’s it. I miss my declarativity, but the way I have things set up right now sucks, so I didn’t bother. Maybe next year.