Wallabag

imported>Malacology2022年5月25日 (三) 10:34的版本 (add tags)

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

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

Install

# pacman -S mariadb nginx
# pacman -S php7 php7-gd php7-tidy php7-intl redis
# php7 也可以替换为 php74,需要用 yay,若今后支持php8,可以替换为php
$ yay -S wallabag

此处使用我自己的打包,即原来 AUR 的打包

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/php74-fpm/php-fpm.sock;
        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/php74 或者 /etc/php7 或者 /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

nginx

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


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/YOUR_PHP-FPM_DIR/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;
    }
}

配置

cd /usr/share/webapps/wallabag/app/config
vim 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_transport: smtp
    mailer_user: null
    mailer_password: null
    mailer_host: 127.0.0.1
    mailer_port: false
    mailer_encryption: null
    mailer_auth_mode: null
    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/webapps/wallabag
php bin/console wallabag:install --env=prod
# php可以改为php74,或者相应的php版本
# 第三步一定要新建用户

清除缓存

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

安装时设置用户