1. Seafile简介
Seafile 是一款开源的企业云盘,注重可靠性和性能。支持 Windows, Mac, Linux, iOS, Android 平台。支持文件同步或者直接挂载到本地访问。
2. Seafile部署
1. 安装信赖
[root@linux-node2 ~]# yum -y install wget python-setuptools python-imaging python-ldap MySQL-python python-memcached python-urllib3 mariadb-server #创建seafile数据库用户 Create USER 'seafile'@'%' IDENTIFIED BY 'seafile'; grant all privileges on *.* to 'seafile'@'localhost'; grant all privileges on *.* to 'seafile'@'%'; [root@linux-node2 ~]# mysql -uroot -prootroot -e "use mysql;select user,password,host from mysql.user;"
yum 安装 mysqldb-python 后面seafile安装可能报错,可以通过 python 的工具pip来安装MySQL-python pip install MySQL-python,不执行grant语句创建seahub-db时会提示权限问题导致报错
2. 下载seafile安装包
[root@linux-node2 ~]# wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.1.1_x86-64.tar.gz -O /home/xxx/ooo/seafile-6.1.1.tar.gz [root@linux-node2 ~]# cd /home/xxx/ooo/ && tar xf seafile-6.1.1.tar.gz && cd seafile-server-6.1.1
3. 执行设置脚本
设置脚本
./setup-seafile-mysql.sh
[root@linux-node2 seafile-server-6.1.1]# ./setup-seafile-mysql.sh
#服务器名
[server name]: seafile-test
#设置服务器的IP或域名
[This server's ip or domain]: sf.test.com
#数据存储目录
[default: /home/xxx/ooo/seafile-data ]
#seafile fileserver监听的TCP端口,最好别改
[default: 8082 ]
#配置mysql数据信息
-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases
[ 1 or 2 ] 1
What is the host of mysql server?
[ default "localhost" ]
What is the port of mysql server?
[ default "3306" ]
What is the password of the mysql root user?
[ root password ]
verifying password of user root ... done
Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ]
Enter the password for mysql user "seafile":
[ password for seafile ]
verifying password of user seafile ... done
Enter the database name for ccnet-server:
[ default "ccnet-db" ]
Enter the database name for seafile-server:
[ default "seafile-db" ]
Enter the database name for seahub:
[ default "seahub-db" ]
---------------------------------
This is your configuration
---------------------------------
server name: seafile-test
server ip/domain: sf.test.com
seafile data dir: /home/xxx/ooo/seafile-data
fileserver port: 8082
database: create new
ccnet database: ccnet-db
seafile database: seafile-db
seahub database: seahub-db
database user: seafile
---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------
Generating ccnet configuration ...
done
Successly create configuration dir /home/xxx/ooo/ccnet.
Generating seafile configuration ...
Done.
done
Generating seahub configuration ...
----------------------------------------
Now creating seahub database tables ...
----------------------------------------
creating seafile-server-latest symbolic link ... done
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------
run seafile server: ./seafile.sh { start | stop | restart }
run seahub server: ./seahub.sh { start| stop | restart}
-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------
port of seafile fileserver: 8082
port of seahub: 8000
When problems occur, Refer to
https://github.com/haiwen/seafile/wiki
for information.启动seafile服务
[root@linux-node2 seafile-server-6.1.1]# ./seafile.sh start [09/05/17 21:53:39] ../common/session.c(132): using config file /home/xxx/ooo/conf/ccnet.conf Starting seafile server, please wait ... Seafile server started Done. #第一次执行seahub脚本会创建admin管理员配置 [root@linux-node2 seafile-server-6.1.1]# ./seahub.sh start LC_ALL is not set in ENV, set to en_US.UTF-8 Starting seahub at port 8000 ... ---------------------------------------- It's the first time you start the seafile server. Now let's create the admin account ---------------------------------------- What is the email for the admin account? [ admin email ] anzhihe@chegva.com What is the password for the admin account? [ admin password ] Enter the password again: [ admin password again ] ---------------------------------------- Successfully created seafile admin ---------------------------------------- Seahub is started Done. #启动服务 ./seafile.sh start ./seahub.sh start #检查服务是否都正常启动 tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 4034/seaf-server tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 4136/python2.7 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3495/mysqld tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 2582/memcached
3. Seafile使用Memcached
安装 Memcached 能够显著提高系统性能。首先你需要保证 libmemcached 库已经安装在你的系统中。要想使用memcached集群,我们要求使用 1.0.18 或者更新的版本。
参考:http://manual-cn.seafile.com/deploy/add_memcached.html
[root@linux-node2 seafile-server-6.1.1]# yum install gcc libffi-devel python-devel openssl-devel libmemcached libmemcached-devel
memcached安装自行解决,下载libmemcached安装包,解压编译安装
[root@linux-node2 ~]# yum -y install epel-release
[root@linux-node2 ~]# yum install python-pip -y
[root@linux-node2 ~]# pip install --upgrade pip
[root@linux-node2 ~]# pip install pylibmc
[root@linux-node2 ~]# pip install django-pylibmc
将以下配置添加到 seahub_settings.py 中:
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
}
}
最后重启 Seahub 以使更改生效:
./seahub.sh restart4. Nginx下配置Seahub
参考:http://manual-cn.seafile.com/deploy/deploywithnginx.html
#添加nginx配置文件
[root@linux-node2 vhost]# more seafile.conf
server {
listen 80;
server_name sf.test.com;
proxy_set_header X-Forwarded-For $remote_addr;
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 /home/xxx/ooo/logs/seahub.access.log;
error_log /home/xxx/ooo/logs/seahub.error.log;
}
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;
}
location /media {
root /home/xxx/ooo/seafile-server-latest/seahub;
}
}
#修改 seahub_settings.py
(增加一行,这是一个 python 文件,注意引号)
FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'
[root@linux-node2 seafile-server-latest]# cat ../conf/seahub_settings.py
# -*- coding: utf-8 -*-
...
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
}
}
FILE_SERVER_ROOT = 'http://sf.test.com/seafhttp'
[root@linux-node2 seafile-server-latest]# ./seafile.sh restart
[root@linux-node2 seafile-server-latest]# ./seahub.sh start-fastcgi5. 测试
绑定本地域名,打开
sf.test.com,输入用户名(邮箱账号)/密码
1. 支持图片、文档等格式的预览,加密等,适合个人企业使用。
2. Seahub: 8000 #Seafile 服务器的 Web 端,修改端口重启后也无效,坑,浪费了些时间。
3. httpserver: 8082 #负责为 Seahub 处理文件的上传和下载,最好也别改,网上说有坑。
启动方式:
数据备份:
FAQ
1.seafile无法下载文件,且web端文件无法加载预览,页面调试发现有ERR_CONTENT_LENGTH_MISMATCH错误
原因:nginx会缓存大文件到proxy_temp目录中,文件夹权限有问题
解决:chown -R work.work /var/lib/nginx/tmp && chmod 777 /var/lib/nginx/tmp && rm -rf /var/lib/nginx/tmp/proxy
2.上传文件夹报错:Maximum number of files exceeded,应该是超过文件夹最大文件数量限制。
解决:Open the file and search for string maxNumberOfFiles:500,默认是500个文件,修改seahub_settings.py配置
MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD = 5000,将500个改成5000个,上传文件夹不再报错
参考:https://forum.seafile.com/t/maximum-number-of-files-exceeded/552
参考:
https://github.com/wangyan/docker-seafile
https://www.hyahm.com/article/166.html
https://www.howtoing.com/how-to-install-seafile-with-nginx-on-centos-7/
http://www.jianshu.com/p/ed7efb2cedbe
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-seafile-on-an-ubuntu-12-04-vps

