Install Wallabag on your server
Wallabag is an open source alternative to Pocket. With Wallabag you can save articles found on the web to read them later.
Prerequisites
- Add a non root user on your server - link
- Install a LAMP stack - link
- Configure your Apache virtual hosts - link
- Install Let’s Encrypt - link
Sources
A part of this work is based on the work of Xiao Guoan that you can find on Linuxbabe. However you can also find the same documentation on the official Wallabag documentation.
Installing composer
Getting composer.phar
As stated on the official Wallabag installation procedure compose is used to install the large number of PHP libraries used to function.
The following procedure is extracted from the composer website. At the end of the procedure
we get a composer.phar
file.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
The file composer.phar
should be accessible by the wallabag installation script.
To do so we can either place the file in the correct place, or simply install it
globally.
Installing globally
To install globally we can modify the PATH
variable to add the folder containing
the file, or move the file to a folder listed in the PATH
variable.
We choose the latter:
sudo mv composer.phar /usr/local/bin/composer
Installing php extensions
The following php extensions are required for wallabag: -php-session -php-ctype -php-dom -php-hash -php-simplexml -php-json -php-gd -php-mbstring -php-xml -php-tidy -php-iconv -php-curl -php-gettext -php-tokenizer -php-bcmath
Some of them might already be installed with PHP. Before installing them, let’s take a look at some useful commands that will help us work with php extensions.
Some general information
See if php-session module is installed :
php -m | grep session
# Output
session
Search for a package :
apt-cache search php- | grep packagename
Install a package :
sudo apt-get install packagename
Install missing extensions
Here are the php extensions usually missing
sudo apt-get install php-bcmath php-curl php-tidy
Create a database and user for Wallabag
The procedure used to create the database and a database user is not detailed on the official website. The following procedure was found on this website
From a terminal, login to mysql:
mysql -u root -p
The mysql console starts. Create a database and name it ‘wallabag’:
create database wallabag;
Create a new user in the database, we will use this user’s credentials to let wallabag use the database:
create user 'sammy'@'localhost' IDENTIFIED BY 'my_password*84';
We give privileges on the wallabag database to our new user
grant all privileges on wallabag.* to sammy@localhost identified by 'my_password*84';
We flush the privileges so that they are refreshed:
flush privileges;
And we are done with the mysql console:
exit;
Install Wallabag
First we need to install some programs that might not be installed on our server already :
sudo apt-get install make unzip zip
Then we clone the wallabag project in a newly created folder named ‘Git’:
mkdir Git
cd Git
git clone https://github.com/wallabag/wallabag.git
We should have a new directory created named ‘wallabag’. Let’s proceed to the installation :
cd wallabag/
make install
Here is the expected output (click to collapse):
You should then be asked to provide parameters :
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
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):
database_port (null): 3306
database_name (symfony): wallabag
database_user (root): sammy
database_password (null): my_password*84
database_path ('%kernel.root_dir%/../data/db/wallabag.sqlite'): /var/lib/mysql/wallabag
For the rest of the parameters you can just chose the default values
database_table_prefix (wallabag_):
database_socket (null):
database_charset (utf8):
mailer_transport (smtp):
mailer_host (127.0.0.1):
mailer_user (null):
mailer_password (null):
locale (en):
secret (ovmpmAWXRCabNlMgzlzFXDYmCFfzGv):
twofactor_auth (true):
twofactor_sender (no-reply@wallabag.org):
fosuser_registration (true):
fosuser_confirmation (true):
from_email (no-reply@wallabag.org):
rss_limit (50):
rabbitmq_host (localhost):
rabbitmq_port (5672):
rabbitmq_user (guest):
rabbitmq_password (guest):
rabbitmq_prefetch_count (10):
redis_scheme (tcp):
redis_host (localhost):
redis_port (6379):
redis_path (null):
redis_password (null):
sites_credentials ({ }):
The installation then continues
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
// Clearing the cache for the prod environment with debug
// false
[OK] Cache for the "prod" environment (debug=false) was successfully cleared.
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets
Trying to install assets as relative symbolic links.
--- ------------------------------ ------------------
Bundle Method / Error
--- ------------------------------ ------------------
✔ NelmioApiDocBundle relative symlink
✔ WhiteOctoberPagerfantaBundle relative symlink
✔ FOSJsRoutingBundle relative symlink
--- ------------------------------ ------------------
[OK] All assets were successfully installed.
In step 2, you will be asked if you would like to reset the database, answer n
(No).
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile
Installing wallabag...
Step 1 of 4. Checking system requirements.
+------------------------+--------+----------------+
| Checked | Status | Recommendation |
+------------------------+--------+----------------+
| PDO Driver (pdo_mysql) | OK! | |
| Database connection | OK! | |
| Database version | OK! | |
| curl_exec | OK! | |
| curl_multi_init | OK! | |
+------------------------+--------+----------------+
Success! Your system can run wallabag properly.
Step 2 of 4. Setting up database.
When asked if you would like to create a new admin user, answer yes and fill a name and password of your choice:
Step 3 of 4. Administration setup.
Would you like to create a new admin user (recommended) ? (Y/n)y
Username (default: wallabag) :admin
Password (default: wallabag) :another_password*78
Email:admin@mail.com
The installation finished:
Step 4 of 4. Config setup.
wallabag has been successfully installed.
Just execute `php bin/console server:run --env=prod` for using wallabag: http://localhost:8000
You can now copy the wallabag web application where you intended to serve it:
cp -r ~/Git/wallabag/* /var/www/wallabag.sammy.fr/
And give access to this directory to www-data
:
sudo chown -R www-data:www-data /var/www/wallabag.sammy.fr
Modify Virtual host
If you have already created your virtual host, you will need to modify:
wallabag.sammy.fr-le-ssl.conf
: the virtual host configuration for the HTTPS sitewallabag.sammy.conf
: the virtual host configuration for the HTTP site
vim wallabag.sammy.fr-le-ssl.conf
Here is the configuration needed
<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin sammy@gmail.com
ServerName wallabag.sammy.fr
ServerAlias www.wallabag.sammy.fr
DocumentRoot /var/www/wallabag.sammy.fr/web
<Directory /var/www/wallabag.sammy.fr/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.sammy.fr/public_html/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/wallabag_error.log
CustomLog ${APACHE_LOG_DIR}/wallabag_access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SSLCertificateFile /etc/letsencrypt/live/sammy.fr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sammy.fr/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>
web
. This is the equivalent of
the usual public_html
directory : the website document root
Report the modifications to wallabag.sammy.fr.conf and you are good to go! You just need to restart apache2 to see you web site active:
sudo systemctl restart apache2.service