Wallabag is a popular read-it-later service that allows users to save webpages for later reading. While there are several services available like Pocket and Instapaper, installing Wallabag on your own server provides greater control and ensures that your saved links won’t disappear if the service shuts down. In this comprehensive guide, we will walk you through the step-by-step process of installing and setting up Wallabag on a server running Ubuntu 22.04.

Prerequisites

Before we begin, make sure you have the following prerequisites in place:

  • A server running Ubuntu 22.04
  • A non-root user with sudo privileges
  • A fully qualified domain name (FQDN) like wallabag.example.com

Ensure that your system is up to date by running the following commands:

sudo apt update
sudo apt upgrade

Next, install the necessary packages by running the following command:

sudo apt install wget curl nano software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y

Step 1 – Configure Firewall

The first step is to configure the firewall on your Ubuntu server to allow necessary connections. By default, Ubuntu comes with UFW (Uncomplicated Firewall). Check if the firewall is running by running the following command:

sudo ufw status

If the firewall is inactive, you can proceed to allow SSH, HTTP, and HTTPS connections by running the following commands:

sudo ufw allow OpenSSH
sudo ufw allow http
sudo ufw allow https

Enable the firewall by running the following command:

sudo ufw enable

Verify the firewall status to ensure that the changes have been applied successfully:

sudo ufw status

Step 2 – Install PHP and its Extensions

Ubuntu 22.04 ships with PHP 8.1.2, but we will install the latest PHP 8.1 version using Ondrej’s PHP repository. Run the following commands to add the repository and install PHP and its extensions required by Wallabag:

sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.1-fpm php8.1-mysql php8.1-bcmath php8.1-xml php8.1-zip php8.1-curl php8.1-mbstring php8.1-gd php8.1-tidy php8.1-intl php8.1-cli

Verify the installation by running the following command:

php --version

Step 3 – Install Composer

Composer is a dependency management tool for PHP and is required for Wallabag installation. Run the following commands to download and install Composer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --2.2
php -r "unlink('composer-setup.php');"

Verify the installation by running the following command:

composer --version

Step 4 – Install MySQL

Ubuntu 22.04 ships with the latest version of MySQL. Install it by running the following command:

sudo apt install mysql-server

Check the version of MySQL by running the following command:

mysql --version

Step 5 – Configure MySQL

Log in to the MySQL shell as the root user:

sudo mysql -u root -p

Set the password for the root user by running the following command. Replace ‘YourPassword12!’ with a strong password of your choice:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPassword!';

Exit the MySQL shell by running the following command:

exit

Run the MySQL secure install script to improve the security of your MySQL installation:

sudo mysql_secure_installation

Follow the prompts to set up the MySQL security options. It is recommended to remove anonymous users, disallow remote root logins, remove the test database, and reload the privilege tables.

Step 6 – Install Nginx

Ubuntu 22.04 ships with an older version of Nginx. To install the latest version, we need to add the official Nginx repository. Run the following commands to import Nginx’s signing key and add the repository:

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg arch=amd64] http://nginx.org/packages/ubuntu lsb_release -cs nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update
sudo apt install nginx

Verify the installation by running the following command:

nginx -v

Start the Nginx server by running the following command:

sudo systemctl start nginx

Step 7 – Install SSL

To secure your Wallabag installation, we will install an SSL certificate using Certbot. We will use the Snapd version of Certbot. Run the following commands to ensure that Snapd is up to date and to install Certbot:

sudo snap install core && sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Generate an SSL certificate by running the following command. Replace ‘wallabag.example.com’ with your own domain name:

sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m test@example.com -d wallabag.example.com

Generate a Diffie-Hellman group certificate by running the following command:

sudo openssl dhparam-dsaparam -out /etc/ssl/certs/dhparam.pem4096

Check the Certbot renewal scheduler service by running the following command:

sudo systemctl list-timers

To test the SSL renewal process, run the following command:

sudo certbot renew --dry-run

Step 8 – Install Wallabag

Create the necessary directories and download the latest version of Wallabag by running the following commands:

sudo mkdir /var/www/html/wallabag-p
wget https://wllbg.org/latest-v2-package
tar xzf latest-v2-package
sudo mv wallabag-2.5.4/* /var/www/html/wallabag

Create the asset directory by running the following command:

sudo mkdir /var/www/html/wallabag/data/assets

Change the ownership of the Wallabag directory to the currently logged-in user by running the following command. Replace ‘username’ with your own username:

sudo chown -R username:username /var/www/html/wallabag

Copy the example parameters file to create the actual parameters file by running the following command:

cp /var/www/html/wallabag/app/config/parameters.yml.dist /var/www/html/wallabag/app/config/parameters.yml

Generate a secret key by running the following command and note it down for later use:

openssl rand-base64 32

Open the parameters file for editing:

nano /var/www/html/wallabag/app/config/parameters.yml

Find the database section and fill in the database credentials, server description, domain name, SMTP details, and secret key. Refer to the example below:

..........
    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: 3306
    database_name: wallabag
    database_user: wallabaguser
    database_password: Your_password2
domain_name: https://wallabag.example.com
    server_name: "ShapeHost Wallabag"
mailer_transport:  smtp
    mailer_user:       YOUR_AES_USERNAME
    mailer_password:   YOUR_AES_PASSWORD
    mailer_host:       email-smtp.us-west-2.amazonaws.com
    mailer_port:       587
    mailer_encryption: tls
   # A secret key that's used to generate certain security-related tokens
    secret: QLV/GpZwDobQbyQZQ15FkM1Hvt+ZFJZXw8GW9F4KR3o=

    # two factor stuff
    twofactor_auth: true
    twofactor_sender: no-reply@wallabag.org

    # fosuser stuff
    fosuser_registration: true
    fosuser_confirmation: true
.....
    from_email: no-reply@wallabag.org
.....

Save the file and exit the editor.

Install the Wallabag dependencies by running the following command:

SYMFONY_ENV=prod composer install --no-dev -o --prefer-dist

Finish the installation using the Wallabag command-line tool:

php /var/www/html/wallabag/bin/console wallabag:install --env=prod

During the installation process, you will be prompted to reset the database and schema. Choose ‘no’ for both prompts. Next, you will be asked if you want to create an administrator account. Choose ‘yes’ and provide the username, password, and email for the account.

Change the ownership of the Wallabag directory back to Nginx by running the following command:

sudo chown -R nginx:nginx /var/www/html/wallabag

Step 9 – Configure Nginx and PHP

Open the Nginx configuration file for Wallabag:

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

Replace the contents of the file with the following code:

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name wallabag.example.com;
access_log /var/log/nginx/wallabag.access.log;
error_log /var/log/nginx/wallabag.error.log;

# SSL
ssl_certificate /etc/letsencrypt/live/wallabag.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/wallabag.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/wallabag.example.com/chain.pem;
ssl_session_timeout 5m;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
resolver 8.8.8.8;

root /var/www/html/wallabag/web;

location / {
try_files $uri /app.php$is_args$args;
}

# Pass PHP Scripts To FastCGI Server
location ~ ^/app\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass unix:/run/php/php8.1-fpm.sock; # Depends On The PHP Version
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
include fastcgi_params;
internal;
}

location ~ \.php$ {
return 404;
}
}

# Enforce HTTPS
server {
listen 80;
listen [::]:80;
server_name wallabag.example.com;
return 301 https://$host$request_uri;
}

Save the file and exit the editor.

To ensure the Nginx configuration file syntax is correct, run the following command:

sudo nginx -t

If there are no errors, restart the Nginx service by running the following command:

sudo systemctl restart nginx

Step 10 – Access Wallabag

Open your browser and enter your domain name (e.g., https://wallabag.example.com). You will be greeted with the Wallabag login screen. Enter the credentials you created during the installation process and click the “LOG IN” button to proceed. You will now have access to the Wallabag dashboard.

Wallabag provides various apps, browser extensions, and a bookmarklet to help you save articles for later reading. You can find links to these tools in the “How to” section, accessible by clicking the user icon in the top right corner of the dashboard.

Conclusion

Congratulations! You have successfully installed and set up Wallabag on your Ubuntu 22.04 server. Now you can enjoy the benefits of having your own read-it-later service, with complete control over your saved links. If you have any questions or need further assistance, please feel free to reach out in the comments below.

Don’t forget to check out Shape.host’s Cloud VPS services for reliable and scalable cloud hosting solutions. Shape.host provides top-notch performance and security, ensuring your Wallabag installation runs smoothly.