Seafile is awesome. Your own managed ‘cloud’ type file sharing and storage with history. I’ve used it for many years. I am redoing some of my home networking and recently wanted to put Seafile on a new Debian 12 VM.
From this thread: https://forum.seafile.com/t/seafile-server-11-0-3-on-debian-12-bookworm-seahub-can-not-be-started/19145/11 there was some very helpful information about using a python virtual environment (venv) to get Seafile running on Debian 12. I happened across it because I had started by going through the Seafile documentation and had issues getting it to work. There are some caveats to getting it to work on Debian 12 instead of the usually supported Ubuntu 22 etc.
I can confirm that the python venv is certainly the way to go. I had a clean install of Debian 12 in a VM and did the following:
apt-get -y install wget python3 python3-dev python3-setuptools python3.11-venv
python3-pip libmariadb-dev ldap-utils libldap2-dev memcached libmemcached-dev mariadb-server
Note the ‘libmariadb-dev
‘ instead of the ‘libmysqlclient-dev
‘ that the Seafile docs mention. Debian 12 has moved to MariaDB so the client package needs to reflect that. I also installed the python3.11-venv package.
I installed the Seafile database within the VM itself so it can be relatively self contained as a VM.
Run ‘mysql’ and set the root password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'secure root password';
After that is done, make a seafile user:
adduser --system seafile --group --shell /bin/bash
I tend to put things in /usr/local but you can use /opt or whatever directory you like – but putting Seafile in its own directory is a clean way to do it.
Make /usr/local/seafile (or whatever you choose for the following steps) owned by the ‘seafile’ user you made.
su - seafile
cd /usr/local/seafile
You will want to enable the Python virtual environment (venv) now.
python3 -m venv python-venv
source python-venv/bin/activate
Then you can finally run the ‘pip’ setup (this is all one line)
pip3 install --timeout=3600 django==3.2.* future==0.18.* mysqlclient==2.1.* pymysql pillow==10.0.* pylibmc captcha==0.4 markupsafe==2.0.1 jinja2 sqlalchemy==2.0.18 psd-tools django-pylibmc django_simple_captcha==0.5.* djangosaml2==1.5.* pysaml2==7.2.* pycryptodome==3.16.* cffi==1.15.1 lxml python-ldap==3.4.3
From there, download the Seafile server
mkdir download
cd download
wget https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_11.0.9_x86-64.tar.gz
cd /usr/local/seafile
tar -ztvf seafile-server_11.0.9_x86-64.tar.gz
You should then have the Seafile server within /usr/local/seafile.
cd seafile-server-11.0.9
From there, you will want to run:
./setup-seafile-mysql.sh
The installer will guide you through the steps but you should end up with Seafile installed.
A helper script such as this can be used so you can start the processes as root but will su to the seafile user and engage the Python virtual environment before starting the services as usual.
I have this script as /usr/local/seafile/startup.sh
!/bin/bash
SERVERBASE=/usr/local/seafile
SERVERHOME=${SERVERBASE}/seafile-server-latest
SERVERUSER=seafile
cd $SERVERBASE
if [ whoami == 'root' ]; then
su - $SERVERUSER -s /bin/bash -c $0 $@
else
source "python-venv/bin/activate"
$SERVERHOME/seafile.sh start
$SERVERHOME/seahub.sh start
fi
From there you can run that script to run Seafile.
An example systemd unit file for starting it at boot:
[Unit]
Description=Seafile
Needs=network.target
[Service]
ExecStart=/bin/bash /usr/local/seafile/startup.sh
[Install]
WantedBy=multi-user.target
Place that in /etc/systemd/system/seafile.service
systemctl enable seafile
And you should be off and going!