Wallabag

来自MalacoKnowledge
Malacology留言 | 贡献2023年7月30日 (日) 07:38的版本 →‎配置

wallabag是一个开源免费可自建的稍后读服务。

全文注意替换 YOUR_PASSWORD YOUR_DOMAIN YOUR_PHP-FPM_DIR YOUR_KEY_FILE YOUR_CRT_FILE 并且注意你的php版本以及相关路径。

Install

# pacman -S mariadb nginx
# pacman -S php-fpm redis
# pacman -S wallabag

nginx

configure

cd /etc/nginx/sites-enabled
vim read.conf

add

server {
            listen 80;
            server_name YOUR_DOMAIN;
            return 301 https://$server_name$request_uri;
}
server {
    listen 443 ssl http2;
    server_name YOUR_DOMAIN;
    root /usr/share/webapps/wallabag/web;
    ssl_certificate YOUR_CRT_FILE;
    ssl_certificate_key YOUR_KEY_FILE;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;
    
    error_log /var/log/nginx/wallabag_error.log;
    access_log /var/log/nginx/wallabag_access.log;
    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /app.php$is_args$args;
    }

    location ~ ^/app\.php(/|$) {
        # if, for some reason, you are still using PHP 5,
        # then replace /run/php/php7.0 by /var/run/php5
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock; # 注意替换/run/php74-fpm/php-fpm.sock为你的php-fpm地址
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/app.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }
    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
        return 404;
    }
}

also, I make key for SSL avaiable

systemctl enable nginx
systemctl restart nginx

mariadb

mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
systemctl enable mariadb
systemctl restart mariadb
mysql_secure_installation
mysql -u root -p
CREATE DATABASE wallabag;
use wallabag;
CREATE USER 'wallabag'@'localhost' IDENTIFIED BY 'YOUR_PASSWARD'
GRANT ALL PRIVILEGES ON `wallabag`.* TO 'wallabag'@'localhost'; 
FLUSH PRIVILEGES; 
exit
systemctl restart mariadb

php

cd /etc/php
vim php.ini

# 删除相应extension前的;

extension=bcmath
;extension=bz2
;extension=calendar
extension=curl
;extension=dba
;extension=enchant
;extension=exif
;extension=ffi
;extension=ftp
extension=gd
;extension=gettext
;extension=gmp
extension=iconv
;extension=imap
extension=intl
;extension=ldap
extension=mysqli
;extension=odbc
;zend_extension=opcache
;extension=pdo_dblib
extension=pdo_mysql
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=pspell
;extension=shmop
;extension=snmp
;extension=soap
extension=sockets
;extension=sodium
;extension=sqlite3
;extension=sysvmsg
;extension=sysvsem
;extension=sysvshm
extension=tidy
extension=xmlrpc
;extension=xsl
extension=zip

配置 /etc/php/php-fpm.d/wallabag.conf

cp /etc/php/php-fpm.d/www.conf /etc/php/php-fpm.d/wallabag.conf

然后 wallabag.conf 几处 www 替换成 http

[wallabag]
user = wallabag
group = wallabag
listen = /run/php-fpm/php-fpm-wallabag.sock

配置

vim /etc/wallabag/parameters.yml

设置

# This file is auto-generated during the composer install
parameters:
    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: 3306
    database_name: wallabag
    database_user: wallabag
    database_password: YOUR_PASSWORD
    database_path: /var/lib/mysql/wallabag
    database_table_prefix: wallabag_
    database_socket: null
    database_charset: utf8mb4
    domain_name: 'https://YOUR_DOMAIN'
    server_name: 'Your wallabag instance'
    mailer_dsn: 'smtp://127.0.0.1'
    locale: en
    secret: ANY_SECRET
    twofactor_auth: true
    twofactor_sender: [email protected]
    fosuser_registration: true
    fosuser_confirmation: true
    fos_oauth_server_access_token_lifetime: 3600
    fos_oauth_server_refresh_token_lifetime: 1209600
    from_email: [email protected]
    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
    sentry_dsn: null

安装

cd /usr/share/wallabag
php bin/console wallabag:install --env=prod

清除缓存

php bin/console cache:clear --env=prod

安装时设置用户