Seafile is an open-source, cross-platform file-hosting software system. Files are stored on a central server and can be synchronized with personal computers and mobile devices through apps. Files on the Seafile server can also be accessed directly via the server’s web interface.
In this tutorial, we will learn how to install seafile to syn and share files on the centOS 8 system.
How to Install Seafile to Sync and Share Files on CentOS 8
Follow the following steps to install seafile to sync and share files on CentOS 8:
- Step 1 – Update System Packages
- Step 2 – Install Required Dependencies
- Step 3 – Install Nginx and MariaDB
- Step 4 – Create a Database for Seafile
- Step 5 – Install Seafile
- Step 6 – Set Up Admin Account
- Step 7 – Create a Systemd Service File for Seafile
- Step 8 – Configure Nginx for Seafile
- Step 9 – Access Seafile Web Interface
Step 1 – Update System Packages
First of all, open terminal or command line and execute the following command to update base system with the latest available packages:
yum update -y
Step 2 – Install Required Dependencies
Execute the following command on command line to install the EPEL repository in your system:
yum install epel-release -y
Once the EPEL repository is installed, install other dependencies with the following command:
yum install python3 python3-devel python3-setuptools gcc gcc-c++ freetype-devel python3-pip python3-ldap memcached java-1.8.0-openjdk libmemcached libreoffice-headless libreoffice-pyuno libffi-devel pwgen curl tar -y
Once all the dependencies are installed, use the pip command to install other dependencies:
pip3 install Pillow pylibmc captcha jinja2 sqlalchemy psd-tools django-pylibmc django-simple- captcha
Once all the packages are installed, enable the Memcached service to start at system reboot:
systemctl enable --now memcached
Step 3 – Install Nginx and MariaDB
Execute the following command on command line to install Nginx and MariaDB server on our system:
yum install nginx mariadb-server -y
Once installed, start the Nginx and MariaDB services and enable them to start at system reboot:
systemctl start nginx systemctl start mariadb systemctl enable nginx systemctl enable mariadb
Step 4 – Create a Database for Seafile
Execute the following command on the command line to set the MariaDB root password and secure the MariaDB installation:
mysql_secure_installation
Answer all the questions as shown below:
Enter current password for root (enter for none): Set root password? [Y/n] Y New password: Re-enter new password: Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
Next, log in to the MariaDB shell with the following command:
mysql -u root -p
Once logged in, create a database for Seafile with the following command:
create database `ccnetdb` character set = 'utf8'; create database `seafiledb` character set = 'utf8'; create database `seahubdb` character set = 'utf8';
Next, create a user for Seafile with the following command:
create user 'seafile'@'localhost' identified by 'yourpassword';
Next, grant all the privileges to the ccnetdb, seafiledb and seahubdb with the following command:
GRANT ALL PRIVILEGES ON `ccnetdb`.* to `seafile`@localhost; GRANT ALL PRIVILEGES ON `seafiledb`.* to `seafile`@localhost; GRANT ALL PRIVILEGES ON `seahubdb`.* to `seafile`@localhost;
Next, flush the privileges and exit from the MariaDB shell with the following command:
FLUSH PRIVILEGES; EXIT;
Step 5 – Install Seafile
Execute the following command on command line to download the latest version of Seafile:
wget https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_7.1.5_x86- 64.tar.gz
Once downloaded, extract the downloaded file with the following command:
tar -xvzf seafile-server_7.1.5_x86-64.tar.gz
Next, move the extracted directory to /opt with the following command:
mv seafile-server-* /opt/seafile cd /opt/seafile
Next, change the directory to /opt/seafile and set up the Seafile server by running the following script:
./setup-seafile-mysql.sh
You will be asked to provide the server name, valid domain name, and database details as shown below.
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 ----------------------------------------------------------------- What is the name of the server? It will be displayed on the client. 3 - 15 letters or digits [ server name ] seafile 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" ] ------------------------------------------------------- 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 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 ccnetdb ... done Enter the existing database name for seafile: [ seafile database ] seafiledb verifying user "seafile" access to database seafiledb ... done Enter the existing database name for seahub: [ seahub database ] seahubdb verifying user "seafile" access to database seahubdb ... done
Provide each detail carefully. Once the installation has been completed, you should see the following output:
--------------------------------- This is your configuration --------------------------------- server name: seafile server ip/domain: seafile.example.com seafile data dir: /opt/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 ----------------------------------------------------------------- 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.
Step 6 – Set Up Admin Account
Execute the following command on the command line to set up an admin account to access Seafile:
/opt/seafile/seafile.sh start
Next, start the Seahub service to set an admin password:
/opt/seafile/seahub.sh start
We will be asked to set an admin username and password as shown below.
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 ] [email protected] What is the password for the admin account? [ admin password ] Enter the password again: [ admin password again ] ---------------------------------------- Successfully created seafile admin ----------------------------------------
Next, stop the Seafile and Seahub services with the following command:
/opt/seafile/seafile.sh stop /opt/seafile/seahub.sh stop
Step 7 – Create a Systemd Service File for Seafile
Execute the following command on command line to create a service file for Seafile:
nano /etc/systemd/system/seafile.service
Then Add the following lines:
[Unit] Description=Seafile After= mysql.service After=network.target [Service] Type=forking ExecStart=/opt/seafile-server-latest/seafile.sh start ExecStop=/opt/seafile-server-latest/seafile.sh stop [Install] WantedBy=multi-user.target
Save and close the file, then create a service file for Seahub with the following command:
nano /etc/systemd/system/seahub.service
Add the following lines:
[Unit] Description=Seafile After= mysql.service After=network.target [Service] Type=forking ExecStart=/opt/seafile-server-latest/seahub.sh start ExecStop=/opt/seafile-server-latest/seahub.sh stop [Install] WantedBy=multi-user.target
Save and close the file, then reload the systemd daemon with the following command:
systemctl daemon-reload
Next, execute the following command on command line to start the Seafile and Seahub service and enable them to start at system reboot:
systemctl start seafile systemctl enable seafile systemctl start seahub systemctl enable seahub
Now, Seafile server is started and listening on port 8000. Also we can verify it with using the following command:
ss -tunelp | grep 8000
We will get the following output:
tcp LISTEN 0 128 127.0.0.1:8000 0.0.0.0:* users:(("python3",pid=44925,fd=8),("python3",pid=44924,fd=8),("pyt hon3",pid=44923,fd=8),("python3",pid=44922,fd=8),("python3",pid=44921,fd=8),("python3",pid=44916,fd=8)) ino:77620 sk:9 <->
Step 8 – Configure Nginx for Seafile
Next, we need to configure Nginx as a reverse proxy to access Seafile using port 80. And we can configure it with using the following command:
nano /etc/nginx/conf.d/seafile.conf
Add the following lines:
server { listen 80; listen [::]:80; server_name seafile.example.com; autoindex off; client_max_body_size 100M; access_log /var/log/nginx/seafile.com.access.log; error_log /var/log/nginx/seafile.com.error.log; 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; } location /seafhttp { rewrite ^/seafhttp(.*)$ $1 break; proxy_pass http://127.0.0.1:8082; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; proxy_send_timeout 36000s; send_timeout 36000s; } location /media { root /opt/seafile-server-latest/seahub; } }
Save and close the file, then restart the Nginx service with the following command:
systemctl restart nginx
If you got any errors, then edit the Nginx.conf file:
nano /etc/nginx/nginx.conf
Add the following line below http {:
server_names_hash_bucket_size 64;
Save and close the file, then restart the Nginx service:
systemctl restart nginx
Step 9 – Access Seafile Web Interface
Finally, Nginx is configured to serve Seafile. Now, open web browser and access the Seafile web interface using the URL http://seafile.example.com. And will be redirected to the Seafile login page:
Conclusion
Through this tutorial, we have learned how to install the Seafile server with Nginx as a reverse proxy on CentOS 8.