红联Linux门户
Linux帮助

Ubuntu 16.04安装配置Seafile服务端

发布时间:2016-08-29 16:04:17来源:topspeedsnail.com作者:斗大的熊猫
Seafile(https://www.seafile.com/)是一个开源的文件云存储平台,更注重于隐私保护和对团队文件协作的支持。
Seafile源代码:https://github.com/haiwen/seafile
Seafile通过“资料库”来分类管理文件,每个资料库可单独同步,用户可加密资料库,且密码不会保存在服务器端,所以即使是服务器管理员也无权访问你的文件。
Seafile允许用户创建“群组”,在群组内同步文件、创建维基、发起讨论等,方便团队内协同工作。
Ubuntu 16.04安装Seafile(使用Nginx做反向代理)
 
1.安装依赖包
本文使用Python 2.7;
$ sudo apt-get install default-jre poppler-utils libreoffice libreoffice-script-provider-python libpython2.7 python-pip mysql-server python-setuptools python-imaging python-mysqldb python-memcache ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy python-pip
安装过程中需要设置MySQL root密码。
使用pip安装boto:
$ sudo pip install boto
如果出现local变量问题,执行:
$ export LANGUAGE=en_US.UTF-8
$ export LANG=en_US.UTF-8
$ export LC_ALL=en_US.UTF-8
$ sudo locale-gen en_US.UTF-8
$ sudo dpkg-reconfigure locales
 
2.为Seafile创建一个用户
创建seafile用户,使用它运行Seafile服务。
$ sudo useradd -m -s /bin/bash seafile
$ sudo passwd seafile
 
3.下载Seafile
切换到新用户:
$ su - seafile
$ cd ~
下载最新Seafile:https://www.seafile.com/download/
$ wget http://download-cn.seafile.com/seafile-server_5.1.4_x86-64.tar.gz
解压:
$ tar -xzf seafile-server_*.tar.gz
$ mv seafile-server-*/ seafile-server/
 
4.为Seafile创建数据库
$ mysql -u root -p
执行SQL:
# 创建数据库
mysql> create database ccnet_db character set = 'utf8';
mysql> create database seafile_db character set = 'utf8';
mysql> create database seahub_db character set = 'utf8';
# 创建用户
mysql> create user seacloud@localhost identified by 'test1234';
# 设置权限
mysql> grant all privileges on ccnet_db.* to seacloud@localhost identified by 'test1234';
mysql> grant all privileges on seafile_db.* to seacloud@localhost identified by 'test1234';
mysql> grant all privileges on seahub_db.* to seacloud@localhost identified by 'test1234';
mysql> flush privileges;
mysql> exit
上面SQL语句创建了一个叫seacloud的用户(密码test1234)和3个数据库。
 
5.配置Seafile
运行Seafile设置脚本:
$ cd seafile-server/
$ ./setup-seafile-mysql.sh
根据提示填写:
Ubuntu 16.04安装配置Seafile服务端
Ubuntu 16.04安装配置Seafile服务端
启动seafile和seahub服务:
$ ./seafile.sh start
$ ./seahub.sh start  # 创建管理员密码
测试,访问:http:://your_domain_or_IP:8000:
Ubuntu 16.04安装配置Seafile服务端
为了方便管理seafile和seahub服务进程,我们可以把它们配置为systemd后台服务。
首先,停止服务的运行:
$ ./seafile.sh stop
$ ./seahub.sh stop
退出seafile用户:
$ exit
创建seafile.service文件:
$ sudo vim /lib/systemd/system/seafile.service
[Unit]
Description=Seafile Server
After=network.target mariadb.service
[Service]
Type=oneshot
ExecStart=/home/seafile/seafile-server/seafile.sh start
ExecStop=/home/seafile/seafile-server/seafile.sh stop
RemainAfterExit=yes
User=seafile
Group=seafile
[Install]
WantedBy=multi-user.target
创建seahub.service文件:
$ sudo vim /lib/systemd/system/seahub.service
[Unit]
Description=Seafile Hub
After=network.target seafile.target
[Service]
Type=oneshot
ExecStart=/home/seafile/seafile-server/seahub.sh start-fastcgi
ExecStop=/home/seafile/seafile-server/seahub.sh stop
RemainAfterExit=yes
User=seafile
Group=seafile
[Install]
WantedBy=multi-user.target
启动Seafile和Seahub服务:
$ sudo systemctl daemon-reload
$ sudo systemctl start seafile
$ sudo systemctl enable seafile
$ sudo systemctl start seahub
$ sudo systemctl enable seahub
 
6.安装配置Nginx
安装Nginx:
$ sudo apt-get install nginx
创建虚拟主机配置文件:
$ sudo vim /etc/nginx/sites-available/seafile.conf
server {
listen 80;
server_name your_domain;
proxy_set_header X-Forwarded-For $remote_addr;
# Reverse proxy for seafile
location / {
fastcgi_pass    127.0.0.1:8000;
fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
fastcgi_param   PATH_INFO           $fastcgi_script_name;
fastcgi_param    SERVER_PROTOCOL        $server_protocol;
fastcgi_param   QUERY_STRING        $query_string;
fastcgi_param   REQUEST_METHOD      $request_method;
fastcgi_param   CONTENT_TYPE        $content_type;
fastcgi_param   CONTENT_LENGTH      $content_length;
fastcgi_param    SERVER_ADDR         $server_addr;
fastcgi_param    SERVER_PORT         $server_port;
fastcgi_param    SERVER_NAME         $server_name;
fastcgi_param   REMOTE_ADDR         $remote_addr;
access_log      /var/log/nginx/seahub.access.log;
error_log       /var/log/nginx/seahub.error.log;
fastcgi_read_timeout 36000;
}
# Reverse Proxy for seahub
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_connect_timeout  36000s;
proxy_read_timeout  36000s;
proxy_send_timeout  36000s;
send_timeout  36000s;
}
#CHANGE THIS PATH WITH YOUR OWN DIRECTORY
location /media {
root /home/seafile/seafile-server/seahub;
}
}
注意替换上面的域名。
使生效:
$ sudo ln -s /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/seafile.conf
重启Nginx服务:
$ sudo systemctl restart nginx
使用浏览器访问:http://your_doamin_or_IP:
Ubuntu 16.04安装配置Seafile服务端
 
本文永久更新地址:http://www.linuxdiyf.com/linux/23723.html