Ubuntu 22.04 直接部署 Seafile 教程

0x01 引言

Seafile 是一个开源、专业、可靠的云存储平台,解决文件集中存储、共享和跨平台访问等问题,其他百度…

https://www.seafile.com

0x02 部署

本次部署系统环境 Ubuntu 22.04,后面操作均在 root 下操作

$ sudo lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

准备

安装依赖

apt -y update
apt -y install python3 python3-setuptools python3-pip python3-ldap libmysqlclient-dev

pip3 install --timeout=3600 django==3.2.* future mysqlclient pymysql \
Pillow pylibmc captcha jinja2 sqlalchemy==1.4.3 psd-tools \
django-pylibmc django-simple-captcha pycryptodome==3.12.0 cffi==1.15.1 lxml

安装 Java 有就跳过

$ apt -y install default-jre
$ java --version
openjdk 11.0.18 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)

安装 Memcached 有就跳过

$ apt -y install memcached
$ memcached --version
memcached 1.6.14

# 启动并自启
$ systemctl enable --now memcached

安装 Nginx 最新版,有就跳过

$ apt-add-repository ppa:ondrej/nginx
$ apt -y install nginx
$ nginx -version
nginx version: nginx/1.22.1

# 设置自启
$ systemctl enable nginx

安装 MySQL8.0 版,有就跳过

$ apt -y install mysql-server
$ mysql --version
mysql  Ver 8.0.32-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu))

因为我新安装的数据库,要设置下ROOT密码 qwe123qwe 你们不是可以跳过

$ mysql -uroot -p
mysql> alter user 'root'@'localhost' identified with caching_sha2_password by 'qwe123qwe';
mysql> flush privileges;

安装 ElasticSearch,有就跳过

# 导入存储库的GPG密钥
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg

# 添加源
echo "deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

# 安装
apt update && apt -y install elasticsearch
systemctl enable --now elasticsearch

# 创建软连接
ln -s /usr/share/elasticsearch/bin/* /usr/local/bin

# 查看版本
$ elasticsearch --version
elasticsearch --version
Version: 7.17.9, Build: default/deb/ef48222227ee6b9e70e502f0f0daa52435ee634d/2023-01-31T05:34:43.305517834Z, JVM: 19.0.2

安装

下载 Seafile 最新企业版 9.0.14

https://download.seafile.com/d/6e5297246c/?p=/pro&mode=list

2023-02-28T11:36:40.png

创建所需目录,并解压安装包

mkdir -p /opt/seafile && cd $_
tar -zxvf seafile-pro-server_9.0.14_x86-64_Ubuntu.tar.gz

自动安装(密码必须包含 大小写字母、数字、符号

cd seafile-*
./setup-seafile-mysql.sh auto -u seafile -w QWEsad213! -r qwe123qwe
参数 说明
-u 自动创建Seafile数据库账户
-w 自动创建Seafile数据库账户密码
-r 数据库root密码

有该提示就是安装成功了

...
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start <port> | stostart <port> }
 
-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------
 
port of seafile fileserver:   8082
port of seahub:               8000
...

Mysql8.0的到这里要去数据库修改下用户密码插件

$ mysql -uroot -pqwe123qwe!
mysql> alter user 'seafile'@'127.0.0.1' identified with mysql_native_password by 'QWEsad213!';
mysql> flush privileges;

运行

运行 Seafile

$ ./seafile.sh start
...
Seafile server started     # 看到这个说明启动成功

Done.

因为 Ubuntu22.04 安装不了 cffi 1.14.0 版本的,当你可以修改文件呀!!!

vim seahub/thirdpart/cffi

把它们改为 1.15.1 即可,目前运行而没见到什么问题…

__version__ = "1.15.1"
__version_info__ = (1, 15, 1)

运行 Seahub

./seahub.sh start

第一次启动 Seahub 需要配置管理员账户

What is the email for the admin account?
[ admin email ] admin@admin.com # 管理员账户邮箱

What is the password for the admin account?
[ admin password ]              # 管理员密码
 
Enter the password again:
[ admin password again ]        # 重复管理员账户密码
 
----------------------------------------
Successfully created seafile admin
----------------------------------------

Seahub server started           # 看到这个说明启动成功

Done.

使用 pgrep 命令检查 seafile/seahub 进程是否还在运行中

$ pgrep -f seafile-controller   # 查看 Seafile 进程
1792
$ pgrep -f seahub               # 查看 Seahub 进程
5436
5437
5438
5439
5440
5441

有回显就是启动成功了


编辑 seafevents.conf 配置文件

vim pro/python/seafes/tests/integration/seafevents.conf

[INDEX FILES] 字段下添加

[INDEX FILES]
external_es_server = true
es_host = your elasticsearch server's IP     # ElasticSearch 服务器ip或者域名
es_port = 9200                               # ElasticSearch 容器映射端口

重启 Seafile 程序,使配置文件生效

./seafile.sh restart && ./seahub.sh restart 

0x03 配置

添加 Nginx 反向代理,复制执行

cat<<'EOF'>/etc/nginx/sites-enabled/seafile.hello.com.conf
server {
    listen 80;
    server_name seafile.hello.com;
    proxy_set_header X-Forwarded-For $remote_addr;

    # 仅能用
    location / {
        proxy_pass         http://127.0.0.1:8000;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;
        proxy_read_timeout 1200s;
        client_max_body_size 0;

        access_log      /var/log/nginx/seafile.access.log;
        error_log       /var/log/nginx/seafile.error.log;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_request_buffering off;

        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;
        send_timeout  36000s;
    }
    location /media {
        root /home/user/haiwen/seafile-server-latest/seahub;
    }
}
EOF

重启价值

nginx -s reload

添加 HOSTS

echo '192.168.6.128 seafile.hello.com' >/etc/hosts

配置证书

可参考上篇 Seafile 企业版部署之Docker…

在线编辑

如上

0x04 使用

浏览器访问

http://seafile.hello.com/

使用刚刚注册的账号登录

2023-02-28T13:49:56.png

在后台设置下 SERVICE_URLFILE_SERVER_ROOT

http://seafile.hello.com/sys/web-settings/

2023-02-28T13:50:53.png

正常上传

2023-02-28T13:51:47.png

客户端

下载 8.X 客户端

https://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-8.0.10.msi

登录

2023-02-28T13:56:10.png

试了上传下载都没问题

2023-02-28T14:00:21.png

大文件也正常上传

2023-02-28T14:20:40.png

其他的自己玩~~~


本文链接 点击前往


10.0.0 beta (2023-02-22)

  • Update Python dependencies and support Ubuntu 22.04 and Debian 11
  • Add a new notification server (document will be provided later)
  • Update WebDAV password to use one-way hash
  • Remove SQL sub queries to improve SQL query speed in seaf-server
  • Show number of shared users/groups if any when deleting a folder
  • Support online playing of .wav files

社区版是更新了,但是企业版 Seafile Pro 9.0.15 的 Python 依赖还是没更新,要自己手动更新


=== 华丽分割线 === 编辑不了帖子 ===

因为 Ubuntu22.04 是安装不了 cffi 1.14.0 的,我们要把它改为 1.15.1 版本,先备份

cd /opt/seafile/seafile-server-latest
mv seahub/thirdpart/cffi seahub/thirdpart/cffi.bak

安装 cffi 到指定目录

pip3 install cffi==1.15.1 --upgrade --target=seahub/thirdpart/

其他的正常按上面的来就行了

社区版和企业版安装完全一样,除了安装包不一样,社区版下载地址

https://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_10.0.0_x86-64.tar.gz

社区版 SeaFile Server 10.0 已经更新了 Python 依赖,直接安装就可以了,不用更改 Cffi 模块

直接部署的seafile 在线预览office应该怎么弄呢 看了您的docker部署 但是没搞定 在线预览显示的是空白页

大神求帮助 搞不定在线预览office


大神,这一步没看懂是干嘛的 社区版似乎不用设置这个也能运行

每一次在pip3 install这里都会报错
Installing build dependencies … done
Getting requirements to build wheel … error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [27 lines of output]
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Trying pkg-config --exists mysqlclient
Command ‘pkg-config --exists mysqlclient’ returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command ‘pkg-config --exists mariadb’ returned non-zero exit status 127.
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 363, in
main()
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 345, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 130, in get_requires_for_build_wheel
return hook(config_settings)
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 162, in get_requires_for_build_wheel
return self._get_build_requires(
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 143, in _get_build_requires
self.run_setup()
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 158, in run_setup
exec(compile(code, file, ‘exec’), locals())
File “setup.py”, line 154, in
ext_options = get_config_posix(get_options())
File “setup.py”, line 48, in get_config_posix
pkg_name = find_package_name()
File “setup.py”, line 27, in find_package_name
raise Exception(
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
大佬知道怎么回事吗?Ubuntu22.04 LTS

把python版本换成3.8以上

seafile的nginx和onlyoffice 的nginx没通,你可以看一下防火墙端口,配置的问题,看onlyoffice报错日志

安装mysqkclient就会报这个错
root@ruhr:/home/ruhr# pip install --timeout=3600 mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.2.0.tar.gz (89 kB)
Installing build dependencies … done
Getting requirements to build wheel … error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [27 lines of output]
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Trying pkg-config --exists mysqlclient
Command ‘pkg-config --exists mysqlclient’ returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command ‘pkg-config --exists mariadb’ returned non-zero exit status 127.
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 363, in
main()
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 345, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 130, in get_requires_for_build_wheel
return hook(config_settings)
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 162, in get_requires_for_build_wheel
return self._get_build_requires(
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 143, in _get_build_requires
self.run_setup()
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 158, in run_setup
exec(compile(code, file, ‘exec’), locals())
File “setup.py”, line 154, in
ext_options = get_config_posix(get_options())
File “setup.py”, line 48, in get_config_posix
pkg_name = find_package_name()
File “setup.py”, line 27, in find_package_name
raise Exception(
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

用pip3 install