Community

Blog
×
Community Blog How to Install and Configure Seafile on Ubuntu 16.04

How to Install and Configure Seafile on Ubuntu 16.04

In this tutorial, we will be learning how to install and configure Seafile on an Alibaba Cloud ECS with Ubuntu 16.04.

By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Seafile is a free, open source and cross-platform file storage system similar to Dropbox. It is used for sharing and syncing files between users and groups. It can be easily integrated with LDAP and WebDAV. It supports file versioning, snapshots and two-factor authentication. You can deploy it with MySQL, MariaDB, PostgreSQL, Apache and Nginx web server. Files are stored on Seafile server and can be synchronized with personal computers and mobile devices through apps. You can also access and manage Seafile through a web browser.

Features:

  1. Multi-platform file synchronization.
  2. You can create a public link for downloading and uploading files.
  3. Supports LDAP, Active Directory authentication and Version control.
  4. File locking, Text searching and Activity logging.
  5. Provide access control and Client-side encryption.
  6. Desktop clients are available for personal computers running on Windows, MacOS, and Linux. Mobile clients are available for iOS, Windows Phone 8 and Android.

In this tutorial, we will install and configure a Seafile server on Ubuntu 16.04 with an Alibaba Cloud Elastic Compute Service (ECS) instance.

Requirements

  1. A fresh Alibaba cloud Ubuntu 16.04 instance with minimum 2GB RAM.
  2. A valid domain name is setup to your instance.
  3. A Root password is setup on the server.

Launch Alibaba Cloud ECS Instance

First, log in to your https://ecs.console.aliyun.com">Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

apt-get update -y

Install Required Dependencies

Before starting, you will need to install some dependencies in order to install Seafile. You can install all the dependencies by running the following command:

apt-get install apache2 openjdk-8-jre poppler-utils libreoffice libreoffice-script-provider-python libpython2.7 python-pip xfonts-wqy python-imaging python-mysqldb python-setuptools python-memcache ttf-wqy-microhei ttf-wqy-zenhei -y

Next, you will also need to install boto using pip:

pip install boto

Install and Configure Database

First, you will need to install MariaDB server to your system. You can install it by just running the following command:

apt-get install mariadb-server -y

Once the MariaDB is installed, start MariaDB service and enable it to start on boot time with the following command:

systemctl start mysql
systemctl enable mysql

By default, MariaDB is not secured, so you will need to secure it first. You can secure it by running the mysql_secure_installation script:

mysql_secure_installation

Answer all the questions as shown below:

Change the password for root ? N
Remove anonymous users? Y
Disallow root login remotely? Y
Remove test database and access to it? Y
Reload privilege tables now? Y

Once the MariaDB is secured, login to MariaDB shell using the following command:

mysql -u root -p

Enter your root password, then create a database for ccnet, seafile and seahub:

MariaDB [(none)]> create database ccnetdb character set = 'utf8';
MariaDB [(none)]> create database seafiledb character set = 'utf8';
MariaDB [(none)]> create database seahubdb character set = 'utf8';

Next, create a user for these databases using the following command:

MariaDB [(none)]> create user seacloud@localhost identified by 'password';

Next, grant all privileges to the seacloud user on all databases using the following command:

MariaDB [(none)]> grant all privileges on ccnetdb.* to seacloud@localhost identified by 'password';
MariaDB [(none)]> grant all privileges on seafiledb.* to seacloud@localhost identified by 'password';
MariaDB [(none)]> grant all privileges on seahubdb.* to seacloud@localhost identified by 'password';

Next flush the privileges and exit from the shell:

MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

Install Seafile

First, you will need to download the latest version of Seafile from their official website. You can download it with the following command:

wget https://download.seadrive.org/seafile-server_6.3.1_x86-64.tar.gz

Once the download is completed, extract the downloaded file with the following command:

tar -xvzf seafile-server_6.3.1_x86-64.tar.gz

Next, move the extracted directory to the Apache web root directory:

mv seafile-server_6.3.1 /var/www/html/seafile

Next, give proper permissions to the seafile directory:

chown -R www-data:www-data /var/www/html/seafile
chmod -R 777 /var/www/html/seafile

Next, change the directory to seafile and install seafile by running setup-seafile-mysql.sh script:

cd /var/www/html/seafile
./setup-seafile-mysql.sh

During installation, you will need to provide some details like, your domain name, database name, password etc. Provide all the details as follows:

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

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] example.com

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/var/www/html/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 ] 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 ] seacloud

What is the password for mysql user "seacloud"?
[ password for seacloud ] 

verifying password of user seacloud ...  done

Enter the existing database name for ccnet:
[ ccnet database ] ccnetdb

verifying user "seacloud" access to database ccnetdb ...  done

Enter the existing database name for seafile:
[ seafile database ] seafiledb

verifying user "seacloud" access to database seafiledb ...  done

Enter the existing database name for seahub:
[ seahub database ] seahubdb

verifying user "seacloud" access to database seahubdb ...  done

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

    server name:            SeafileCloud
    server ip/domain:       example.com

    seafile data dir:       /var/www/html/seafile-data
    fileserver port:        8082

    database:               use existing
    ccnet database:         ccnetdb
    seafile database:       seafiledb
    seahub database:        seahubdb
    database user:          seacloud



---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------
Generating ccnet configuration ...

done
Successly create configuration dir /var/www/html/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 <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://github.com/haiwen/seafile/wiki

for information.

Once the installation is completed successfully, start seafile and the seahub server using the following command:

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

You will need to provide email and password for admin account:

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 ] admin@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.

Configure Apache for Seafile

Next, you will need to configure Apache as a reverse proxy server for seafile-server on port 8000 and 8002. You can do this by creating seafile.conf file:

nano /etc/apache2/sites-enabled/seafile.conf

Add the following lines:

<VirtualHost *:80>
    ServerName www.example.com
    DocumentRoot /var/www/html
    Alias /media  /var/www/html/seafile/seahub/media

    RewriteEngine On

    <Location /media>
        Require all granted
    </Location>

    #
    # seafile fileserver
    #
    ProxyPass /seafhttp http://127.0.0.1:8082
    ProxyPassReverse /seafhttp http://127.0.0.1:8082
    RewriteRule ^/seafhttp - [QSA,L]

    #
    # seahub
    #
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    ProxyPass / http://127.0.0.1:8000/
    ProxyPassReverse / http://127.0.0.1:8000/
</VirtualHost>

Save and close the file, then enable seafile virtual host, rewrite module and proxy module with the following command:

a2ensite seafile
a2enmod rewrite
a2enmod proxy_http

Finally, restart apache service to apply all the changes:

systemctl restart apache2

Seafile server is now installed and listening on port 80. Open your web browser and type the URL http://example.com. You will be redirected to the following page:

1

Now, provide your admin email and password, then click on the Login button. You should see the Seafile dashboard in the following image:

2

Secure Seafile with Certbot Certificate

Seafile is now installed and configured. If you want to enable https on Seafile server, then you will need to obtain a certificate from the Certificate Authority (CA).

Here, we will use Let's Encrypt to obtain a certificate using via Certbot. So you will need to add the Certbot PPA to your server.

You can add the PPA by running the following command:

add-apt-repository ppa:certbot/certbot
apt-get update -y

Next, install Certbot using the following command:

apt-get install python-certbot-apache -y

Next, create a directory to store certificates:

mkdir /etc/certs

Change the directory to the /etc/certs and download Certbot certificate using the following command:

cd /etc/certs
certbot --apache certonly

Next, enable ssl module with the following command:

a2enmod ssl

Next, open Apache configuration file for Seafile and make the following changes:

nano /etc/apache2/sites-enabled/seafile.conf

Make the following changes:

<VirtualHost *:443>
  ServerName www.example.com
  DocumentRoot /var/www/html

  SSLEngine On
  SSLCertificateFile /etc/certs/cacert.pem
  SSLCertificateKeyFile /etc/certs/privkey.pem

  Alias /media  /var/www/html/seafile-server-latest/seahub/media

  <Location /media>
    Require all granted
  </Location>

  RewriteEngine On

  #
  # seafile fileserver
  #
  ProxyPass /seafhttp http://127.0.0.1:8082
  ProxyPassReverse /seafhttp http://127.0.0.1:8082
  RewriteRule ^/seafhttp - [QSA,L]

  #
  # seahub
  #
  SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
  ProxyPass / http://127.0.0.1:8000/
  ProxyPassReverse / http://127.0.0.1:8000/
</VirtualHost>

Save and close the file, then restart Apache service to apply all the changes:

systemctl restart apache2

Now, you can access Seafile server using the URL https://example.com

Create Service file for Seafile and Seahub

Next, you will need to create seafile and seahub services file to start and stop seafile server.

First, stop seafile and seahub service using the following command:

/var/www/html/seafile/seafile.sh stop
/var/www/html/seafile/seahub.sh stop

Next, create a seafile service file with the following command:

nano /lib/systemd/system/seafile.service

Add the following lines:

[Unit]
Description=Seafile Server
After=network.target mariadb.service

[Service]
Type=oneshot
ExecStart=/var/www/html/seafile/seafile.sh start
ExecStop=/var/www/html/seafile/seafile.sh stop
RemainAfterExit=yes
User=www-data
Group=www-data

[Install]
WantedBy=multi-user.target

Save and close the file, then create a seahub service file:

nano /lib/systemd/system/seahub.service

Add the following lines:

[Unit]
Description=Seafile Hub
After=network.target seafile.target

[Service]
Type=oneshot
ExecStart=/var/www/html/seafile/seahub.sh start
ExecStop=/var/www/html/seafile/seahub.sh stop
RemainAfterExit=yes
User=www-data
Group=www-data

[Install]
WantedBy=multi-user.target

Save the file once you are done.

Next, reload the systemd service and start seafile and seahub with the following command:

systemctl daemon-reload
systemctl start seafile
systemctl start seahub

Finally, enable seafile and seahub service on boot time:

systemctl enable seafile
systemctl enable seahub

Install Seafile Client

Seafile server is now up and running. It's time to install Seafile client on Ubuntu 16.04 desktop system.

By default, Seafile client is not available in the Ubuntu 16.04 default repository. So you will need to add the repository for Seafile.

You can do this by running the following command:

add-apt-repository ppa:seafile/seafile-client

Next, update the repository and install Seafile client using the following command:

apt-get update
apt-get install seafile-gui -y

Next, open Seafile client from Unity Dash as shown below:

3

Now, choose the folder where you want to store Seafile, then click on the Next button. You should see the following page:

4

Here, provide your Seafile server name, username and password, then click on the Login button. You should see the following page:

5

Congratulations! You have successfully installed and configured Seafile server and client. You can now access all your files through a web browser and Seafile client. Seafile client maps storage space in Seafile server as a virtual drive of your local storage. You can access all the files in the Seafile without syncing them.

6

Related Alibaba Cloud Products

ActionTrail documents daily operations to provide an operational history of your Alibaba Cloud account and saves this information to a specified OSS bucket. From the information collected by ActionTrail, you can conveniently perform security analysis, resource tracking, and compliance audits.

Content Moderation leverages Deep Learning technology and benefits from Alibaba's years of Big Data analysis to provide accurate monitoring of pictures, video, text and other multimedia content. Not only does Content Moderation help users to reduce adult, violence, terrorism, drugs and other illegal or inappropriate content, but can also minimize spam advertising and other user experience pain points.

0 0 0
Share on

Alibaba Clouder

760 posts | 113 followers

You may also like

Comments