Prerequisites:
A server running Ubuntu 24.04 with a minimum of 2 CPU Cores and 2GB of RAM.
A non-root user with sudo privileges.
A fully qualified domain name (FQDN) like seafile.example.com.
Make sure everything is updated.
sudo apt update
sudo apt upgrade
Then, install the apache2 package :
sudo apt install apache2
Create a Seafile directory and user
sudo mkdir /var/www/html/seafile
Create the user for Seafile. Add user with home directory
sudo useradd -m -d /var/www/html/seafile seafile
Change password of created user
sudo passwd seafile
Change shell – optional command
sudo chsh -s /bin/bash seafile
Add sudo command to created user
sudo usermod -aG sudo seafile
Change the ownership of the directory to the new user.
sudo chown -R seafile: /var/www/html/seafile
Log in as the Seafile user. Enter your user password when prompted.
sudo login
or
su - name_of_user
Download the Seafile server archive.
Upload to seafile directory
Extract the archive.
tar xzf seafile-pro-server_12.0.11_x86-64_Ubuntu.tar.gz
To set up an Apache virtual host you need to set default permissions for your webroot:
sudo chmod -R 755 /var/www/html/seafile
You need to create a sites-available directory:
sudo nano /etc/apache2/sites-available/seafile.conf
Type this in your editor:
<VirtualHost *:80>
ServerAdmin barosoft@gmail.com
ServerName barosoft.go.ro
ServerAlias barosoft.go.ro
DocumentRoot /var/www/html/seafile
<Directory /var/www/html/seafile/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save and close the file when you are finished.
Enable the file with the a2ensite tool:
sudo a2ensite seafile.conf
Modify apache config file
sudo nano /etc/apache2/apache2.conf
Put this line at the end of file:
ServerName localhost
Restart apache
sudo systemctl restart apache2
Test for configuration errors:
sudo apache2ctl configtest
sudo systemctl status apache2
You must see something like this:
apache2.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled) Active: active (running) since Sun 2025-04-06 09:35:53 UTC; 1min 0s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 16556 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 16561 (apache2) Tasks: 55 (limit: 19003) Memory: 5.6M (peak: 6.8M) CPU: 25ms CGroup: /system.slice/apache2.service ├─16561 /usr/sbin/apache2 -k start ├─16563 /usr/sbin/apache2 -k start └─16564 /usr/sbin/apache2 -k start Apr 06 09:35:53 seafile systemd[1]: Starting apache2.service - The Apache HTTP Server... Apr 06 09:35:53 seafile systemd[1]: Started apache2.service - The Apache HTTP Server.
Install certbot on Ubuntu 24.04
First of all, you need to install “certbot” to get an SSL certificate with Let’s Encrypt.
sudo apt install certbot python3-certbot-apache
sudo certbot --apache
It will ask you some questions. the first will ask you to enter your email address for renewal notifications and security notices:
Verify Certificates From Let’s Encrypt
sudo certbot renew --dry-run
MariaDB Installation & Configuration for Seafile Server on Ubuntu 24.04
Then, use the command below to install MariaDB on Ubuntu 24.04:
sudo apt install mariadb-server -y
Also, you must run the security script for MariaDB
sudo mysql_secure_installation
Create Seafile Server Databases
sudo mysql -u root -p
CREATE DATABASE seafiledb CHARACTER SET = 'utf8';
CREATE DATABASE ccnetdb CHARACTER SET = 'utf8';
CREATE DATABASE seahubdb CHARACTER SET = 'utf8';
Create Seafile Database User and grant all the privileges for the created databases to it.
CREATE USER 'seafile'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON seafiledb.* TO 'seafile'@'localhost';
GRANT ALL PRIVILEGES ON ccnetdb.* TO 'seafile'@'localhost';
GRANT ALL PRIVILEGES ON seahubdb.* TO 'seafile'@'localhost';
Then, exit from the MariaDB shell with the following commands:
EXIT;
Installing Seafile Dependencies
Since Seafile is written in the Python Django framework, you need to install its dependencies and Python packages to make it work. Run the following command to install Python tools, Pip package manager, SQL libraries, and Memcached.
sudo apt-get install -y python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev python3 python3-setuptools python3-pip default-libmysqlclient-dev libmysqlclient-dev memcached libmemcached-dev pkg-config
Run the following command to install Python dependencies.
sudo pip3 install --timeout=3600 pyproject-toml django==4.2.* future==1.0.* mysqlclient==2.2.* \ pymysql pillow==10.4.* pillow==10.4.* sqlalchemy==2.0.* pillow_heif==0.18.0 \ gevent==25.5.* pylibmc captcha==0.6.* markupsafe==2.0.1 jinja2 sqlalchemy==2.0.18 \ 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.3 --break-system-packages --ignore-installed wheel==0.42
Last parameter –ignore-installed wheel==0.42 ignore installed wheel version come with your OS. To find your version launch command without this parameter – at the end of command will see error „cannot uninstall wheel [your version]”
Switch to the Seafile directory.
cd /var/www/html/seafile/seafile-pro-server-12.0.17
Before runing the script you need to delete one single line from setup-seafile-mysql.py
sudo vi /var/www/html/seafile/seafile-pro-server-12.0.11/setup-seafile-mysql.py
Delete line at the end of file – line 1566 – db_config.root_conn.close()
Put your cursor at begining of line and press from your keyboard dd
After this close and save – type :x and press Enter
Type :q! if you make some mistake – this command close vi without saving
ON LATEST VERSION 12.0.17 DO NOTHING
Save and close
Run the Seafile installation script.
sudo ./setup-seafile-mysql.sh
The installer script will start. Press the ENTER key to continue.
Checking python on this machine ...
-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at https://download.seafile.com/published/seafile-manual/home.md
Press ENTER to continue
-----------------------------------------------------------------
Next, configure your Seafile server by providing a name for your server, a domain name (seafile.example.com), and the port. You can leave the port field empty for Seafile to stick to the 8082 as the default port. Once configured, press the ENTER key to continue.
What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] Howtoforge
What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] seafile.example.com
Which port do you want to use for the seafile fileserver?
[ default "8082" ]
Next, you will be asked to choose a way to initialize Seafile databases. Since we have already created the database, choose the 2nd option.
-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases
[ 1 or 2 ] 2
Next, you will be asked to enter the database details for Seafile. Leave the host and port fields empty for Seafile to select the default values. Enter the other values as configured in Step 4.
What is the host of mysql server?
[ default "localhost" ]
What is the port of mysql server?
[ default "3306" ]
Which mysql user to use for seafile?
[ mysql user for seafile ] seafile
What is the password for mysql user "seafile"?
[ password for seafile ]
verifying password of user seafile ... done
Enter the existing database name for ccnet:
[ ccnet database ] ccnetdb
verifying user "seafile" access to database ccnet_db ... done
Enter the existing database name for seafile:
[ seafile database ] seafiledb
verifying user "seafile" access to database seafile_db ... done
Enter the existing database name for seahub:
[ seahub database ] seahubdb
verifying user "seafile" access to database seahub_db ... done
Next, you will be shown your Seafile configurations. Press the ENTER key to continue the installation.
---------------------------------
This is your configuration
---------------------------------
server name: Howtoforge
server ip/domain: seafile.example.com
seafile data dir: /var/www/html/seafile/seafile-data
fileserver port: 8082
database: use existing
ccnet database: ccnetdb
seafile database: seafiledb
seahub database: seahubdb
database user: seafile
---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------
You will see the following screen if the installation was successful.
Generating ccnet configuration ...
Generating seafile configuration ...
done
Generating seahub configuration ...
----------------------------------------
Now creating ccnet database tables ...
----------------------------------------
----------------------------------------
Now creating seafile database tables ...
----------------------------------------
----------------------------------------
Now creating seahub database tables ...
----------------------------------------
creating seafile-server-latest symbolic link ... done
-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------
run seafile server: ./seafile.sh { start | stop | restart }
run seahub server: ./seahub.sh { start <port> | stop | restart <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
When problems occur, Refer to https://download.seafile.com/published/seafile-manual/home.md for information.
JWT_PRIVATE_KEY, A random string with a length of no less than 32 characters, can be generated by
Need to install pwgen
sudo apt install pwgen
Generate with this command
sudo pwgen -s 40 1
copy generated string to notepad or any text editor
Create the .env file in conf/ directory /var/www/html/seafile/conf/.env
sudo nano /var/www/html/seafile/conf/.env
Put this lines on it
TIME_ZONE=Europe/Bucharest JWT_PRIVATE_KEY=dtGhGDWINLFhVPc3D9CjaLhwu7sCfAozyomVkl2G SEAFILE_SERVER_PROTOCOL=https SEAFILE_SERVER_HOSTNAME=barosoft.go.ro SEAFILE_MYSQL_DB_HOST=localhost SEAFILE_MYSQL_DB_PORT=3306 SEAFILE_MYSQL_DB_USER=seafile SEAFILE_MYSQL_DB_PASSWORD=password SEAFILE_MYSQL_DB_CCNET_DB_NAME=ccnetdb SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=seafiledb SEAFILE_MYSQL_DB_SEAHUB_DB_NAME=seahubdb LC_ALL=en_US.UTF-8
Start Seafile Server
Run the following command to start the Seaf-server.
sudo ./seafile.sh start
You will get the following output.
Cannot find JWT_PRIVATE_KEY value from environment, try to read .env file. Starting seafile server, please wait ... License file /var/www/html/seafile/seafile-license.txt does not exist, allow at most 3 trial users Seafile server started Done.
Run the following command to start Seahub.
sudo ./seahub.sh start
The first time Seahub starts, you will be prompted for the administrator account details. You will get the following output. Cannot find JWT_PRIVATE_KEY value from environment, try to read .env file. Starting seahub at port 8000 ... ---------------------------------------- It's the first time you start the seafile server. Now let's create the admin account ---------------------------------------- What is the email for the admin account? [ admin email ] barosoft@gmail.com What is the password for the admin account? [ admin password ] Enter the password again: [ admin password again ] ---------------------------------------- Successfully created seafile admin ---------------------------------------- Seahub is started Done.
Stop the Seafile and Seahub servers.
sudo ./seafile.sh stop
sudo ./seahub.sh stop
Apache Configuration for Seafile on Ubuntu 24.04
To do this, run the command below:
sudo a2enmod proxy_http
sudo systemctl restart apache2
Then, open the Apache SSL virtual host file and update it:
sudo nano /etc/apache2/sites-enabled/seafile-le-ssl.conf
Add this lines before </VirtualHost>
Alias /media /var/www/html/seafile/seafile-server-latest/seahub/media <Location /media> Require all granted </Location> # seafile fileserver ProxyPass /seafhttp http://127.0.0.1:8082 ProxyPassReverse /seafhttp http://127.0.0.1:8082 RewriteEngine On RewriteRule ^/seafhttp - [QSA,L] # seahub web interface SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 ProxyPass / http://127.0.0.1:8000/ ProxyPassReverse / http://127.0.0.1:8000/ </VirtualHost> </IfModule>
Check for Apache syntax error and restart the service to apply the changes:
sudo apache2ctl configtest
sudo systemctl restart apache2
Then, open the Seahub settings with the command below:
sudo nano /var/www/html/seafile/conf/seahub_settings.py
At the file specify the path where the file server is listening for file uploads and downloads.
SECRET_KEY = "" SERVICE_URL = "https://barosoft.go.ro" FILE_SERVER_ROOT = 'https://barosoft.go.ro/seafhttp' CSRF_TRUSTED_ORIGINS = ['https://barosoft.go.ro']
Save and close the file.
Create Systemd Service
To make sure Seafile starts automatically at boot and can withstand reboots, you need to create Systemd service unit files for it.
Create and open the /etc/systemd/system/seafile.service file for editing.
sudo nano /etc/systemd/system/seafile.service
Paste the following code in it.
[Unit] Description=Seafile # add mysql.service or postgresql.service depending on your database to the line below After=network.target mysql.service [Service] Type=forking ExecStart=/var/www/html/seafile/seafile-server-latest/seafile.sh start ExecStop=/var/www/html/seafile/seafile-server-latest/seafile.sh stop LimitNOFILE=infinity User=seafile Group=seafile [Install] WantedBy=multi-user.target
Save the file by pressing Ctrl + X and entering Y when prompted.
Create and open the /etc/systemd/system/seahub.service file for editing.
sudo nano /etc/systemd/system/seahub.service
Paste the following code in it.
[Unit] Description=Seafile hub After=network.target seafile.service [Service] Type=forking # change start to start-fastcgi if you want to run fastcgi ExecStart=/var/www/html/seafile/seafile-server-latest/seahub.sh start ExecStop=/var/www/html/seafile/seafile-server-latest/seahub.sh stop User=seafile Group=seafile [Install] WantedBy=multi-user.target
Save the file by pressing Ctrl + X and entering Y when prompted.
Reload the Systemctl daemon.
sudo systemctl daemon-reload
Run the following commands to enable and start Seafile and Seahub services.
sudo chown -R seafile: /var/www/html/seafile
sudo chmod -R 775 /var/www/html/seafile
sudo systemctl enable --now seafile
sudo systemctl enable --now seahub
Check the status of both services.
sudo systemctl status seafile
Next, check the status of Seahub.
sudo systemctl status seahub
Don’t forget to add this lines on /var/www/html/seafile/conf/seafile.conf
sudo nano /var/www/html/seafile/conf/seafile.conf
Put this at end of file
max_download_dir_size=600000 [zip] windows_encoding = iso-8859-1
with these added lines of code you will be able to download multiple files at once archived in a single zip file
PREVIEW PDF Files with LibreOffice
sudo apt-get install libreoffice libreoffice-script-provider-python
sudo apt-get install poppler-utils
Open file seafevents.conf, in the OFFICE CONVERTER section:
sudo nano /var/www/html/seafile/conf/seafevents.conf
Add this lines on it
[OFFICE CONVERTER] enabled = true
Email setup
Edit this file:
sudo nano /var/www/html/seafile/conf/seahub_settings.py
Add this lines after this: CSRF_TRUSTED_ORIGINS = [‘https://barosoft.go.ro’]
EMAIL_USE_TLS = True EMAIL_HOST = 'mail.barosoft.ro' # smpt server EMAIL_HOST_USER = 'barosoft@barosoft.ro' # username and domain EMAIL_HOST_PASSWORD = 'password' # password EMAIL_PORT = 587 DEFAULT_FROM_EMAIL = EMAIL_HOST_USER SERVER_EMAIL = EMAIL_HOST_USER
Run this command from seafile user
Restart seafile and seahub
./seafile.sh stop
./seahub.sh stop
./seafile.sh start
./seahub.sh start
Access Seafile Server Admin Console via Web Interface https://your_domain.ro






