准备工作 Ubuntu24 & After Install后的工作
编译seafile 注:假定编译目录入口为 /opt/pzbox/seafile-src ,编译后的包移到 /opt/pzbox/seafile/seafile-server **
1 2 3 sudo mkdir /opt/pzbox/seafile-srcsudo mkdir /opt/pzbox/seafilesudo chown -R pzbox:pzbox /opt/pzbox/
1. 选择编译版本 可以在seahub项目的tag中找到一个版本号,如 v12.0.11 -server,则我们选择的版本号就是12.0.11 。
2. 选择性下载并编译(也可手工下载) 目录仅是seafile-build.sh和seafile-build.py
1 2 3 4 5 cd /opt/pzbox/seafile-srcgit clone --filter=blob:none --sparse https://github.com/haiwen/seafile-docker.git cd seafile-dockergit sparse-checkout set build/seafile_12.0 cp build/seafile_12.0/seafile-build.* ..
3. 运行脚本 1 2 3 4 5 6 cd /opt/pzbox/seafile-src/python3 -m venv .venv source .venv/bin/activatepip config set global.index-url http://mirrors.aliyun.com/pypi/simple/ sudo -H ./seafile-build.sh 12.0.11
4. 完成后 1 2 3 mv seafile-server-12.0.11/ /opt/pzbox/seafilesudo chown -R pzbox:pzbox /opt/pzbox/seafileln -s /opt/pzbox/seafile/seafile-server-12.0.11 /opt/pzbox/seafile/seafile-server
依赖组件 1 2 3 4 5 6 7 sudo apt-get updatesudo apt-get install pwgensudo apt-get install -y memcached libmemcached-devsudo systemctl enable memcachedsudo apt-get install -y pylibmc django-pylibmcsudo apt-get install -y ldap-utils libldap2-dev libmemcached-devsudo apt-get install -y libmysqlclient-dev default-libmysqlclient-dev
Mariadb 10.11 1. 添加key 1 2 3 sudo apt-get install apt-transport-https curlsudo mkdir -p /etc/apt/keyringssudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
2. 修改源:/etc/apt/sources.list.d/mariadb.sources 1 2 3 4 5 6 7 8 9 10 # MariaDB 10.11 repository list - created 2025-03-21 07:47 UTC # https://mariadb.org/download/ X-Repolib-Name: MariaDB Types: deb # deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details. # URIs: https://deb.mariadb.org/10.11/ubuntu URIs: https://mirrors.aliyun.com/mariadb/repo/10.11/ubuntu Suites: noble Components: main main/debug Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
3. 安装执行 1 2 sudo apt-get updatesudo apt-get install mariadb-server
4. 初始化 1 2 3 4 5 6 $ sudo mysql use mysql; set password for 'root'@'localhost'=password('pzbox2025'); create user 'root'@'%' identified by 'pzbox2025'; grant all privileges on *.* to 'root'@'%' with grant option; flush privileges;
5. 绑定所有网卡(生产环境不建议) 文件:/etc/mysql/mariadb.conf.d/50-server.cnf
1 2 + bind-address = 0.0.0.0 - bind-address = 127.0.0.1
创建用户(可选) 1 2 3 4 sudo useradd -m -s /bin/bash seafilesudo usermod -aG pzbox seafile sudo passwd seafilesudo chown -R seafile:seafile /opt/pzbox/seafile/
执行安装脚本 1 2 3 4 5 6 7 cd /opt/pzbox/seafile/seafile-serverpython3 -m venv .venv source .venv/bin/activatepip install sqlalchemy pytz ./setup-seafile-mysql.sh
运行前 启动各服务
1 sudo systemctl start memcached
pip依赖 1 2 3 4 5 6 7 cd /opt/pzbox/seafile/seafile-serversource .venv/bin/activatepip3 install --timeout =3600 django==4.2.* future==1.0.* mysqlclient==2.2.* \ pymysql pillow==10.4.* pylibmc captcha==0.6.* markupsafe==2.0.1 jinja2 sqlalchemy==2.0.* \ psd-tools django-pylibmc django_simple_captcha==0.6.* djangosaml2==1.9.* pysaml2==7.3.* pycryptodome==3.20.* \ cffi==1.17.0 lxml python-ldap==3.4.* gevent==24.2.*
seafile各配置文件 1. /opt/pzbox/seafile/conf/seahub_settings.py 1 2 3 4 5 6 CACHES = { 'default' : { 'BACKEND' : 'django_pylibmc.memcached.PyLibMCCache' , 'LOCATION' : '127.0.0.1:11211' , }, }
2. /opt/pzbox/seafile/conf/.env
将生成的字符串贴入.env:
1 2 3 4 5 6 7 8 9 10 JWT_PRIVATE_KEY=xxxxxxxxxxxxxxxxxxxxxx SEAFILE_SERVER_PROTOCOL=https SEAFILE_SERVER_HOSTNAME=file.pzbox.cn SEAFILE_MYSQL_DB_HOST=localhost SEAFILE_MYSQL_DB_PORT=3306 SEAFILE_MYSQL_DB_USER=seafile SEAFILE_MYSQL_DB_PASSWORD=seafile SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnet_db SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafile_db SEAFILE_MYSQL_DB_SEAHUB_DB_NAME=seahub_db
启动seafile 1 2 3 4 cd /opt/pzbox/seafile/seafile-serversource .venv/bin/activate./seafile.sh start ./seahub.sh start
加入systemd service
/etc/systemd/system/seafile.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [Unit] Description=Seafile After=mariadb.service [Service] Type=oneshot WorkingDirectory=/opt/pzbox/seafile/seafile-server/ ExecStart=/bin/bash -c 'cd /opt/pzbox/seafile/seafile-server/ && source .venv/bin/activate && seafile.sh start' ExecStop=/opt/pzbox/seafile/seafile-server/seafile.sh stop Environment="PATH=/opt/pzbox/seafile/seafile-server/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" RemainAfterExit=yes User=pzbox Group=pzbox [Install] WantedBy=multi-user.target
/etc/systemd/system/seahub.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [Unit] Description=Seahub After=seafile.service [Service] Type=oneshot WorkingDirectory=/opt/pzbox/seafile/seafile-server/ ExecStart=/bin/bash -c 'cd /opt/pzbox/seafile/seafile-server/ && source .venv/bin/activate && seahub.sh start' ExecStop=/opt/pzbox/seafile/seafile-server/seahub.sh stop Environment="PATH=/opt/pzbox/seafile/seafile-server/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" RemainAfterExit=yes User=pzbox Group=pzbox [Install] WantedBy=multi-user.target
最后
1 2 3 sudo systemctl enable seafilesudo systemctl enable seahubsudo systemctl daemon-reload
好了
参考资料https://manual.seafile.com/12.0/setup_binary/installation_ce/ https://manual.seafile.com/latest/config/env/ https://manual.seafile.com/latest/config/seafile-conf/ https://sqlpey.com/python/top-5-ways-to-enable-virtualenv-in-systemd-service-unit/