红联Linux门户
Linux帮助

Ubuntu安装配置Wallabag

发布时间:2016-08-26 17:14:41来源:topspeedsnail.com作者:斗大的熊猫
Wallabag(https://www.wallabag.org/)是用来保存网页的开源自托管应用,主要功能就是将你要阅读或者一时没有读完的文章同步到Wallabag服务器,供你在以后阅读。
 
Wallabag的特性:
Wallabag在同步网页时会去掉广告、还有其它一些没用的东西
Wallabag把网页保存到数据库,即使原始网页不见了也没有关系
还可以把Wallabag保存的网页导出为其它格式 (TXT,HTML,CSV,EPUB,MOBI,FDF,JSON)
Wallabag提供了浏览器插件和手机app,可以更方便的访问Wallabag
 
Ubuntu安装Wallabag
Wallabag是PHP编写的,所以需要LAMP或LEMP环境。
 
1.为Wallabag创建数据库和用户
$ sudo mysql -u root -p
MariaDB [(none)]> CREATE DATABASE wallabag;
MariaDB [(none)]> CREATE USER wallabag@localhost;
MariaDB [(none)]> SET PASSWORD FOR wallabag@localhost= PASSWORD("test1234");
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wallabag.* TO wallabag@localhost IDENTIFIED BY 'test1234';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
上面SQL语句创建了一个wallabag数据库和wallabag用户(密码test1234)。
 
2.安装composer
下载composer安装器:
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
安装composer:
$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
安装到/usr/local/bin/composer。
Ubuntu安装配置Wallabag
删除composer安装器:
$ php -r "unlink('composer-setup.php');"
 
3.下载Wallabag
$ git clone https://github.com/wallabag/wallabag
checkout最新分支,我安装时是2.1:
$ cd wallabag/
$ git checkout 2.1
配置(推荐内存4G+):
$ SYMFONY_ENV=prod composer install --no-dev -o --prefer-dist
根据提示设置一些参数:
Creating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
database_driver (pdo_sqlite): pdo_mysql
database_host (127.0.0.1): 127.0.0.1
database_port (null): 3306
database_name (symfony): wallabag
database_user (root): wallabag
database_password (null): test1234
database_path ('%kernel.root_dir%/../data/db/wallabag.sqlite'): /var/lib/mysql/wallabag
database_table_prefix (wallabag_): wallabag_
数据库也可以使用SQLite。邮箱设置:
mailer_transport (smtp): 
mailer_host (127.0.0.1): 
mailer_user (null): 
mailer_password (null): 
locale (en): 
secret (ovmpmAWXRCabNlMgzlzFXDYmCFfzGv): 
twofactor_auth (true): 
twofactor_sender (no-reply@wallabag.org): 
fosuser_registration (true): 
fosuser_confirmation (true): 
from_email (no-reply@wallabag.org): 
安装Wallabag:
$ php bin/console wallabag:install --env=prod
Installing Wallabag...
Step 1 of 4. Checking system requirements.
+-----------------+--------+----------------+
| Checked | Status | Recommendation |
+-----------------+--------+----------------+
| PDO Driver  | OK!||
| curl_exec   | OK!||
| curl_multi_init | OK!||
+-----------------+--------+----------------+
Success! Your system can run Wallabag properly.
Step 2 of 4. Setting up database.
It appears that your database already exists. Would you like to reset it? (y/N)n
Creating schema
Clearing the cache
Step 3 of 4. Administration setup.
Would you like to create a new admin user (recommended) ? (Y/n)y
Username (default: wallabag) :wallabag
Password (default: wallabag) :test123456
Email:test@test.com
Step 4 of 4. Config setup.
Wallabag has been successfully installed.
Just execute `php bin/console server:run --env=prod` for using wallabag: http://localhost:8000
把Wallabag移动到/var/www/目录:
$ cd ..
$ sudo mv wallabag /var/www
更改目录权限:
$ sudo chown -R www-data:www-data /var/www/wallabag
 
4.配置Apache
创建虚拟主机配置文件:
$ sudo vim /etc/apache2/sites-available/wallabag.conf
写入:
<VirtualHost *:80>
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /var/www/wallabag/web
<Directory /var/www/wallabag/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeScript assets
# <Directory /var/www/wallabag>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/wallabag/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/wallabag_error.log
CustomLog /var/log/apache2/wallabag_access.log combined
</VirtualHost>
注意替换上面的域名。
如果你使用php7.0-fpm,还需要添加一行配置:
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.0-fpm.sock|fcgi://localhost/var/www/wallabag/web/
开启rewrite模块:
$ sudo a2enmod rewrite
启用新配置:
$ sudo ln -s /etc/apache2/sites-available/wallabag.conf /etc/apache2/sites-enabled/
$ sudo systemctl restart apache2
 
5.完成安装
使用浏览器访问:http://yourdomain.com
Ubuntu安装配置Wallabag
 
源码:https://github.com/wallabag/wallabag
 
本文永久更新地址:http://www.linuxdiyf.com/linux/23649.html