Deploy Seafile with Apache

With Apache 2.4

Preparation

Load Modules

Edit httpd.conf

First edit your httpd.conf. Add the following lines to the end of the file:

  1. LoadModule proxy_module modules/mod_proxy.so
  2. LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
  3. LoadModule proxy_http_module modules/mod_proxy_http.so
  4. LoadModule rewrite_module modules/mod_rewrite.so
  5. Include conf/extra/httpd-vhosts.conf

And please ensure this line does NOT exist:

  1. DocumentRoot "${SRVROOT}/htdocs"

Deploy Seahub/FileServer With Apache 2.4

Seahub is the web interface of Seafile server. FileServer is used to handle raw file uploading/downloading through browsers. By default, it listens on port 8082 for HTTP request.

Here we deploy Seahub using fastcgi, and deploy FileServer with reverse proxy. We assume you are running Seahub using domain ‘’’www.myseafile.com’’’.

Edit your httpd-vhosts.conf

Modify Apache config file: (conf/extra/httpd-vhosts.conf)

Assume you have uncompresssed seafile server into C:/seafile.

If you need to use the IP address to access the seafile service directly.Please unconfigure the <VirtualHost _default_:80> section.

Then add the following lines:

  1. <VirtualHost *:80>
  2. ServerName www.myseafile.com
  3. DocumentRoot "${SRVROOT}/htdocs"
  4. Alias /media "C:/seafile/seafile-server-6.0.7/seahub/media"
  5. RewriteEngine On
  6. <Location /media>
  7. Require all granted
  8. </Location>
  9. #
  10. # seafile fileserver
  11. #
  12. ProxyPass /seafhttp http://127.0.0.1:8082
  13. ProxyPassReverse /seafhttp http://127.0.0.1:8082
  14. RewriteRule ^/seafhttp - [QSA,L]
  15. #
  16. # seahub
  17. #
  18. SetEnvIf Request_URI . proxy-fcgi-pathinfo=unescape
  19. SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
  20. ProxyPass / fcgi://127.0.0.1:8000/
  21. </VirtualHost>

Modify seafile/seafile.conf

Modify the seahub section of seafile/seafile.conf:

  1. [seahub]
  2. port = 8000
  3. fastcgi = true

Modify ccnet.conf and seahub_setting.py

Modify ccnet.conf

You need to modify the value of SERVICE_URL in ccnet.conf
to let Seafile know the domain you choose. You can also modify SERVICE_URL via web UI in “System Admin->Settings”. (Warning: if you set the value both via Web UI and ccnet.conf, the setting via Web UI will take precedence.)

  1. SERVICE_URL = http://www.myseafile.com

Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL.

Modify seahub_settings.py

You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT. You can also modify FILE_SERVER_ROOT via web UI in “System Admin->Settings”. (Warning: if you set the value both via Web UI and seahub_settings.py, the setting via Web UI will take precedence.)

  1. FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'

Please restart Seafile Server and httpd.

With Apache 2.2

Preparation

Install mod_fastcgi

Download [mod_fastcgi-*.dll] (http://fastcgi.com/dist/) first, and put it into the modules/ directory of your Apache installation.

Note: You must download the right version of mod_fastcgi DLL according for your Apache. For example:

Deploy Seahub/FileServer With Apache

Seahub is the web interface of Seafile server. FileServer is used to handle raw file uploading/downloading through browsers. By default, it listens on port 8082 for HTTP request.

Here we deploy Seahub using fastcgi, and deploy FileServer with reverse proxy. We assume you are running Seahub using domain ‘’’www.myseafile.com’’’.

Edit httpd.conf

First edit your httpd.conf. Add the following lines to the end of the file:

  1. LoadModule fastcgi_module modules/mod_fastcgi-2.4.6-AP22.dll
  2. LoadModule rewrite_module modules/mod_rewrite.so
  3. LoadModule proxy_module modules/mod_proxy.so
  4. LoadModule proxy_http_module modules/mod_proxy_http.so
  5. Include conf/extra/httpd-vhosts.conf

Then add this line (substitute YourDocumentRoot with the value of your apache DocumentRoot)

  1. FastCGIExternalServer "YourDocumentRoot/seahub.fcgi" -host 127.0.0.1:8000

Note, seahub.fcgi is just a placeholder, you don’t need to actually have this file in your system.

Edit your httpd-vhosts.conf

Assume you have uncompresssed seafile server into C:/SeafileProgram/seafile-pro-server-2.1.4.

  1. <VirtualHost *:80>
  2. ServerName www.myseafile.com
  3. Alias /media "C:/SeafileProgram/seafile-pro-server-2.1.4/seahub/media"
  4. RewriteEngine On
  5. #
  6. # seafile fileserver
  7. #
  8. ProxyPass /seafhttp http://127.0.0.1:8082
  9. ProxyPassReverse /seafhttp http://127.0.0.1:8082
  10. RewriteRule ^/seafhttp - [QSA,L]
  11. #
  12. # seahub
  13. #
  14. RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
  15. RewriteCond %{REQUEST_FILENAME} !-f
  16. RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  17. </VirtualHost>
  18. <Directory "C:/SeafileProgram/seafile-pro-server-2.1.4/seahub/media">
  19. Options Indexes FollowSymLinks
  20. AllowOverride None
  21. Order allow,deny
  22. Allow from all
  23. </Directory>

Modify Configurations

Modify ccnet.conf

You can also modify SERVICE_URL via web UI in “System Admin->Settings”. (Warning: if you set the value both via Web UI and ccnet.conf, the setting via Web UI will take precedence.)

  1. SERVICE_URL = http://www.myseafile.com

Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL.

Modify seafile-data/seafile.conf

Modify the seahub section of seafile-data/seafile.conf:

  1. [seahub]
  2. port=8000
  3. fastcgi=true

Modify seahub_settings.py

You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT. You can also modify FILE_SERVER_ROOT via web UI in “System Admin->Settings”. (Warning: if you set the value both via Web UI and seahub_settings.py, the setting via Web UI will take precedence.)

  1. FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'

Notes when Upgrading Seafile Server

When upgrading seafile server, besides the normal steps you should take, there is one extra step to do: ‘’’Update the path of the static files in your apache configuration’’’. For example, assume your are upgrading seafile server 2.1.4 to 2.1.5, then:

  1. <VirtualHost *:80>
  2. ...
  3. Alias /media "C:/SeafileProgram/seafile-pro-server-2.1.5/seahub/media"
  4. ...
  5. </VirtualHost>
  6. <Directory "C:/SeafileProgram/seafile-pro-server-2.1.5/seahub/media">
  7. ...
  8. </Directory>