红联Linux门户
Linux帮助

Ubuntu安装配置Paperwork-开源云笔记系统

发布时间:2016-08-28 09:49:40来源:topspeedsnail.com作者:斗大的熊猫
Paperwork(http://paperwork.rocks/)是开源、自托管的网络云笔记系统,功能类似Evernote、Microsoft OneNote和Google Keep。
Paperwork源代码:https://github.com/twostairs/paperwork
Paperwork采用 PHP 开发,使用Laravel框架,提供一个很流行的 Web UI,提供开放 API 用于第三方集成。后端可以使用 MySQL、SQLite等数据库。
本文在Ubuntu 16.04上安装Paperwork,使用LEMP(Nginx+PHP-FPM+MariaDB)。
 
1.安装一些工具
$ sudo apt-get install software-properties-common git vim curl
 
2.安装MariaDB
为Paperwork创建一个数据库和一个用户:
$ sudo mysql -u root -p
执行SQL语句:
MariaDB [(none)]> CREATE DATABASE paperwork;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON paperwork.* TO 'paperwork'@'localhost' IDENTIFIED BY 'test1234';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit
上面的SQL语句创建了一个叫paperwork的数据库和一个叫paperwork的用户(密码test1234)。
 
3.安装PHP、Composer和一些PHP模块
目前的PHP版本是7.0:
$ sudo apt-get install php-fpm php-cli php-json php-curl php-gd php-mysql php-mcrypt php-mbstring
Composer是PHP的依赖包管理器,需要使用它下载项目需要的所有库。
安装Composer:
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
查看Composer版本:
Ubuntu安装配置Paperwork-开源云笔记系统
配置PHP,限制PHP内存为512M,上传文件限制200M,使用UTC时区:
$ sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.0/fpm/php.ini
$ sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 200M/" /etc/php/7.0/fpm/php.ini
$ sudo sed -i "s/post_max_size = .*/post_max_size = 200M/" /etc/php/7.0/fpm/php.ini
$ sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/fpm/php.ini
$ sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/" /etc/php/7.0/fpm/php.ini
重启PHP-FPM服务:
$ sudo systemctl restart php7.0-fpm
 
4.安装Nodejs
$ sudo apt-get install nodejs npm
Ubuntu安装配置Paperwork-开源云笔记系统
使用npm安装gulp和bower:
$ sudo npm install -g gulp bower
 
5.安装Nginx
$ sudo apt-get install nginx
 
6.安装Paperwork
从Github Clone源码:
$ cd ~
$ git clone https://github.com/twostairs/paperwork
使用composer安装PHP依赖:
$ cd paperwork/frontend
$ composer install
创建database.json并设置数据库连接信息:
$ cp app/storage/config/default_database.json app/storage/config/database.json
$ vim app/storage/config/database.json
{
"driver": "mysql",
"database": "paperwork",
"host": "localhost",
"username": "paperwork",
"password": "test1234",
"port": 3306
}
迁移数据库:
$ php artisan migrate
Ubuntu安装配置Paperwork-开源云笔记系统
安装npm依赖:
$ npm install
安装bower依赖:
$ sudo ln -s /usr/bin/nodejs /usr/bin/node
$ bower install
$ gulp
移动目录并更改目录所有者:
$ sudo mv -r ~/paperwork /var/www
$ sudo chown -R www-data:www-data /var/www/paperwork
 
7.配置Nginx
创建自签名证书,你也可以使用其它证书。
$ sudo mkdir -p /etc/nginx/ssl
$ cd /etc/nginx/ssl
$ sudo openssl genrsa -des3 -passout pass:x -out paperwork.pass.key 2048
$ sudo openssl rsa -passin pass:x -in paperwork.pass.key -out paperwork.key
$ sudo rm paperwork.pass.key
$ sudo openssl req -new -key paperwork.key -out paperwork.csr
$ sudo openssl x509 -req -days 365 -in paperwork.csr -signkey paperwork.key -out paperwork.crt
$ sudo openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
创建Nginx虚拟主机配置文件:
$ sudo vim /etc/nginx/sites-available/paperwork
server {
listen 443 ssl http2;
server_name your_domain.com;
root /var/www/paperwork/frontend/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
ssl on;
ssl_certificate     /etc/nginx/ssl/paperwork.crt;
ssl_certificate_key /etc/nginx/ssl/paperwork.key;
ssl_dhparam  /etc/nginx/ssl/dhparam.pem;
ssl_session_timeout 5m;
ssl_ciphers  EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
access_log  /var/log/nginx/paperwork.access.log;
error_log   /var/log/nginx/paperwork.error.log;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
server {
listen      80;
server_name your_domain.com;
add_header Strict-Transport-Security max-age=2592000;
rewrite ^ https://$server_name$request_uri? permanent;
}
注意替换上面的域名。
创建链接:
$ sudo ln -s /etc/nginx/sites-available/paperwork /etc/nginx/sites-enabled/paperwork
重启Nginx:
$ sudo nginx -t
$ sudo systemctl restart nginx
重启PHP-FPM:
$ sudo systemctl restart php7.0-fpm
 
8.完成安装
使用浏览器访问:https://your_domain.com
设置数据库连接:
Ubuntu安装配置Paperwork-开源云笔记系统
Ubuntu安装配置Paperwork-开源云笔记系统
注册第一个用户:
Ubuntu安装配置Paperwork-开源云笔记系统
完成安装:
Ubuntu安装配置Paperwork-开源云笔记系统
安装过程遇到的一个错误:
configuration has not been set correctly. please try again.
解决方法:临时删除 app/storage/config/database.json 文件。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/23685.html