After I got Shaarli setup, I realized that a lot of bookmarks I had imported had broken links and I had no idea what those links were and what they contained.

This caused me a bit of grief, until I came across this software called Wallabag.

Wallabag promised to save pages to my server after cleaning up scripts and unnecessary junk from the html pages.

And the best part was I could choose from Shaarli which pages to save for posterity in Wallabag!

Install software

I wanted to set up Wallabag with SQLite, so I had to install some corresponding libraries.

sudo apt-get install -y composer
sudo apt-get install -y php-gd
sudo apt-get install -y php-curl
sudo apt-get install -y php-bcmath
sudo apt-get install -y php7.0-sqlite

After this, I had a bit of struggle until I realized that I needed to change the php.ini config. This file was located for me at /etc/php/7.0/fpm/php.ini

I had to uncomment the following line.

extension=php_pdo_sqlite.dll

Modify Wallabag template

The other important part was to modify the wallabag template file (template.yml) to configure it for my site.

This file is located under /wallabag folder/app/config/

# database_driver: %env.database_driver%
# database_host: %env.database_host%
# database_port: %env.database_port%
# database_name: %env.database_name%
# database_user: %env.database_user%
# database_password: %env.database_password%

# database_driver: pdo_mysql
database_driver: pdo_sqlite
database_driver_class: ~
# database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver
# database_host: 127.0.0.1
# database_port: ~
# database_name: wallabag
# database_user: root
# database_password: ~
# For SQLite, database_path should be "%kernel.project_dir%/data/db/wallabag.sqlite"
database_path: %kernel.project_dir%/data/db/wallabag.sqlite
database_table_prefix: wallabag_
database_socket: null

Make directories writable

Certain directories that wallabag creates needs to be writable by nginx. And since nginx runs as user www-data, I had to grant that user access to these directories.

sudo chown -R www-data:www-data wallabag folder/vendor/friendsofsymfony
sudo chmod -R 755 wallabag folder/vendor/friendsofsymfony

sudo chown -R www-data:www-data wallabag folder/var/cache/prod
sudo chmod -R 755 wallabag folder/var/cache/prod

sudo chown -R www-data:www-data wallabag folder/data
sudo chmod -R 755 data

Configure Nginx

Finally, as usual, configure Nginx to read wallabag properly.

server {

  listen       80;
  server_name  url-for-wallabag;
  root         /path/to/wallabag folder/web;

  error_log    /var/log/nginx/wallabag_error.log;
  access_log   /var/log/nginx/wallabag_access.log;

  location / {
    # try to serve file directly, fallback to app.php
    try_files $uri /app.php$is_args$args;
  }

  location ~ ^/app\.php(/|$) {
    # if, for some reason, you are still using PHP 5,
    # then replace /run/php/php7.0 by /var/run/php5
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    # When you are using symlinks to link the document root to the
    # current version of your application, you should pass the real
    # application path instead of the path to the symlink to PHP
    # FPM.
    # Otherwise, PHP's OPcache may not properly detect changes to
    # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
    # for more information).
    fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    # Prevents URIs that include the front controller. This will 404:
    # http://domain.tld/app.php/some-path
    # Remove the internal directive to allow URIs like this
    internal;
  }

  # return 404 for all other php files not matching the front controller
  # this prevents access to other php files you don't want to be accessible.
  location ~ \.php$ {
    return 404;
  }

}

All set now!

After setting up Wallabag, I was really pleased how well it rendered in mobile and how much more readable sites were. Also, Wallabag would remember till where I had read that page and open the page at that point so I could resume without having to scroll down again.

Fabulous!

Shaarli and Wallabag together is indeed a great combination.