Seafile是国内团队开发的一款开源的云存储产品,其具有全平台客户端,和OwnCloud不相上下,但是和OwnCloud不同的是,它的后端是由Python开发的,而且还支持集群甚至Ceph分布式文件系统,个人感觉,它比OwnCloud,以及NextCloud更加专注于存储,另外两个由于插件的存在反而向云平台靠拢了,有些"臃肿"。
不过……Seafile有个很蛋疼的地方,是它的国内站下载的版本和国外站下载的不同……国内站的那个免费版是社区版(开源版),而国外站的那个则是限制了免费用户数的Pro版(企业版可能?),功能差别当然也是有的,参见下图,主要还是看需求吧,毕竟实际上开源版本的大部分人都够用了,而它的企业版授权按人数算的,也是不便宜。我建议如果用的人多,那么还是开源版吧,如果就两三个人用,而且追求折腾,那么使用三用户免费的Pro版也挺好的。
这儿我以Pro版安装介绍下Seafile的安装流程,因为两者的基础安装流程是相同的,区别只是在于Pro版可以额外安装和配置其它东西
一.下载
首先,来给个下载地址
社区版:请前往https://www.seafile.com/download/ 直接下载
Pro版:请前往https://customer.seafile.com/ 注册后将有下载地址
二.安装
我目前下载的版本是6.0.13,所以下载的压缩包名为seafile-pro-server_6.0.13_x86-64.tar.gz ,你可以注意到,官方还提供了带Ubuntu后缀名的压缩包,在文件夹说明中,该包内程序在Ubuntu 16.04环境下编译,具有更好的支持LDAPS和Ceph的特点,看你需要吧,我用不着所以差不多了
默认情况下,Seafile是内置Web服务器的,但是由于很多情况下服务器上会跑Nginx,所以不能让Seafile独占80和443端口,而我们又不喜欢访问还额外带个端口,那么,我们就需要配置Nginx来反代Seafile,而不是"单纯"的使用Seafile的一键安装脚本
(是的,Seafile自带一键安装脚本,setup-seafile.sh可以使用SQLite作为数据库一键安装,而setup-seafile-mysql.sh可以使用Mysql作为数据库一键安装,其实这俩都是假的一键,还有个真的一键,不过会帮你装全家桶,要的话可以看看——>
好了,回归正题,配置Seafile和Nginx一起工作其实是在安装Seafile的前提下的一个额外选项,所以我们首先要做的还是装Seafile,怎么装?当然是上面提到的一键咯
//首先来做下一键安装的前提准备
yum install python-setuptools python-imaging python-ldap MySQL-python python-memcached python-urllib3
pip install boto
1
2
3
4
//首先来做下一键安装的前提准备
yuminstallpython-setuptoolspython-imagingpython-ldapMySQL-pythonpython-memcachedpython-urllib3
pipinstallboto
这边需要注意,因为Seafile要求的是Python2.7,所以请Centos6预先安装Python2.7,安装方法我博客里有,不过那个有些麻烦,我后来还找到了一个办法,这儿说一下
//ius源依赖epel源
yum install epel-release -y
rpm -Uvh https://centos6.iuscommunity.org/ius-release.rpm
//是的,ius源内包含了python2.7
yum install python27 python27-devel -y
//替换默认python顺便修复yum只能用python 2.6的问题
ln -sf /usr/bin/python2.7 /usr/bin/python
sed -i '1s/python/python2.6/g' /usr/bin/yum
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
rm -rf get-pip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
//ius源依赖epel源
yuminstallepel-release-y
rpm-Uvhhttps://centos6.iuscommunity.org/ius-release.rpm
//是的,ius源内包含了python2.7
yuminstallpython27python27-devel-y
//替换默认python顺便修复yum只能用python 2.6的问题
ln-sf/usr/bin/python2.7/usr/bin/python
sed-i'1s/python/python2.6/g'/usr/bin/yum
wgethttps://bootstrap.pypa.io/get-pip.py
pythonget-pip.py
rm-rfget-pip.py
那么,又来了一个问题,yum装的那些python依赖只是给默认的Python 2.6用的,所以要给新的2.7用我们需要用pip装
pip install image ldap mysql memcached urllib3 boto
1
pipinstallimageldapmysqlmemcachedurllib3boto
这样就OK了
然后,上传解压你下载的程序包,我选择丢到/opt/seafile 目录中
然后执行进入/opt/seafile/seafile-pro-server-6.0.13 目录 执行./setup-seafile-mysql.sh
恩,python的模块没问题了,还差个java,小意思,需要注意版本必须在1.7及以上
//你要装sunjdk啥的也行,poppler-utils是用于处理PDF的,顺便一起装了,反正也要用
yum install java-1.7.0-openjdk poppler-utils
1
2
//你要装sunjdk啥的也行,poppler-utils是用于处理PDF的,顺便一起装了,反正也要用
yuminstalljava-1.7.0-openjdkpoppler-utils
然后继续执行一键脚本,依次填空,然后一路回车,很快就OK了
PS.根据我自己的经历以及Qa同学的问题,请在数据库这儿注意,如果是让程序自己创建用户的,请使用mysql命令行或者phpmyadmin等工具复制一个mysql用户将其允许连接的主机设置为127.0.0.1,默认程序创建的是localhost,实际上连的却是127.0.0.1。如果是自己创建用户和数据库的,也请注意这个问题。
接着我们配置Nginx,来反代Seafile内置的Web服务器,在nginx的配置目录中(我的OneInStack环境要在vhost目录中)创建一个新的配置文件,内容如下
server {
listen 80;
listen 443 ssl http2;
ssl_certificate /path/to/your.crt;
ssl_certificate_key /path/to/your.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
ssl_stapling on;
ssl_stapling_verify on;
server_name your.domain.com;
#强制跳转HTTPS
#if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
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;
#启用HTTPS
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
access_log /data/wwwlogs/seahub.access.log;
error_log /data/wwwlogs/seahub.error.log;
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
proxy_request_buffering off;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
}
location /media {
#这儿也要看你安装位置
root /opt/seafile/seafile-server-latest/seahub;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
server{
listen80;
listen443sslhttp2;
ssl_certificate/path/to/your.crt;
ssl_certificate_key/path/to/your.key;
ssl_protocolsTLSv1TLSv1.1TLSv1.2;
ssl_ciphersEECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_cipherson;
ssl_session_timeout10m;
ssl_session_cachebuiltin:1000shared:SSL:10m;
ssl_buffer_size1400;
ssl_staplingon;
ssl_stapling_verifyon;
server_nameyour.domain.com;
#强制跳转HTTPS
#if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
proxy_set_headerX-Forwarded-For$remote_addr;
location/{
fastcgi_pass127.0.0.1:8000;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
fastcgi_paramPATH_INFO$fastcgi_script_name;
fastcgi_paramSERVER_PROTOCOL$server_protocol;
fastcgi_paramQUERY_STRING$query_string;
fastcgi_paramREQUEST_METHOD$request_method;
fastcgi_paramCONTENT_TYPE$content_type;
fastcgi_paramCONTENT_LENGTH$content_length;
fastcgi_paramSERVER_ADDR$server_addr;
fastcgi_paramSERVER_PORT$server_port;
fastcgi_paramSERVER_NAME$server_name;
fastcgi_paramREMOTE_ADDR$remote_addr;
#启用HTTPS
fastcgi_paramHTTPSon;
fastcgi_paramHTTP_SCHEMEhttps;
access_log/data/wwwlogs/seahub.access.log;
error_log/data/wwwlogs/seahub.error.log;
}
location/seafhttp{
rewrite^/seafhttp(.*)$$1break;
proxy_passhttp://127.0.0.1:8082;
client_max_body_size0;
proxy_request_bufferingoff;
proxy_connect_timeout36000s;
proxy_read_timeout36000s;
}
location/media{
#这儿也要看你安装位置
root/opt/seafile/seafile-server-latest/seahub;
}
}
然后重启nginx
下面的修改也可以通过Web管理界面进行(先用端口访问修改)
修改/opt/seafile/conf/ccnet.conf
//这儿是要去除端口 如果你像我一样开了强制跳转,请用https
SERVICE_URL = http://www.myseafile.com
1
2
//这儿是要去除端口 如果你像我一样开了强制跳转,请用https
SERVICE_URL=http://www.myseafile.com
修改/opt/seafile/conf/seahub_settings.py
//参照着新增如下这行,还是注意https问题
FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'
1
2
//参照着新增如下这行,还是注意https问题
FILE_SERVER_ROOT='http://www.myseafile.com/seafhttp'
接着启动Seafile
./seafile.sh start
#请务必注意,在Nginx模式下不能用./seahub.sh start,否则无法连上fastcgi
./seahub.sh start-fastcgi
1
2
3
./seafile.shstart
#请务必注意,在Nginx模式下不能用./seahub.sh start,否则无法连上fastcgi
./seahub.shstart-fastcgi
这儿会让你创建管理员账号,然后就可以访问域名了,用创建的账号登陆
到这边其实就好了,下面说些其它的修改
三.优化
官方建议在用户数达到一定量的情况下配置Memcached,以减小系统压力
//这边的python-devel在Centos6下换成python27-devel
yum install gcc libffi-devel python-devel openssl-devel libmemcached libmemcached-devel
pip install pylibmc
pip install django-pylibmc
1
2
3
4
//这边的python-devel在Centos6下换成python27-devel
yuminstallgcclibffi-develpython-developenssl-devellibmemcachedlibmemcached-devel
pipinstallpylibmc
pipinstalldjango-pylibmc
然后修改/opt/seafile/conf/seahub_settings.py
//添加如下内容
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
}
}
1
2
3
4
5
6
7
//添加如下内容
CACHES={
'default':{
'BACKEND':'django_pylibmc.memcached.PyLibMCCache',
'LOCATION':'127.0.0.1:11211',
}
}
然后重启Seahub
//请在/opt/seafile/seafile-server-latest 或者你安装的位置执行
./seahub.sh stop
./seahub.sh start-fastcgi
1
2
3
//请在/opt/seafile/seafile-server-latest 或者你安装的位置执行
./seahub.shstop
./seahub.shstart-fastcgi
这样就好了,当然这儿需要你自己装memcached,这个就不用我说了吧,不然你肯定启动失败的
另外,Seafile好像不会默认开机启动,所以如果需要这个请参考官方的开机脚本 ——> 传送门