Skip to content

Instantly share code, notes, and snippets.

@yomli
Last active July 9, 2024 00:40
Show Gist options
  • Save yomli/cc4185eda47a929ab2e314ac8cce6425 to your computer and use it in GitHub Desktop.
Save yomli/cc4185eda47a929ab2e314ac8cce6425 to your computer and use it in GitHub Desktop.
Install Wallabag on a shared web hosting in a subfolder with SQLite

Update April 2021: See this comment for a smoother install of Wallabag 2.4.x. I'll leave this gist up for legacy.


Please note that this trick works with the latest release of Wallabag (2.3.7). There is no guarantee that it'll continue to work. Eventually, Wallabag will drop support of SQLite so this setup isn't future-proof.

Install Wallabag 2.2.3

This is the last version with SQLite support that works in a subfolder (like mydomain.tld/wallabag, although deploying Wallabag in a subfolder isn't officially supported). It will allow you to create an user and start the configuration. Get it here: https://static.wallabag.org/releases/, then tar xvf wallabag-release-2.2.3.tar.gz. If this release doesn't work, use the 2.2.2 one. Normally, you will have a file app/config/parameters.yml like that:

parameters:
    database_driver: pdo_sqlite
    database_host: 127.0.0.1
    database_port: null
    database_name: symfony
    database_user: root
    database_password: null
    database_path: '%kernel.root_dir%/../data/db/wallabag.sqlite'
    database_table_prefix: wallabag_
    database_socket: null
    database_charset: utf8

Create a new user, configure as your convenience.

Upgrade to Wallabag 2.3.7

In a distinct folder, install the latest release: wget https://wllbg.org/latest-v2-package && tar xvf latest-v2-package. By default, this release uses MySQL, so you must change the file app/config/parameters.yml:

parameters:
    database_driver: pdo_sqlite
    database_driver_class: null
    database_host: 127.0.0.1
    database_port: null
    database_name: symfony
    database_user: root
    database_password: null
    database_path: '%kernel.root_dir%/../data/db/wallabag.sqlite'
    database_table_prefix: wallabag_
    database_socket: null
    database_charset: utf8mb4
    domain_name: 'http://localhost/wallabag/web'

Note that for domain_name you must point it to the web folder without a trailling slash.

From here, you can follow the upgrade documentation:

  1. Copy the SQLite database from your 2.2.3 folder to data/db/wallabag.sqlite.
  2. Open it with an appropriate tool to apply the migration queries.

Just in case I copy these queries here:

INSERT INTO wallabag_craue_config_setting (name, value, section) VALUES ('share_scuttle', '1', 'entry');
INSERT INTO wallabag_craue_config_setting (name, value, section) VALUES ('scuttle_url', 'http://scuttle.org', 'entry');

ALTER TABLE wallabag_entry ADD COLUMN published_at DATETIME DEFAULT NULL;
ALTER TABLE wallabag_entry ADD COLUMN published_by CLOB DEFAULT NULL;

DROP INDEX uid;
DROP INDEX created_at;
DROP INDEX IDX_F4D18282A76ED395;
CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, http_status, published_at, published_by FROM wallabag_entry;
DROP TABLE wallabag_entry;
CREATE TABLE wallabag_entry (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid VARCHAR(23) DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, http_status VARCHAR(3) DEFAULT NULL COLLATE BINARY, published_at DEFAULT NULL, published_by CLOB DEFAULT NULL, PRIMARY KEY(id));
INSERT INTO wallabag_entry (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, http_status, published_at, published_by) SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, http_status, published_at, published_by FROM __temp__wallabag_entry;
DROP TABLE __temp__wallabag_entry;
CREATE INDEX uid ON wallabag_entry (uid);
CREATE INDEX created_at ON wallabag_entry (created_at);
CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id);

DELETE FROM wallabag_craue_config_setting WHERE name = 'download_pictures';

CREATE TABLE wallabag_site_credential (id INTEGER NOT NULL, user_id INTEGER NOT NULL, host VARCHAR(255) NOT NULL, username CLOB NOT NULL, password CLOB NOT NULL, createdAt DATETIME NOT NULL, PRIMARY KEY(id));
CREATE INDEX idx_user ON wallabag_site_credential (user_id);

ALTER TABLE wallabag_entry ADD COLUMN headers CLOB DEFAULT NULL;

CREATE TEMPORARY TABLE __temp__wallabag_annotation AS
SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
FROM wallabag_annotation;
DROP TABLE wallabag_annotation;
CREATE TABLE wallabag_annotation
(
id INTEGER PRIMARY KEY NOT NULL,
user_id INTEGER DEFAULT NULL,
entry_id INTEGER DEFAULT NULL,
text CLOB NOT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
quote CLOB NOT NULL,
ranges CLOB NOT NULL,
CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES wallabag_user (id),
CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES wallabag_entry (id) ON DELETE CASCADE
);
CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id);
CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id);
INSERT INTO wallabag_annotation (id, user_id, entry_id, text, created_at, updated_at, quote, ranges) SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
FROM __temp__wallabag_annotation;
DROP TABLE __temp__wallabag_annotation;

INSERT INTO wallabag_craue_config_setting (name, value, section) VALUES ('api_user_registration', '0', 'api');

DELETE FROM wallabag_craue_config_setting WHERE name = 'wallabag_url';

ALTER TABLE wallabag_entry ADD COLUMN starred_at DATETIME DEFAULT NULL;

ALTER TABLE wallabag_entry ADD COLUMN origin_url CLOB DEFAULT NULL;

INSERT INTO wallabag_craue_config_setting (name, value, section) VALUES ('store_article_headers', '0', 'entry');

INSERT INTO wallabag_craue_config_setting (name, value, section) VALUES ('shaarli_share_origin_url', '0', 'entry');

Tweaks

At this point, you can erase the 2.2.3 folder and connect to the address domain_name. If you don't want that anybody else register a new account, you can put this at the end of the web/.htaccess file:

<FilesMatch ".*register$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

Upgrade?

To upgrade Wallabag to a newer version, you'll have to save two files and a folder: data/, app/config/parameters.yml, and web/.htaccess. That's all.

But since Wallabag is about 125MB with 16,000+ files (that's more than Nextcloud!), it quickly become tedious to upload every new release on a SFTP. If your web hosting supports it, I advise you to use a SSH access.

Localhost?

This tutorial works on local XAMP if you take into account that there are many simlinks. You will have to replace them by hand if your XAMP does not follow them.

MySQL?

I didn't try with MySQL. I think if you follow this tutorial you may be able to get a working Wallabag 2.3.7 in a subfolder with MySQL as a database, as long as you use the migration queries.

@KenyOS
Copy link

KenyOS commented Sep 9, 2019

How can I configure in my nginx.conf?

@yomli
Copy link
Author

yomli commented Sep 9, 2019

Please read the official documentation. This gist is just a tip for installing Wallabag on a shared hosting in a subfolder with SQLite, and it isn't the recommended way to install.

But I think the only part of this gist where nginx could differ is the Tweaks part. Since you can disable any new registration in the Wallabag admin settings, I suspect you don't have to configure your nginx.conf at all. Nevertheless, I can point to this official config and say you could try to replace the .htaccess in the Tweaks part by this:

location ~ ^/register\.php(/|$) {
    return 404;
}

@KenyOS
Copy link

KenyOS commented Sep 10, 2019

oh thanks Yomli. I know I did read your comments on the one of issues from Wallabag repo. I have a Home Server and I'm having a lot of problems to host wallabag using nginx with others services. So.. reading the official config for nginx configuration, I really need to create a new Server block and set the root path on "/var/www/wallabag/web" right? I thought I could use in the same server block where all my others services are running.. a little bit confusing for me.

@GiovanniSalmeri
Copy link

GiovanniSalmeri commented Jan 8, 2021

I successfully installed the 1) latest release of Wallabag (2.4.1) 2) in a shared webhosting 3) without SSH access 4) in un subfolder 4) with SQLite. Since I think that this is a rather common situation, this is my little and easy recipe. Obviously, YMMV and corrections are much welcomed.

  1. Upload wallabag-release-2.4.1.tar.gz and decompress it in a folder (let's say /wallabag/) with the file manager of the control panel of your webhosting.

  2. Modify the file /wallabag/app/config/parameters.yml following the page https://doc.wallabag.org/en/admin/parameters.html. In particular the first lines must be as follows (replace mydomain.org with your domain name):

	database_driver: pdo_sqlite
	database_host: 127.0.0.1
	database_port: null
	database_name: wallabag
	database_user: root
	database_password: null
	database_path: %kernel.root_dir%/../data/db/wallabag.sqlite
	database_table_prefix: wallabag_
	database_socket: null
	database_charset: utf8mb4
	domain_name: 'https://mydomain.org/wallabag'
  1. Upload to /wallabag/ a file named install.php with the following content:
<?php
exec('bin/console wallabag:install --env=prod --no-interaction', $output, $retval);
header("Content-Type: text/plain"); 
if ($retval !== 0) {
	echo "An error occured!\n\n";
	echo "Error code: $retval\n\n";
	echo "Error message:\n\n";
}
echo implode("\n", $output);
  1. Visit with your browser the address https://mydomain.org/wallabag/install.php. If all goes right, you should read the following messages:
wallabag installer
==================

Step 1 of 4: Checking system requirements.
------------------------------------------

 ------------------------- -------- ----------------
  Checked                   Status   Recommendation
 ------------------------- -------- ----------------
  PDO Driver (pdo_sqlite)   OK!
  Database connection       OK!
  Database version          OK!
  curl_exec                 OK!
  curl_multi_init           OK!
 ------------------------- -------- ----------------

 [OK] Success! Your system can run wallabag properly.

Step 2 of 4: Setting up database.
---------------------------------

 Creating schema...
 Clearing the cache...

 Database successfully setup.

Step 3 of 4: Administration setup.
----------------------------------

 Administration successfully setup.

Step 4 of 4: Config setup.
--------------------------

 Config successfully setup.

 [OK] wallabag has been successfully installed.

 [OK] You can now configure your web server, see https://doc.wallabag.org
  1. Delete the file install.php!

  2. Upload to /wallabag/ a file named .htaccess (initial dot!) with the following content:

RewriteEngine On
RewriteRule ^(.*)$ /wallabag/web/$1 [NC,L,R]
  1. Visit the address https://mydomain.org/wallabag/ and register.

  2. Use in your mobile app the address https://mydomain.org/wallabag/web

  3. Anyone who knows the address of your wallabag instance can freely register. If you want to prevent this, change in the file /wallabag/app/config/parameters.yml the setting fosuser_registration to false.

@yomli
Copy link
Author

yomli commented Apr 8, 2021

Thanks a lot @GiovanniSalmeri, it works as intended. I was able to do a fresh install and even an update from 2.3.7 with those instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment