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.

@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