seafile服务器部署
服务器环境:CentOS Linux release 7.4.1708 (Core) 部署方式:源码安装部署
系统包依赖
- autoconf/automake/libtool
- libevent-dev ( 2.0 or later )
- libcurl4-openssl-dev (1.0.0 or later)
- libgtk2.0-dev ( 2.24 or later)
- uuid-dev
- intltool (0.40 or later)
- libsqlite3-dev (3.7 or later)
- valac (only needed if you build from git repo)
- libjansson-dev
- qtchooser
- qtbase5-dev
- libqt5webkit5-dev
- qttools5-dev
- qttools5-dev
- cmake
- python-simplejson (for seaf-cli)
- libssl-dev
- libarchive-dev
- libfuse-dev
因为是Centos7系统
,故使用YUM
安装上述安装包:
sudo yum install wget gcc libevent-devel openssl-devel gtk2-devel libuuid-devel sqlite-devel jansson-devel intltool cmake libtool vala gcc-c++ qt5-qtbase-devel qt5-qttools-devel qt5-qtwebkit-devel libcurl-devel openssl-devel fuse-devel libarchive-devel python-devel epel-release python-pip -y
上面的命令可以多执行几次,已确保全部安装。
另外,7.1.0版本之前seafile
服务使用的是python2.7
,还未支持python3
;7.1.0版本后已支持python3
若此步骤使用yum
安装失败,可查看下系统yum
源是否正确或者完整,部分系统使用最小化安装的话,可能会缺少某些安装包。这个时候可考虑更换yum
源,或者重装系统。
python3
7.1.0后版本已支持,自行在系统中安装python3与pip3
数据库
数据库服务
这里使用的MariaDB
数据库
安装MariaDB
yum install mariadb mariadb-server -y
配置MariaDB
- 启动服务并设置为开机自启动
systemctl start mariadb # 开启服务
systemctl enable mariadb # 设置为开机自启动服务
- 首次安装后需要进行的数据配置
命令:
mysql_secure_installation
命令后的选项:
Enter current password for root (enter for none): # 输入数据库超级管理员root的密码(注意不是系统root的密码),第一次进入还没有设置密码则直接回车
Set root password? [Y/n] # 设置密码,y
New password: # 新密码
Re-enter new password: # 再次输入密码
Remove anonymous users? [Y/n] # 移除匿名用户, y
Disallow root login remotely? [Y/n] # 拒绝root远程登录,n,不管y/n,都会拒绝root远程登录
Remove test database and access to it? [Y/n] # 删除test数据库,y:删除。n:不删除,数据库中会有一个test数据库,一般不需要
Reload privilege tables now? [Y/n] # 重新加载权限表,y。或者重启服务也许
- 测试是否能够登录成功
mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
设置允许远程连接
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'your password' WITH GRANT OPTION;
MariaDB [(none)]> flush privileges;
关闭防火墙
systemctl stop firewalld
数据库连接器
这里使用的是MariaDB's LGPL Connector/C library
,因为seafile
内核主要是用C
语言开发,而MariaDB Connector/C
就是用来连接seafile
与MariaDB
或者MySQL
数据库的。
进入 https://downloads.mariadb.org/connector-c/ 官网下载最新的安装包。
本文中使用的为最新版本3.1.5.
- 下载:
wget https://downloads.mariadb.com/Connectors/c/connector-c-3.1.5/mariadb-connector-c-3.1.5-src.tar.gz
- 解压:
tar xf mariadb-connector-c-3.1.5-src.tar.gz
安装:
cd mariadb-connector-c-3.1.5-src/ cmake . make && sudo make install
添加环境变量。默认会安装在
/usr/local/lib/mariadb
下,export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/mariadb
libevhtp
libevhtp
是 libevent's httpd API
的一个快速、灵活的替代品。通过使用libevhtp
,我们可以很容易地创建速度极快、安全的HTTP服务器
- 下载:
wget https://github.com/ellzey/libevhtp/archive/1.1.6.tar.gz
- 解压:
tar xf 1.1.6.tar.gz
- 安装:
cd libevhtp-1.1.6/ cmake -DEVHTP_DISABLE_SSL=ON -DEVHTP_BUILD_SHARED=OFF . make && sudo make install
构建服务目录
mkdir /data/haiwen/
cd /data/haiwen/
mkdir seafile-server
cd seafile-server
mkdir src
构建完毕后,服务目录应为
haiwen/
└── seafile-server
└─────── src
安装对应服务
拉取代码
分别从git
仓库上拉取最新的源码
- https://github.com/haiwen/libsearpc/tags
- https://github.com/haiwen/ccnet-server/tags
- https://github.com/haiwen/seafile-server/tags
- https://github.com/haiwen/seahub/tags
其中ccnet-server
、seafile-server
和seahub
的版本应当一致
libsearpc
进入
src
目录cd /data/haiwen/seafile-server/src/
下载最新的安装包
wget https://github.com/haiwen/libsearpc/archive/v3.2-latest.tar.gz
解压
tar xf v3.2-latest.tar.gz
安装
cd libsearpc-3.2-latest/ ./autogen.sh ./configure make && make install
导入路径
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
ccnet-server
进入
src
目录cd /data/haiwen/seafile-server/src/
下载最新的安装包
wget https://github.com/haiwen/ccnet-server/archive/v7.1.1-server.tar.gz
解压
tar xf v7.1.1-server.tar.gz
安装
cd ccnet-server-7.1.1-server/ ./autogen.sh ./configure --with-mysql=/usr/local/bin/mariadb_config make && make install
若执行
./configure
出现了错误configure: error: Package requirements (libsearpc >= 1.0) were not met: No package 'libsearpc' found
则确保你上一步服务
libsearpc
是否正确安装好了,并正确导入了路径export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
seafile-server
进入
src
目录cd /data/haiwen/seafile-server/src/
下载最新的安装包
wget https://github.com/haiwen/seafile-server/archive/v7.1.1-server.tar.gz
解压
tar xf v7.1.1-server.tar.gz
安装
cd seafile-server-7.1.1-server/ ./autogen.sh ./configure --with-mysql=/usr/local/bin/mariadb_config make && make install
更新系统库
sudo ldconfig
seahub
进入
server
目录cd /data/haiwen/seafile-server
下载最新的安装包
wget https://github.com/haiwen/seahub/archive/v7.1.1-server.tar.gz
解压
tar xf v7.1.1-server.tar.gz
更改名字(后续安装所必需)
mv seahub-7.1.1-server/ seahub
安装seahub依赖
cd seahub pip3 install -r requirements.txt # 若出现安装超时,可加上--timeout=1000
配置服务
修改脚本文件
当上述服务都安装完毕后,seafile-admin
命令应该就已经安装到了系统中,通过此命令我们来进行一系列配置。
因为seafile-admin
脚本还是基于python2.7
的,所以需要我们自己修改一下
找到脚本文件,并进入编辑:
[root@localhost haiwen]# whereis seafile-admin seafile-admin: /usr/local/bin/seafile-admin [root@localhost haiwen]# vim /usr/local/bin/seafile-admin
修改文件头为
python3
第一行:#!/usr/bin/env python
修改为:
#!/usr/bin/env python3
将关于python版本的检查代码注释掉
#if sys.version_info.major == 3: # print 'Python 3 not supported yet. Quit now' # sys.exit(1) #if sys.version_info.minor < 6: # print 'Python 2.6 or above is required. Quit now' # sys.exit(1)
将关于django版本的检查代码注释掉
#if django.VERSION[0] != 1 or django.VERSION[1] != 8: # error('Django 1.8 is required')
修改初始化
seahub
数据库的函数def init_seahub(): seahub_dir = conf[CONF_SEAHUB_DIR] # create seahub_settings.py create_seahub_settings_py() argv = [PYTHON, 'manage.py', 'syncdb'] # Set proper PYTHONPATH before run django syncdb command env = get_seahub_env() print("") print("") info('Now initializing seahub database, please wait...') print("") if run_argv(argv, cwd=seahub_dir, env=env) != 0: error('Seahub syncdb failed') info('done') move_avatar() create_gunicorn_conf()
改为:
def init_seahub(): seahub_dir = conf[CONF_SEAHUB_DIR] # create seahub_settings.py create_seahub_settings_py() argv1 = [PYTHON, 'manage.py', 'makemigrations'] argv2 = [PYTHON, 'manage.py', 'migrate'] # Set proper PYTHONPATH before run django syncdb command env = get_seahub_env() print("") print("") info('Now initializing seahub database, please wait...') print("") if run_argv(argv1, cwd=seahub_dir, env=env) != 0: error('Seahub syncdb failed') if run_argv(argv2, cwd=seahub_dir, env=env) != 0: error('Seahub syncdb failed') info('done') move_avatar() create_gunicorn_conf()
将文件中相关函数修改为
python3
用法 例如print
函数后带括号,rawinput
函数修改为input
,except OSError, e:
修改为except OSError as e:
按照报错一步步修改
执行脚本文件
执行脚本文件进行配置
seafile-admin setup
报错:
Error: Python module "compressor" not found. Please install it first
提醒我们安装
django_compressor
:pip3 install django_compressor
继续报错:
fatal error: Python.h: No such file or directory
安装环境依赖:
yum install python3-devel -y
重新安装:
pip3 install django_compressor
, 成功。报错:
Error: Python module "constance" not found. Please install it first
提醒我们安装django-constance
:pip3 install django-constance
报错:
error while loading shared libraries: libmariadb.so.3: cannot open shared object file: No such file or directory
导入库依赖:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/mariadb
报错:ModuleNotFoundError: No module named 'seaserv' 这是
seafile
的服务包,需要我们导入。[root@localhost haiwen]# find / -name seaserv -type d #找到包的位置 find: ‘/run/user/1000/gvfs’: Permission denied /usr/local/lib64/python2.7/site-packages/seaserv /data/haiwen/seafile-server/src/seafile-server-7.1.1-server/python/seaserv [root@localhost haiwen]# export PYTHONPATH=/usr/local/lib64/python2.7/site-packages/ #导入路径
成功示例:
[root@localhost haiwen]# seafile-admin setup
-----------------------------------------------------------------
This script will guide you to config and setup your seafile server.
Make sure you have read seafile server manual at
https://github.com/haiwen/seafile/wiki
Press [ENTER] to continue
-----------------------------------------------------------------
check python modules ...
checking sqlite3
checking chardet
checking six
checking pytz
checking rest_framework
checking compressor
checking statici18n
checking jsonfield
checking dateutil
checking constance
checking openpyxl
checking python imaging library(PIL)
What is the ip of the server? (For example: www.mycompany.com, 192.168.1.101)
[ip or domain ] 192.168.0.57
Where do you want to put your seafile data? (Please use a volume with enough free space)
[default /data/haiwen/seafile-data ]
Which port do you want to use for the seafile server?
[default 12001 ]
Which port do you want to use for the seafile fileserver?
[default 8082 ]
This is your configuration
------------------------------------------
ccnet conf dir: /data/haiwen/ccnet
server host: 192.168.0.57
seafile data dir: /data/haiwen/seafile-data
seafile port: 12001
seafile fileserver port: 8082
------------------------------------------
Press ENTER if the config is right, or anything else to re-config
Generating ccnet configuration...
done
Successly create configuration dir /data/haiwen/ccnet.
done
Generating seafile configuration...
Done.
done
Now initializing seahub database, please wait...
...
...
...
-----------------------------------------------------------------
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------
-----------------------------------------------------------------
To start/stop seafile server:
$ cd /data/haiwen
$ seafile-admin { start | stop }
If you have any problem, refer to
Seafile server manual: https://github.com/haiwen/seafile/wiki
Seafile discussion group: https://groups.google.com/forum/?fromgroups#!forum/seafile
Seafile website: http://www.seafile.com
for more information.
配置使用mariaDB数据库
ccnet.conf
打开ccnet.conf
文件,vim conf/ccnet.conf
添加如下:
[Database]
ENGINE = mysql
HOST = 127.0.0.1
PORT = 3306
USER = root
PASSWD = your password
DB = ccnet-db
CONNECTION_CHARSET = utf8
seafile.conf
打开seafile.conf
文件,vim conf/seafile.conf
添加如下:
[database]
type = mysql
host = 127.0.0.1
port = 3306
user = root
password = your password
db_name = seafile-db
connection_charset = utf8
注意:这里的配置都是小写,和ccnet.conf
里的不一致,第一次我简单的复制了ccnet.conf
里的数据配置进行修改,导致一直报错。
settings.py
打开settings.py
文件,vim seafile-server/seahub/seahub/settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '%s/seahub/seahub.db' % PROJECT_ROOT, # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
修改如下:
```
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'seahub-db',
'USER': 'root',
'PASSWORD': 'your password',
'HOST': '127.0.0.1',
'PORT': '3306'
}
}
```
找到789行,注释掉
```
#DATABASES['default']['NAME'] = os.path.join(install_topdir, 'seahub.db')
```
建表
[root@localhost haiwen]# cd seafile-server/src/seafile-server-7.1.1-server/scripts/sql/mysql/
[root@localhost mysql]# ls
ccnet.sql seafile.sql
[root@localhost mysql]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database `ccnet-db` character set = 'utf8';
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create database `seafile-db` character set = 'utf8';
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create database `seahub-db` character set = 'utf8';
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`;
Query OK, 0 rows affected (0.04 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> use ccnet-db
Database changed
MariaDB [ccnet-db]> source ccnet.sql;
MariaDB [ccnet-db]> use seafile-db;
Database changed
MariaDB [seafile-db]> source seafile.sql;
MariaDB [seafile-db]> quit;
Bye
利用已有配置文件重新安装
[root@localhost haiwen]# seafile-admin setup
It seems there already exists ccnet config files in /data/haiwen/ccnet, Do you want to use them?
[yes or no] yes
Where do you want to put your seafile data? (Please use a volume with enough free space)
[default /data/haiwen/seafile-data ]
It seems there already exists seafile data in /data/haiwen/seafile-data, Do you want to use them?
[yes or no] yes
This is your configuration
ccnet config: use existing config in /data/haiwen/ccnet
seafile: use existing config in /data/haiwen/seafile-data
Press ENTER if the config is right, or anything else to re-config
Your seafile server configuration has been finished successfully.
启动服务
[root@localhost haiwen]# seafile-admin start
Starting seafile-server...
** Message: 18:01:27.824: seafile-controller.c(554): No seafevents.
Starting seahub...
!!!
!!! WARNING: configuration file should have a valid Python extension.
!!!
Seahub running on port 8000
Done
创建管理员
[root@localhost haiwen]# seafile-admin create-admin
E-mail address: [email protected]
Password:
Password (again):
Superuser created successfully.
服务皆已安装且启动完毕,可以通过网页或客户端登录http://192.168.0.57:8000/