Install Wallabag on Ubuntu 16.04 Server with LAMP or LEMP

Wallabag is a free self-hostable application for saving web pages. It’s an open source alternative to other proprietary read later app like Pocket and Instapaper, allowing you to manage a list of articles you stumbled upon on the Internet for later reading.

Wallabag Features:

  1. Wallabag strips ads and unrelated stuff from your web pages and provide only article text and related images so they can be easily read. This is especially useful when you are viewing them on a smartphone or tablet.
  2. Wallabag saves your web pages in a database so even if the original web page disappears, you can still view it in Wallabag.
  3. You can easily export all your web page to TXT, HTML, CSV, EPUB, MOBI, PDF, or JSON file.
  4. You can also install the Wallabag browser extension and smartphone app to easily access Wallabag.
  5. The ability to import bookmarks from Firefox and Google Chrome ( or Chromium) browser.

This tutorial covers how to host your own Wallabag service on an Ubuntu 16.04 server or VPS.

Prerequisites

To install wallabag, you will need to have access to a user with root privileges.

It’s assumed that you have already set up a LAMP stack or LEMP stack on Ubuntu 16.04. Wallabag is able to run with PHP >= 5.5, including PHP 7. If you haven’t already done so, check out the following easy to follow guides.

Once you are done, come back here and read on.

Log in Via SSH

Log in to your server as the new user that you created (or root) via SSH (substitute your user name and server IP address here):

ssh new_user@server_IP_address

Answer the password prompt to complete the login process.

Let’s get started with the Wallabag installation!

Step 1: Create a Database and User for Wallabag

Wallabag needs a database to store your web pages and we are going to use MariaDB/MySQL database in this tutorial. Run the following command to log into MariaDB/MySQL shell as root. Note that this is the MariaDB/MySQL root user, not the root user of Ubuntu 16.04 system.

mysql -u root -p

If you see Access denied for user 'root'@'localhost' error, then you need to disable unix socket authentication.

Then create a new database for Wallabag using the following command. This tutorial name it wallabag, you can use whatever name you like for the database.

create database wallabag;

Next, create a new database user on localhost using the following command. Again, this tutorial name it wallabaguser, you can use whatever name you like.

create user wallabaguser@localhost;

Set a password for the user. Replace your-password with your preferred password.

set password for wallabaguser@localhost= password("your-password");

Then grant all permission of the new database to the new user so later on Wallabag can write to the database.

grant all privileges on wallabag.* to wallabaguser@localhost identified by 'your-password';

Flush the privileges table for the changes to take effect.

flush privileges;

Exit MariaDB Shell:

exit;

Your web pages will be stored in wallabag_entry table after you finished installing wallabag at the end of this tutorial.

Step 2: Install php7.0-mysql Package

Another important thing we need to do concerning the database is install the php7.0-mysql package.

sudo apt install php7.0-mysql

The php7.0-mysql packages provides the pdo_mysql driver which will be used by wallabag to connect to MariaDB/MySQL database, otherwise Wallabag has no way to connect to it. If you are running PHP as an Apache module, then after the package is installed, you must restart Apache Web server so the driver will be enabled.

sudo systemctl restart apache2

If you are running PHP with php7.0-fpm, then you don’t need to restart Apache or php7.0-fpm. The pdo_mysql driver will be enable automatically after installed.

If you are not sure whether you are using Apache module or php7.0-fpm, then create a test.php file under the document root (by default /var/www/html).

sudo nano /var/www/html/test.php

Then paste the following PHP code into the file.

<?php phpinfo(); ?>

Press Ctrl+O to save the file, then press Ctrl+X to exit. Now in the browser address bar, enter

server-ip-address/test.php

Replace sever-ip-address with your actual IP. You should see your server’s PHP information. If the value of Server API is Apache 2.0 Handler, then you are using PHP7.0 as an Apache Module. If the value is PHP7.0-FPM, then PHP is running as a FPM service.

Step 3: Install Wallabag

We will use the git tool to clone the Wallabag repository from Github and later install Wallabag with Composer. So install git on Ubuntu 16.04 with the below command:

sudo apt install git

Then clone the Wallabag repository and change your working directory to the repository.

git clone https://github.com/wallabag/wallabag.git

cd wallabag

The lastest version of Wallabag (2.1.2) was released on October 17, 2016. Switch to version 2.1.2 with the git checkout command.

git checkout 2.1.2

Before we install Wallabag with Composer, we need to make sure the following PHP extensions are installed on Ubuntu 16.04.

sudo apt install php7.0-bcmath php7.0-xml php7.0-zip php7.0-curl php7.0-mbstring php7.0-gd

Next, we need to install Composer which is a dependency manager for PHP. It will download and install all necessary Wallabag dependencies for us.

sudo apt install composer

Now set Symfony variable and install Wallabag using the following command. SYMFONY_ENV=prod tells symfony we’re installing Wallabag in a production environment. The --no-dev flag ensures that no development packages are installed in production environment.

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

During the installation process, composer will download and install all needed dependencies.

After that, you will be asked to provide missing parameters so that the app/config/parameters.yml file can be created. Composer already provides some default values but they cannot be used for a production Wallabag service.

For simplicity, let’s break the questions into two parts. The first part is about database parameters. Here is the questions and the parameters this tutorial provides.

Creating the "app/config/parameters.yml" file
 Some parameters are missing. Please provide them.
 database_driver (pdo_sqlite): pdo_mysql
 database_host (127.0.0.1): 127.0.0.1
 database_port (null): 3306
 database_name (symfony): wallabag
 database_user (root): wallabaguser
 database_password (null): your-password
 database_path ('%kernel.root_dir%/../data/db/wallabag.sqlite'): /var/lib/mysql/wallabag
 database_table_prefix (wallabag_): wallabag_

This first question is what database driver, i.e, what database you want to use for Wallabag. The default driver is pdo_sqlite which means SQLite database will be used to store web pages. This article will use MariaDB/MySQL because they are speedy and are the most popular open source relation database management system. We have already enabled the pdo_mysql driver in the beginning of this article. So enter pdo_mysql as the answer for the first question.

The other questions are easy to answer. Enter 127.0.0.1 as the database host and 3306 as the database port because by default MariaDB/MySQL database will listen on 127.0.0.1:3306. Then enter the database name, database user and database user password you created in step 1. The default database path of MariaDB/MySQL is /var/lib/mysql. All you databases and tables are stored under this directory. The database table prefix helps you to recognize these tables are for Wallabag.

Now in the second part you can just press Enter to use the default values.

 mailer_transport (smtp):
 mailer_host (127.0.0.1): 
 mailer_user (null): 
 mailer_password (null):
 locale (en): 
 secret (ovmpmAWXRCabNlMgzlzFXDYmCFfzGv): 
 twofactor_auth (true): 
 twofactor_sender ([email protected]): 
 fosuser_confirmation (true): 
 from_email ([email protected]):

Once that’s done, run the following command.

php bin/console wallabag:install --env=prod

It will check system requirements and set up database. When it asks would you like to reset the database, press n to answer no. Then you will be asked to create an admin user.

Installing Wallabag...

Step 1 of 5. Checking system requirements.
+-----------------+--------+----------------+
| Checked         | Status | Recommendation |
+-----------------+--------+----------------+
| PDO Driver      | OK!    |                |
| curl_exec       | OK!    |                |
| curl_multi_init | OK!    |                |
+-----------------+--------+----------------+
Success! Your system can run Wallabag properly.

Step 2 of 5. Setting up database.
It appears that your database already exists. Would you like to reset it? (y/N)n
Creating schema
Clearing the cache

Step 3 of 5. Administration setup.
Would you like to create a new admin user (recommended) ? (Y/n)y
Username (default: wallabag) : your-admin-username
Password (default: wallabag) : admin-pasword-here
Email: admin-email-here

Step 4 of 5. Config setup.

Step 5 of 5. Installing assets.

Wallabag has been successfully installed.
Just execute `php bin/console server:run --env=prod` for using wallabag: http://localhost:8000

Step 2 will create wallabag database tables. Once that’s done, we move the wallabag directory to  /var/www/.

cd ~

sudo mv ~/wallabag/ /var/www/

Then set Apache user (www-data) as the owner.

sudo chown www-data:www-data /var/www/wallabag -R

Step 4: Set up Apache Virtual Host

Create a virtual host configuration file for Wallabag.

sudo nano /etc/apache2/sites-available/wallabag.conf

If you use PHP as an Apache module, then copy and paste the following text into the configuration file. Replace wallabag.example.com with your own domain name. You should also point your domain name to the IP address of your Ubuntu 16.04 server in DNS.

<VirtualHost *:80>
    ServerName wallabag.exmaple.com
    ServerAlias wallabag.example.com

    DocumentRoot /var/www/wallabag/web
    <Directory /var/www/wallabag/web>
        AllowOverride None
        Order Allow,Deny
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeScript assets
    # <Directory /var/www/wallabag>
    #     Options FollowSymlinks
    # </Directory>

    # optionally disable the RewriteEngine for the asset directories
    # which will allow apache to simply reply with a 404 when files are
    # not found instead of passing the request into the full symfony stack
    <Directory /var/www/wallabag/web/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
        </IfModule>
    </Directory>
    ErrorLog /var/log/apache2/wallabag_error.log
    CustomLog /var/log/apache2/wallabag_access.log combined
</VirtualHost>

The above configuration uses PHP as an Apache module, if you want to run PHP with php7.0-fpm, then add the ProxyPassMatch rule below CustomLog.

.....
CustomLog /var/log/apache2/wallabag_access.log combined
 ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.0-fpm.sock|fcgi://localhost/var/www/wallabag/web/
</VirtualHost>

Save and close the file. In the above configuration, we used the Apache rewrite module to rewrite URL. We need to make sure mod_rewrite is enabled by running the following command so that URL rewriting will be working and Wallabag front end can be properly displayed.

sudo a2enmod rewrite

Then enable this virtual host by creating a symbolic link.

sudo ln -s /etc/apache2/sites-available/wallabag.conf /etc/apache2/sites-enabled/

And to put the above changes into effect, restart Apache.

sudo systemctl restart apache2

Now you should be able to access your Wallabag web interface at wallabag.example.com and login.

wallabag read later

Setting up Nginx Server Block File

Create the file.

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

Copy and paste the following text into the configuration file. Replace wallabag.example.com with your own domain name. You should also point your domain name to the IP address of your Ubuntu 16.04 server in DNS.

server {
  server_name wallabag.example.com;
  root /var/www/wallabag/web;

  location / {
    # try to serve file directly, fallback to app.php
    try_files $uri /app.php$is_args$args;
  }
  location ~ ^/app\.php(/|$) {
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    internal;
}

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

Save and close the file. Then reload Nginx so the server block can be enabled.

sudo systemctl reload nginx

Now you should be able to access your wallabag web interface at wallabag.example.com and login.

Setting Up a Basic SMTP Server

Note that in order to register new users, your Ubuntu 16.04 server needs to have a SMTP server running to send confirmation emails to new users. You can use Postfix for this purpose.

sudo apt install postfix

During the installation, it will ask you to select a configuration type for Postfix. Select Internet Site so that Postfix can send emails to other SMTP servers on the Internet.

Selection_005

In the system mail name field, enter something like wallabag.your-domain.com.

Selection_006

And now we are finally done and can start saving web pages. Cheers!

install wallabag on ubuntu 16.04 server

I hope this tutorial helped you to install Wallabag on Ubuntu 16.04 server with LAMP or LEMP. As always, if you found this post useful,  subscribe to our free newsletter or follow us on Google+Twitteror like our Facebook page.

Rate this tutorial
[Total: 6 Average: 4.3]

9 Responses to “Install Wallabag on Ubuntu 16.04 Server with LAMP or LEMP

  • Richard Hemmer
    8 years ago

    Thanks a bunch for that detailed walk-through. I tried installing Wallabag before but despaired over their somewhat sparse documentation.

  • hotsoup
    8 years ago

    Great tutorial! I was having trouble following wallabag’s own installation docs.

    I do have one question. I have a large .json export file from a wallabag v1 instance. Wallabag v2 doesn’t like large files, so the devs recommend using the command line to import the .json file with this command:

    bin/console wallabag:import-v1 1 ~/Downloads/wallabag-export-1-2016-04-05.json –env=prod

    Their instructions for this are from this page: http://doc.wallabag.org/en/master/user/migration.html

    However, when I run the command, I get an error saying that no file or directory for “bin/console” can be found.

    Do I need to get back in to symfony or the wallabag directory for this command to work? I’m a little lost.

    Thanks!

    • Xiao Guoan
      8 years ago

      Hi. The wallabag directory was moved to /var/www/ in this tutorial. You will find bin/console under /var/www/wallabag/.

  • Hi thank you for the tutorial. When I set up Wallabag I end up with a login page that is empty of any color or style, just a plain text log in page that doesn’t work. Any suggestions? Thank you. I’m on Ubuntu 16.04 Server with Apache and PHP 7.0, MariaDB

  • Vincent Bonnefille
    6 years ago

    Hello
    Am very happy to find this amazing garden…
    you really take time to clearly exlain for n00bs like me 😉

    I have an error, I cant figure out but, when I start walla for the first time (completing your tutorial)…
    opening http(|s)://192.168.1.17/ (local ip for the first shoot)
    am redirected to /login/, greate, ok, favicon loading, huhuhuuu
    but the page still blank, the code too.
    I allready try this https://github.com/wallabag/wallabag/issues/2529

    Do you have any clue ?
    I will searching arround my mysql config.
    Thanks, again

  • Hi, first thanks for all the very good tutorial here!
    I’m installing wallabag on Ubuntu 18.04, where I’m asked for the following informations:
    database_driver (pdo_mysql): pdo_mysql
    database_driver_class (null):
    database_table_prefix (wallabag_): wallabag_
    database_socket (null):
    I was looking around, but couldn’t find any working answer.
    Do you have any Idea how to solve this?
    Thanks in advance!

    • Got it working, thanks to original dokumantation 😀

      go to wallabag folder:
      cd /var/www/wallabag
      clear cache and open parameters.yml:
      sudo php bin/console cache:clear -e=prod
      sudo nano app/config/parameters.yml
      put in following parameters:
      database_driver_class: ~
      database_socket: null

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here