Wallabag是一个自托管的应用程序,允许用户保存Web内容以供以后阅读。这是一个开源项目,旨在为想要保存文章、视频和其他 Web 内容以供离线阅读的用户提供简单、隐私友好且无广告的体验。Wallabag适用于Linux,macOS和Windows操作系统,以及运行Android或iOS的移动设备。
在 Ubuntu 22.04 LTS Jammy Jellyfish 上安装 Wallabag
第 1 步。首先,通过在终端中运行以下命令,确保所有系统软件包都是最新的。apt
<span class="pln">sudo apt update sudo apt upgrade sudo apt install wget apt</span><span class="pun">-</span><span class="pln">transport</span><span class="pun">-</span><span class="pln">https gnupg2</span>
第 2 步。在 Ubuntu 22.04 上安装 LEMP 堆栈(Nginx、MariDB 和 PHP)。
在开始本教程之前,必须在服务器上安装 LEMP 服务器。如果您没有安装 LEMP 堆栈,您可以按照我们的指南进行操作 此处.
第 3 步。正在安装作曲家。
默认情况下,Composer 在 Ubuntu 22.04 基本存储库上不可用。现在运行以下命令以使用命令下载 Composer 安装程序:wget
<span class="pln">wget </span><span class="pun">-</span><span class="pln">O composer</span><span class="pun">-</span><span class="pln">setup</span><span class="pun">.</span><span class="pln">php https</span><span class="pun">:</span><span class="com">//getcomposer.org/installer</span>
下载完作曲家后,在命令行上执行以下命令,在 Linux Ubuntu 系统上安装和设置 作曲家:
<span class="pln">php composer</span><span class="pun">-</span><span class="pln">setup</span><span class="pun">.</span><span class="pln">php </span><span class="pun">--</span><span class="pln">install</span><span class="pun">-</span><span class="pln">dir</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin </span><span class="pun">--</span><span class="pln">filename</span><span class="pun">=</span><span class="pln">composer</span>
确认安装并检查已安装的 Composer 内部版本:
<span class="pln">composer </span><span class="pun">-</span><span class="pln">V</span>
有关安装 Composer 的其他资源,请阅读下面的帖子:
- 如何在 Ubuntu Linux √ 上安装 Composer
第 4 步。配置 MariaDB。
默认情况下,MariaDB 未强化。您可以使用脚本保护 MariaDB。您应该仔细阅读并在每个步骤下方仔细阅读,这将设置root密码,删除匿名用户,禁止远程root登录,并删除测试数据库和对安全MariaDB的访问权限:mysql_secure_installation
<span class="pln">mysql_secure_installation</span>
像这样配置它:
<span class="pun">-</span> <span class="typ">Set</span><span class="pln"> root password</span><span class="pun">?</span> <span class="pun">[</span><span class="pln">Y</span><span class="pun">/</span><span class="pln">n</span><span class="pun">]</span><span class="pln"> y </span><span class="pun">-</span> <span class="typ">Remove</span><span class="pln"> anonymous users</span><span class="pun">?</span> <span class="pun">[</span><span class="pln">Y</span><span class="pun">/</span><span class="pln">n</span><span class="pun">]</span><span class="pln"> y </span><span class="pun">-</span> <span class="typ">Disallow</span><span class="pln"> root login remotely</span><span class="pun">?</span> <span class="pun">[</span><span class="pln">Y</span><span class="pun">/</span><span class="pln">n</span><span class="pun">]</span><span class="pln"> y </span><span class="pun">-</span> <span class="typ">Remove</span><span class="pln"> test database </span><span class="kwd">and</span><span class="pln"> access to it</span><span class="pun">?</span> <span class="pun">[</span><span class="pln">Y</span><span class="pun">/</span><span class="pln">n</span><span class="pun">]</span><span class="pln"> y </span><span class="pun">-</span> <span class="typ">Reload</span><span class="pln"> privilege tables now</span><span class="pun">?</span> <span class="pun">[</span><span class="pln">Y</span><span class="pun">/</span><span class="pln">n</span><span class="pun">]</span><span class="pln"> y</span>
接下来,我们需要登录 MariaDB 控制台并为 Wallabag 创建一个数据库。运行以下命令:
<span class="pln">mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>
这将提示您输入密码,因此请输入您的MariaDB root密码并按Enter键。登录到数据库服务器后,您需要为Wallabag安装创建一个数据库:
<span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE DATABASE wallabag</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE USER </span><span class="str">'wallabaguser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'Your-Strong-Passwd'</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> GRANT ALL PRIVILEGES ON wallabag</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'wallabaguser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> FLUSH PRIVILEGES</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span> <span class="kwd">exit</span><span class="pun">;</span>
第5步。在 Ubuntu 22.04 上安装 Wallabag。
现在我们可以下载并安装瓦拉巴格了。运行以下命令以下载最新版本的 Wallabag:
<span class="pln">sudo mkdir </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">wallabag </span><span class="pun">-</span><span class="pln">p wget https</span><span class="pun">:</span><span class="com">//wllbg.org/latest-v2-package</span>
然后,使用以下命令提取下载的文件:
<span class="pln">tar xzf latest</span><span class="pun">-</span><span class="pln">v2</span><span class="pun">-</span><span class="kwd">package</span><span class="pln"> mv wallabag</span><span class="pun">-</span><span class="lit">2.5</span><span class="pun">.</span><span class="lit">4</span><span class="com">/* /var/www/html/wallabag</span>
接下来,创建资产目录:
<span class="pln">mkdir </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">wallabag</span><span class="pun">/</span><span class="pln">data</span><span class="pun">/</span><span class="pln">assets</span>
授予 Wallabag 目录写入和执行权限:
<span class="pln">chown </span><span class="pun">-</span><span class="pln">R $USER</span><span class="pun">:</span><span class="pln">$USER </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">wallabag</span>
之后,切换到目录:
<span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">wallabag</span>
现在通过复制示例文件来创建文件:parameters.yml
<span class="pln">cp app</span><span class="pun">/</span><span class="pln">config</span><span class="pun">/</span><span class="pln">parameters</span><span class="pun">.</span><span class="pln">yml</span><span class="pun">.</span><span class="pln">dist app</span><span class="pun">/</span><span class="pln">config</span><span class="pun">/</span><span class="pln">parameters</span><span class="pun">.</span><span class="pln">yml</span>
在开始配置 Wallabag 之前,我们会生成一个密钥。记下稍后要使用的密钥:
<span class="pln">openssl rand </span><span class="pun">-</span><span class="pln">base64 </span><span class="lit">32</span><span class="pln"> DMV</span><span class="pun">/</span><span class="typ">GpZwDobQbyQZQGDTHvt</span><span class="pun">+</span><span class="typ">ZFJZXwMEIF4KR46</span><span class="pun">=</span>
接下来,打开参数文件进行编辑:
<span class="pln">nano app</span><span class="pun">/</span><span class="pln">config</span><span class="pun">/</span><span class="pln">parameters</span><span class="pun">.</span><span class="pln">yml</span>
添加以下配置:
<span class="pun">..........</span><span class="pln"> database_driver</span><span class="pun">:</span><span class="pln"> pdo_mysql database_host</span><span class="pun">:</span> <span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pln"> database_port</span><span class="pun">:</span> <span class="lit">3306</span><span class="pln"> database_name</span><span class="pun">:</span><span class="pln"> wallabag database_user</span><span class="pun">:</span><span class="pln"> wallabaguser database_password</span><span class="pun">:</span> <span class="typ">Your</span><span class="pun">-</span><span class="typ">Strong</span><span class="pun">-</span><span class="typ">Passwd</span>
填写服务器描述和域名:
<span class="pln">domain_name</span><span class="pun">:</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//your-domain.com</span><span class="pln"> server_name</span><span class="pun">:</span> <span class="str">"idroot Wallabag"</span>
填写之前生成的密钥。如果要保留双因素身份验证,请确保应用以下设置:
<span class="com"># A secret key that's used to generate certain security-related tokens</span><span class="pln"> secret</span><span class="pun">:</span><span class="pln"> DMV</span><span class="pun">/</span><span class="typ">GpZwDobQbyQZQGDTHvt</span><span class="pun">+</span><span class="typ">ZFJZXwMEIF4KR46</span><span class="pun">=</span> <span class="com"># two factor stuff</span><span class="pln"> twofactor_auth</span><span class="pun">:</span> <span class="kwd">true</span><span class="pln"> twofactor_sender</span><span class="pun">:</span><span class="pln"> nagdimin@wallabag</span><span class="pun">.</span><span class="pln">it </span><span class="com"># fosuser stuff</span><span class="pln"> fosuser_registration</span><span class="pun">:</span> <span class="kwd">true</span><span class="pln"> fosuser_confirmation</span><span class="pun">:</span> <span class="kwd">true</span> <span class="pun">.....</span><span class="pln"> from_email</span><span class="pun">:</span><span class="pln"> ngadimin@wallabag</span><span class="pun">.</span><span class="pln">it </span><span class="pun">.....</span>
保存并关闭文件,然后运行 Composer 下载并安装 Wallabag 所需的依赖项:
<span class="pln">SYMFONY_ENV</span><span class="pun">=</span><span class="pln">prod composer install </span><span class="pun">--</span><span class="kwd">no</span><span class="pun">-</span><span class="pln">dev </span><span class="pun">-</span><span class="pln">o </span><span class="pun">--</span><span class="pln">prefer</span><span class="pun">-</span><span class="pln">dist</span>
使用 Wallabag 命令行工具完成安装:
<span class="pln">php bin</span><span class="pun">/</span><span class="pln">console wallabag</span><span class="pun">:</span><span class="pln">install </span><span class="pun">--</span><span class="pln">env</span><span class="pun">=</span><span class="pln">prod</span>
系统将提示您是否要重置数据库及其架构。两次都输入作为响应。接下来,系统将询问您是否要创建管理员帐户。键入以继续并输入帐户的用户名、密码和电子邮件 ID。NO
yes
第 6 步。配置 Nginx。
现在为 Wallabag 安装创建一个新的虚拟主机配置文件。您可以通过运行以下命令来创建文件:
<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">wallabag</span><span class="pun">.</span><span class="pln">conf</span>
添加以下文件:
<span class="pln">server </span><span class="pun">{</span><span class="pln"> listen </span><span class="lit">443</span><span class="pln"> ssl http2</span><span class="pun">;</span><span class="pln"> listen </span><span class="pun">[::]:</span><span class="lit">443</span><span class="pln"> ssl http2</span><span class="pun">;</span><span class="pln"> server_name your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">;</span><span class="pln"> access_log </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">wallabag</span><span class="pun">.</span><span class="pln">access</span><span class="pun">.</span><span class="pln">log</span><span class="pun">;</span><span class="pln"> error_log </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">log</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">wallabag</span><span class="pun">.</span><span class="pln">error</span><span class="pun">.</span><span class="pln">log</span><span class="pun">;</span> <span class="com"># SSL</span><span class="pln"> ssl_certificate </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">letsencrypt</span><span class="pun">/</span><span class="pln">live</span><span class="pun">/</span><span class="pln">your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">/</span><span class="pln">fullchain</span><span class="pun">.</span><span class="pln">pem</span><span class="pun">;</span><span class="pln"> ssl_certificate_key </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">letsencrypt</span><span class="pun">/</span><span class="pln">live</span><span class="pun">/</span><span class="pln">your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">/</span><span class="pln">privkey</span><span class="pun">.</span><span class="pln">pem</span><span class="pun">;</span><span class="pln"> ssl_trusted_certificate </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">letsencrypt</span><span class="pun">/</span><span class="pln">live</span><span class="pun">/</span><span class="pln">your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">/</span><span class="pln">chain</span><span class="pun">.</span><span class="pln">pem</span><span class="pun">;</span><span class="pln"> ssl_session_timeout </span><span class="lit">5m</span><span class="pun">;</span><span class="pln"> ssl_session_cache shared</span><span class="pun">:</span><span class="typ">MozSSL</span><span class="pun">:</span><span class="lit">10m</span><span class="pun">;</span><span class="pln"> ssl_session_tickets off</span><span class="pun">;</span><span class="pln"> ssl_protocols </span><span class="typ">TLSv1</span><span class="pun">.</span><span class="lit">2</span> <span class="typ">TLSv1</span><span class="pun">.</span><span class="lit">3</span><span class="pun">;</span><span class="pln"> ssl_prefer_server_ciphers on</span><span class="pun">;</span><span class="pln"> ssl_ciphers ECDHE</span><span class="pun">-</span><span class="pln">ECDSA</span><span class="pun">-</span><span class="pln">AES128</span><span class="pun">-</span><span class="pln">GCM</span><span class="pun">-</span><span class="pln">SHA256</span><span class="pun">:</span><span class="pln">ECDHE</span><span class="pun">-</span><span class="pln">RSA</span><span class="pun">-</span><span class="pln">AES128</span><span class="pun">-</span><span class="pln">GCM</span><span class="pun">-</span><span class="pln">SHA256</span><span class="pun">:</span><span class="pln">ECDHE</span><span class="pun">-</span><span class="pln">ECDSA</span><span class="pun">-</span><span class="pln">AES256</span><span class="pun">-</span><span class="pln">GCM</span><span class="pun">-</span><span class="pln">SHA384</span><span class="pun">:</span><span class="pln">ECDHE</span><span class="pun">-</span><span class="pln">RSA</span><span class="pun">-</span><span class="pln">AES256</span><span class="pun">-</span><span class="pln">GCM</span><span class="pun">-</span><span class="pln">SHA384</span><span class="pun">:</span><span class="pln">ECDHE</span><span class="pun">-</span><span class="pln">ECDSA</span><span class="pun">-</span><span class="pln">CHACHA20</span><span class="pun">-</span><span class="pln">POLY1305</span><span class="pun">:</span><span class="pln">ECDHE</span><span class="pun">-</span><span class="pln">RSA</span><span class="pun">-</span><span class="pln">CHACHA20</span><span class="pun">-</span><span class="pln">POLY1305</span><span class="pun">:</span><span class="pln">DHE</span><span class="pun">-</span><span class="pln">RSA</span><span class="pun">-</span><span class="pln">AES128</span><span class="pun">-</span><span class="pln">GCM</span><span class="pun">-</span><span class="pln">SHA256</span><span class="pun">:</span><span class="pln">DHE</span><span class="pun">-</span><span class="pln">RSA</span><span class="pun">-</span><span class="pln">AES256</span><span class="pun">-</span><span class="pln">GCM</span><span class="pun">-</span><span class="pln">SHA384</span><span class="pun">;</span><span class="pln"> ssl_ecdh_curve X25519</span><span class="pun">:</span><span class="pln">prime256v1</span><span class="pun">:</span><span class="pln">secp384r1</span><span class="pun">:</span><span class="pln">secp521r1</span><span class="pun">;</span><span class="pln"> ssl_stapling on</span><span class="pun">;</span><span class="pln"> ssl_stapling_verify on</span><span class="pun">;</span><span class="pln"> ssl_dhparam </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">ssl</span><span class="pun">/</span><span class="pln">certs</span><span class="pun">/</span><span class="pln">dhparam</span><span class="pun">.</span><span class="pln">pem</span><span class="pun">;</span><span class="pln"> resolver </span><span class="lit">8.8</span><span class="pun">.</span><span class="lit">8.8</span><span class="pun">;</span><span class="pln"> root </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">wallabag</span><span class="pun">/</span><span class="pln">web</span><span class="pun">;</span><span class="pln"> location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln"> try_files $uri </span><span class="pun">/</span><span class="pln">app</span><span class="pun">.</span><span class="pln">php$is_args$args</span><span class="pun">;</span> <span class="pun">}</span> <span class="com"># Pass PHP Scripts To FastCGI Server</span><span class="pln"> location </span><span class="pun">~</span> <span class="pun">^</span><span class="str">/app\.php(/</span><span class="pun">|</span><span class="pln">$</span><span class="pun">)</span> <span class="pun">{</span><span class="pln"> fastcgi_split_path_info </span><span class="pun">^(.+</span><span class="pln">\.php</span><span class="pun">)(/.*)</span><span class="pln">$</span><span class="pun">;</span><span class="pln"> fastcgi_pass unix</span><span class="pun">:</span><span class="str">/run/</span><span class="pln">php</span><span class="pun">/</span><span class="pln">php8</span><span class="pun">.</span><span class="lit">1</span><span class="pun">-</span><span class="pln">fpm</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">;</span> <span class="com"># Depends On The PHP Version</span><span class="pln"> fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name</span><span class="pun">;</span><span class="pln"> fastcgi_param DOCUMENT_ROOT $realpath_root</span><span class="pun">;</span><span class="pln"> include fastcgi_params</span><span class="pun">;</span> <span class="kwd">internal</span><span class="pun">;</span> <span class="pun">}</span><span class="pln"> location </span><span class="pun">~</span><span class="pln"> \.php$ </span><span class="pun">{</span> <span class="kwd">return</span> <span class="lit">404</span><span class="pun">;</span> <span class="pun">}</span> <span class="pun">}</span> <span class="com"># enforce HTTPS</span><span class="pln"> server </span><span class="pun">{</span><span class="pln"> listen </span><span class="lit">80</span><span class="pun">;</span><span class="pln"> listen </span><span class="pun">[::]:</span><span class="lit">80</span><span class="pun">;</span><span class="pln"> server_name your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">;</span> <span class="kwd">return</span> <span class="lit">301</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//$host$request_uri;</span> <span class="pun">}</span>
保存并关闭文件,然后重新启动 Nginx 服务以使其更改生效:
<span class="pln">sudo systemctl restart nginx</span>
步骤 7.使用Let’s Encrypt SSL保护Wallabag。
首先,使用以下命令安装 Certbot 客户端:
<span class="pln">sudo apt install certbot python3</span><span class="pun">-</span><span class="pln">certbot</span><span class="pun">-</span><span class="pln">nginx</span>
接下来,按照以下步骤使用Let’s Encrypt获取SSL证书:
<span class="pln">certbot </span><span class="pun">--</span><span class="pln">nginx </span><span class="pun">-</span><span class="pln">d your</span><span class="pun">-</span><span class="pln">domain</span><span class="pun">.</span><span class="pln">com</span>
让我们加密证书的有效期为 90 天,强烈建议在证书过期之前续订证书。您可以通过运行以下命令来测试证书的自动续订:
<span class="pln">sudo certbot renew </span><span class="pun">--</span><span class="pln">dry</span><span class="pun">-</span><span class="pln">run</span>
第8步。配置防火墙。
现在我们使用Nginx设置了一个简单的防火墙(UFW),以允许在HTTP和HTTPS的默认Web端口上进行公共访问:
<span class="pln">sudo ufw allow </span><span class="typ">OpenSSH</span><span class="pln"> sudo ufw allow </span><span class="str">'Nginx Full'</span><span class="pln"> sudo ufw enable</span>
第9步。访问Wallabag Web界面。
成功安装后,现在打开您的网络浏览器并使用 URL 访问 Wallabag 网络界面。您将被重定向到以下页面:https://your-domain.com
感谢您使用本教程在 Ubuntu 22.04 LTS Jammy Jellyfish 系统上安装 Wallabag。如需其他帮助或有用信息,我们建议您查看 Wallabag 网站。