How to Install Shaarli on Void Linux

Shaarli is a free and open-source self-hosted bookmarking tool that can run on your server, providing you with a simple and convenient way to store, manage, and share your bookmarks.

This tutorial will guide you through the process of installing Shaarli on Void Linux.

Prerequisites

Step 1: Update and Upgrade Your System

Before you start installing Shaarli, it is recommended to update and upgrade your system to ensure that all packages are up to date. To do so, run the following commands:

sudo xbps-install -Syu
sudo xbps-install -y xbps-triggers
sudo xbps-install -y bash-completion
sudo xbps-install -y sudo git

Step 2: Install Nginx, PHP-fpm, and PostgreSQL

Shaarli requires a web server, PHP-fpm, and a database system to run. In this tutorial, we will be using Nginx, PHP-fpm, and PostgreSQL as a database.

To install Nginx, run the following command:

sudo xbps-install -y nginx

To install PHP-fpm and associated modules, run the following command:

sudo xbps-install -y php7-fpm php7-session php7-pdo php7-pdo_pgsql php7-curl php7-mbstring php7-opcache php7-json php7-xml

To install PostgreSQL, run the following command:

sudo xbps-install -y postgresql postgresql-contrib

Step 3: Configure PostgreSQL

After installing PostgreSQL, create a new database and user by running the following commands:

sudo su - postgres
createdb shaarli
createuser shaarli
psql

In the PostgreSQL prompt, run the following commands to assign a password to the shaarli user and provide it with the necessary permissions:

ALTER USER shaarli PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE shaarli TO shaarli;
\q
exit

Step 4: Clone Shaarli Repository

Now, clone the Shaarli repository from GitHub with the following command:

sudo mkdir -p /var/www/ && cd /var/www
sudo git clone https://github.com/shaarli/Shaarli.git shaarli

Step 5: Configure Nginx

Create a new Nginx server block to serve Shaarli by running the following command:

sudo nano /etc/nginx/conf.d/shaarli.conf

Add the following lines to the file:

server {
    listen 80;
    server_name example.com;  # replace with your domain
    root /var/www/shaarli;
    index index.php;

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

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass unix:/run/php7-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Save and close the file.

Step 6: Configure Shaarli

Copy the default Shaarli configuration file to the correct location with the following command:

sudo cp /var/www/shaarli/config.default.php /var/www/shaarli/config.php

Edit the configuration file with the following command:

sudo nano /var/www/shaarli/config.php

Replace the existing configuration with the following lines:

<?php
$config['ENABLE_ADDONS'] = false;
$config['DEBUG_MODE'] = false;
$config['DATADIR'] = '/var/www/shaarli/data';
$config['USE_APACHE_MOD_REWRITE'] = false;
$config['HIDE_FOOTER'] = true;
$config['PAGE_CACHE_TTL'] = 120;
$config['FRIENDLY_URLS'] = true;
$config['PAGINATION_LIMIT'] = 20;
$config['PRIVATE_LINKS_BY_DEFAULT'] = false;
$config['ALLOWED_TAGS'] = '<b><i><u><s><strike><code><pre><img><a>';
$config['CHECK_LINKS_STATUS'] = true;
$config['FEED_PAGINATION'] = true;
$config['PUBLIC_FEED_MIN_ENTRIES'] = 8;
$config['ENABLE_CACHING'] = true;
$config['ENABLE_AUTOUPDATE'] = false;
$config['ENABLE_LOCAL_BROWSER_CACHE'] = true;
$config['DATABASE_TYPE'] = 'pgsql';
$config['DATABASE_HOST'] = 'localhost';
$config['DATABASE_USER'] = 'shaarli';
$config['DATABASE_PASSWORD'] = 'password';
$config['DATABASE_NAME'] = 'shaarli';
$config['ACCOUNTS_ENABLE'] = false;
$config['LOG_FILE'] = '/var/log/nginx/shaarli.log';
$config['LOG_LEVEL'] = '';
$config['ENABLE_TRACKING'] = false;
$config['SHARE_TITLE'] = '';
$config['SHARE_DESCRIPTION'] = '';
?>

Save and close the file.

Step 7: Start Services and Test Shaarli

To start the services, run the following commands:

sudo systemctl start php-fpm
sudo systemctl start nginx

To test that Shaarli is working correctly, navigate to your server's IP address or domain in a web browser, and you should be able to see the Shaarli welcome screen.

Conclusion

Congratulations! You have successfully installed Shaarli on your Void Linux server. You can now use it as your self-hosted bookmarking tool.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!