Installing Shaarli on nixOS
Shaarli is a minimalist link sharing service that allows you to save bookmarks to URLs, videos, or images on a self-hosted server. In this tutorial, we will walk through the steps to install Shaarli on nixOS.
Prerequisites
Before we start, make sure you have the following:
- NixOS installed (version 21.05 or later)
- A basic understanding of terminal commands
Steps
- Update your system
sudo nixos-rebuild switch --upgrade
- Create a new user for Shaarli
sudo useradd -m -s /bin/bash shaarli
- Install PHP
sudo nix-env --install php
- Install lighttpd
sudo nix-env --install lighttpd
- Clone the Shaarli repository
sudo git clone https://github.com/shaarli/Shaarli.git /var/www/shaarli
- Change ownership of the Shaarli repository to the
shaarliuser
sudo chown -R shaarli:shaarli /var/www/shaarli
- Create a lighttpd configuration file for Shaarli
sudo nano /etc/lighttpd/conf.d/shaarli.conf
$HTTP["host"] =~ "shaarli.example.com" {
server.document-root = "/var/www/shaarli"
url.rewrite-if-not-file = (
"^/.(.+)$" => "/index.php?$1"
)
fastcgi.server = (".php" =>
((
"socket" => "/run/php-fpm.sock",
"bin-path" => "/run/current-system/sw/bin/php-cgi"
))
)
}
- Restart lighttpd
sudo systemctl restart lighttpd.service
- Access Shaarli on your web browser
You can now access Shaarli by entering the URL http://shaarli.example.com on your web browser. Note that you need to substitute shaarli.example.com with your own domain or IP address.
Conclusion
In this tutorial, we have installed Shaarli, a minimalist link sharing service, on nixOS. By self-hosting Shaarli, you can avoid giving away your browsing data to third-party services and have full control over your bookmarks.