How to Install Seafile Self-Hosted Cloud Storage with Apache Maria DB on Ubuntu 24.04 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 Download the Seafile server archive. https://plus.seafile.com/d/6e5297246c/?p=%2Fpro&mode=list Upload to seafile directory Extract the archive. tar xzf seafile-pro-server_11.0.19_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/your_domain.conf Type this in your editor: ServerAdmin webmaster@localhost ServerName your_domain ServerAlias www.your_domain DocumentRoot /var/www/your_domain Options Indexes FollowSymLinks AllowOverride All Require all granted ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Save and close the file when you are finished. Enable the file with the a2ensite tool: sudo a2ensite your_domain.conf Test for configuration errors: sudo apache2ctl configtest Restart your web server with the following command: sudo systemctl restart apache2 Install certbot on Ubuntu 22.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 python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev sudo apt install -y python3 python3-setuptools python3-pip libmysqlclient-dev memcached libmemcached-dev Run the following command to install Python dependencies. sudo pip3 install --timeout=3600 pyproject-toml django==4.2.* future==0.18.* mysqlclient==2.1.* \ pymysql pillow==10.2.* pylibmc captcha==0.5.* markupsafe==2.0.1 jinja2 sqlalchemy==2.0.18 \ psd-tools django-pylibmc django_simple_captcha==0.6.* djangosaml2==1.5.* pysaml2==7.2.* pycryptodome==3.16.* cffi==1.16.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/your_seafile_version 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 | stop | restart } ----------------------------------------------------------------- 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. Start Seafile Server Run the following command to start the Seaf-server. sudo ./seafile.sh start You will get the following output. Starting seafile server, please wait ... ** Message: 04:42:32.937: seafile-controller.c(621): No seafevents. 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. LC_ALL is not set in ENV, set to en_US.UTF-8 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 ] user@example.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 Then, open the Apache SSL virtual host file and update it: sudo nano /etc/apache2/sites-enabled/your_domain-le-ssl.conf Add this lines before Alias /media /var/www/html/seafile/seafile-server-latest/seahub/media Require all granted # 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/ Check for Apache syntax error and restart the service to apply the changes: sudo apache2ctl configtest sudo systemctl restart apache2 Update Seafile Configuration files and Start the Services sudo nano /var/www/html/seafile/conf/ccnet.conf Add the service URL with your domain name in the file: SERVICE_URL = https://your_domain Save and close the file. 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://your.domain.com" FILE_SERVER_ROOT = 'https://your.domain.com/seafhttp' CSRF_TRUSTED_ORIGINS = ['https://your.domain.com'] 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 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 Access Seafile Server Admin Console via Web Interface https://your-domain -------------------------------------------------------- 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 [OFFICE CONVERTER] enabled = true