How to Install Seafile on Ubuntu 16.04

installing seafile on ubuntu 16.04SeaFile is an enterprise file hosting platform with high reliability and performance, there are Community Edition and Professional Edition. SeaFile Community Edition is an open source file storage system, it is an alternative to DropBox, we can synchronize the files between multiple computers or mobile devices using the Seafile client. In this tutorial, we will provide you with a step by step instruction on how to install SeaFile Community Edition on Ubuntu 16.04.

Prerequisites:

  • Ubuntu 16.04 with minimum 2GB of RAM
  • SSH access with root privileges

1. Log in to your server via SSH:

# ssh root@server_ip

Before starting with the SeaFile installation, it is encouraged to check that our system package database is up to date.

2. Update the system

# apt update
# apt upgrade

The installation requires a working LAMP, stack. If you don’t have a LAMP stack installed, you need to install it first

#apt install lamp-server^

3. Install dependencies

We need to install some dependencies prior to installing SeaFile Community Edition, run the following commands:

# apt install python2.7 libpython2.7 python-setuptools python-imaging python-ldap python-mysqldb python-memcache python-urllib3 python-pip

and run

# pip install boto

4. Install SeaFile

Let’s create a directory to store SeaFile core files.

# mkdir /opt/seafile
# cd /opt/seafile
# wget https://download.seadrive.org/seafile-server_6.3.4_x86-64.tar.gz
# tar -xzvf seafile-server_6.3.4_x86-64.tar.gz
# cd /opt/seafile/seafile-server-6.3.4

Let’s create a password for MySQL root user. If your MySQL root user already has a password, you can skip this step

# mysql_secure_installation

Now we have configured a password for MySQL root user, let’s proceed with the installation

# ./setup-seafile-mysql.sh

During the installation process, you will be asked for MySQL root password and a new password for Seafile database user.

root@rose:/opt/seafile/seafile-server-6.3.4# ./setup-seafile-mysql.sh
Checking python on this machine ...
  Checking python module: setuptools ... Done.
  Checking python module: python-imaging ... Done.
  Checking python module: python-mysqldb ... Done.

-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at

        https://github.com/haiwen/seafile/wiki

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 ] 192.168.0.19

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/opt/seafile/seafile-data" ]

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 ] 1

What is the host of mysql server?
[ default "localhost" ]

What is the port of mysql server?
[ default "3306" ]

What is the password of the mysql root user?
[ root password ]

verifying password of user root ...
verifying password of user root ...  done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ]

Enter the password for mysql user "seafile":
[ password for seafile ]

Enter the database name for ccnet-server:
[ default "ccnet-db" ]

Enter the database name for seafile-server:
[ default "seafile-db" ]

Enter the database name for seahub:
[ default "seahub-db" ]

---------------------------------
This is your configuration
---------------------------------

    server name:            seafile
    server ip/domain:       192.168.0.19

    seafile data dir:       /opt/seafile/seafile-data
    fileserver port:        8082

    database:               create new
    ccnet database:         ccnet-db
    seafile database:       seafile-db
    seahub database:        seahub-db
    database user:          seafile



---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------

Generating ccnet configuration ...

done
Successly create configuration dir /opt/seafile/ccnet.
Generating seafile configuration ...

Done.
done
Generating seahub configuration ...

----------------------------------------
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://github.com/haiwen/seafile/wiki

for information.

Once completed, you can start SeaFile and SeaHub:

# ./seafile.sh start
# ./seahub.sh start

When starting seahub for the first time, you will be asked for your email address and a password to create a new SeaFile admin

root@rose:/opt/seafile/seafile-server-6.3.4# ./seahub.sh start
LANG is not set in ENV, set to en_US.UTF-8
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
----------------------------------------

Seahub is started

Done.

Now, you can access your new SeaFile installation at http://YOUR_IP_ADDRESS:8000 or http://yourdomainname.com:8000

install seafile ubuntu 16.04

5. Configure Apache

To access it without typing the port in the web browser, we need to create an apache virtual host and configure it as a reverse proxy. Apache module proxy_http is not enabled by default, and we need to enable it to run Apache as a reverse proxy.

# a2enmod proxy_http
# nano /etc/apache2/sites-available/yourdomain.com.conf

Add the following lines to the file

 <VirtualHost *:80>
    ServerName yourdomain.com
    DocumentRoot /opt
    Alias /media  /opt/seafile/seahub/media
    RewriteEngine On
    <Location /media>
        Require all granted
    </Location>
    	
    ProxyPass /seafhttp http://127.0.0.1:8082
    ProxyPassReverse /seafhttp http://127.0.0.1:8082
    RewriteRule ^/seafhttp - [QSA,L]
    
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    ProxyPass / http://127.0.0.1:8000/
    ProxyPassReverse / http://127.0.0.1:8000/
</VirtualHost>

Restart apache to apply the configuration changes

# systemctl restart apache2

Now, you can access your SeaFile installation at http://yourdomain.com

6. Create SystemD file

In the previous step, we ran seafile and seahub using the provided bash script. Let’s create systemd files to make it easier to manage the application.

# nano /etc/systemd/system/seafile.service
[Unit]
Description=Seafile hub
After=network.target seafile.service

[Service]
Type=forking
# change start to start-fastcgi if you want to run fastcgi
ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start
ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
User=www-data
Group=www-data

[Install]
WantedBy=multi-user.target
# nano /etc/systemd/system/seahub.service

We also need to change the permissions:

# chown -R www-data: /opt/seafile /tmp/seahub_cache
systemctl daemon-reload
systemctl restart seafile
systemctl restart seahub
systemctl enable seafile
systemctl enable seahub

If you want to access your SeaFile installation securely, you can install a free certificate from LetsEncrypt. Follow the steps below to enable HTTPS on your website.

apt-get install software-properties-common python-software-properties
add-apt-repository ppa:certbot/certbot
apt update
apt-get install python-certbot-apache
certbot

In the last command, you will be asked for your email address and the domain name you want to install a certificate to, and whether you want to redirect HTTP to HTTPS or not. Once finished, you can access your SeaFile installation at https://yourdomain.com

That is it, SeaFile has been successfully installed on your Ubuntu 16.04 server.


install seafile on ubuntu 16.04Of course, you don’t have to Install Seafile on Ubuntu 16.04, if you use one of our Optimized Ubuntu Hosting plans, in which case you can simply ask our expert Linux admins to install Seafile on Ubuntu 16.04 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on How to Install Seafile on Ubuntu 16.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment