网上有教程,但是都有或多或少的瑕疵。这里总结一份。
我这里是先安装的oneinstack。

我用的是root用户,当前目录/root/

mkdir /opt/seafile
wget https://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_7.1.5_x86-64.tar.gz
mv seafile-server_* /opt/seafile
cd /opt/seafile

将 seafile-server_* 移动到 seafile 目录下后

tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed
apt install tree
tree ../seafile -L 2

我用的是Debian 10

apt-get update
apt-get install python3 python3-setuptools python3-pip python3-ldap -y
pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools
pip3 install django-pylibmc django-simple-captcha

cd seafile-server-*
./setup-seafile-mysql.sh  #运行安装脚本并回答预设问题
#nginx配置文件
  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;
     # used for view/edit office file via Office Online Server
     client_max_body_size 0;
  }
  location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass http://127.0.0.1:8082;
    client_max_body_size 0;
    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;
    proxy_request_buffering off;
  }

  location /media {
    root /opt/seafile/seafile-server-latest/seahub;
  }

下面这部分要注释掉

  #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
  #  expires 30d;
  #  access_log off;
  #}
  #location ~ .*\.(js|css)?$ {
  #  expires 7d;
  #  access_log off;
  #}
  #location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) {
  #  deny all;
  #}

添加用户和组

groupadd seafile
useradd -d /opt/seafile/ -g seafile -s /bin/false seafile

更改权限

chown -R seafile:seafile /opt/seafile/*
chown -R seafile:seafile /tmp/seahub_cache/

编辑开机启动服务

vim /etc/systemd/system/seahub.service

内容:

[Unit]
Description=Seafile hub
After=network.target seafile.service

[Service]
# 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=seafile
Group=seafile
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

然后:

vim /etc/systemd/system/seafile.service

内容:

[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target

[Service]
Type=oneshot
ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop
RemainAfterExit=yes
User=seafile
Group=seafile

[Install]
WantedBy=multi-user.target

这就完成了。

标签: none

添加新评论