平台: Ubuntu 18.04/ 20.04
配置数据库
进入mysql
sudo mysql –defaults-file=/etc/mysql/debian.cnf
新建数据库
create database `ccnet_db` character set = 'utf8';
create database `seafile_db` character set = 'utf8';
create database `seahub_db` character set = 'utf8';
新建用户
CREATE USER 'seafile'@'localhost' IDENTIFIED BY '[YOUR PASSWORD]';
给予权限
# mysql 8.0以下
GRANT ALL PRIVILEGES ON `ccnet_db`.* to `seafile`@localhost;
GRANT ALL PRIVILEGES ON `seafile_db`.* to `seafile`@localhost;
GRANT ALL PRIVILEGES ON `seahub_db`.* to `seafile`@localhost;
# mysql 8.0
GRANT ALL ON `ccnet_db`.* to `seafile`@localhost;
GRANT ALL ON `seafile_db`.* to `seafile`@localhost;
GRANT ALL ON `seahub_db`.* to `seafile`@localhost;
flush privileges;
exit;
配置环境
# Ubuntu 18.04
sudo apt-get update
sudo apt-get install python3 python3-setuptools python3-pip -y
sudo pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy==1.4.3 \
django-pylibmc django-simple-captcha python3-ldap
# Ubuntu 20.04
sudo apt-get update
sudo apt-get install python3 python3-setuptools python3-pip libmysqlclient-dev memcached libmemcached-dev -y
sudo pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy==1.4.3 \
django-pylibmc django-simple-captcha python3-ldap mysqlclient
设置web proxy
# caddy
example.com {
handle {
reverse_proxy http://127.0.0.1:8000
}
handle_path /seafhttp* {
reverse_proxy http://127.0.0.1:8082
}
handle_path /seafmedia* {
rewrite * /media{uri}
root * /opt/seafile/seafile-server-latest/seahub
file_server
}
handle /seafdav* {
reverse_proxy http://127.0.0.1:8080
}
log {
output file /var/log/caddy/seafile.access.log
}
}
# nginx
server {
listen 80;
server_name seafile.example.com;
proxy_set_header X-Forwarded-For $remote_addr;
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;
access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
}
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
}
}
进行安装
创建程序目录
mkdir /opt/seafile
cd /opt/seafile
创建新用户
sudo adduser seafile
sudo chown -R seafile: /opt/seafile
su seafile
下载并解压程序
# 下载链接: https://www.seafile.com/en/download/
tar xf seafile-server*
cd seafile-server-*
配置程序
./setup-seafile-mysql.sh
启动程序
./seafile.sh start
./seahub.sh start
如果在启动 seahub 时报错: Error happened during creating seafile admin
在mysql使用root输入以下命令
ALTER USER 'seafile'@'localhost' IDENTIFIED WITH mysql_native_password BY '[YOUR PASSWORD]';
然后访问网页, 配置URL: 登录后点击右上角 -> 系统管理 -> 设置
根据提示更改 SERVICE_URL 和 FILE_SERVER_ROOT