本文档主要用来说明如何使用预编译安装包来部署 Seafile 服务器 参考seafile官方的文档,但是官方文档太过简略,可操作性也不是很强 所以写这个文档,供大家参考
seafile服务器端建议使用 MySQL 数据库,并将 Seafile 部署在 Nginx 或者 Apache 上,如果对于 Nginx 和 Apache 都不是很熟悉的话,我们建议使用 Nginx,相对于 Apache 来说,Nginx 使用起来比较简单
本教程的服务器采用虚拟主机,系统为centos7.6,搭配Mariadb数据库和Nginx配置反向代理
一、环境准备
1、 安装Nginx
yum install nginx -y
#如果提示安装包未找到,先安装下linux的扩展源
yum install epel-release -y
#然后再运行上面的安装代码就可以
#安装完成后,启动nginx,并设置开机启动
systemctl start nginx
systemctl enable nginx
2、安装Mariadb(Mysql)
yum install mariadb-server -y
#安装完成后启动数据库并设置开机启动
systemctl start mariadb.service
systemctl enable mariadb.service
#开始mariadb的初始化
mysql_secure_installation
#初始化选项设置
Enter current password for root (enter for none): #初次运行直接回车
Set root password? [Y/n] #是否设置root用户密码,输入y并回车或直接回车
New password: #设置root用户的密码
Re-enter new password: #再输入一次你设置的密码
Remove anonymous users? [Y/n] #是否删除匿名用户,生产环境建议删除,所以直接y
Disallow root login remotely? [Y/n] #是否禁止root远程登录,根据自己的需求选择Y/n,这里选择允许
Remove test database and access to it? [Y/n] #是否删除test数据库,直接y
Reload privilege tables now? [Y/n] #是否重新加载权限表,直接y
3、安装其他依赖组件
yum install python3 python3-setuptools python3-pip python3-ldap python3-devel gcc gcc-c++ -y
#配置国内加速源
在家目录下面创建文件
cd
mkdir .pip
cd .pip/
vim pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
#配置完成继续执行
pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy==1.3.8 psd-tools django-pylibmc django-simple-captcha
二、安装seafile
服务器端
1、下载seafile安装文件
https://www.seafile.com/download/
#部署和目录设计
#假设你已经下载 seafile-server_* 到/opt/seafile目录下
mkdir /opt/seafile
mv seafile-server_* /opt/seafile
cd /opt/seafile
#将 seafile-server_* 移动到 seafile 目录下后
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed
#这样设计目录的好处在于
和 seafile 相关的配置文件都可以放在 /opt/seafile/conf 目录下,便于集中管理.
后续升级时,你只需要解压最新的安装包到 /opt/seafile 目录下
2、安装seafile
#进入到解压后的目录
cd seafile-server-7.1.5/
#运行安装脚本
./setup-seafile-mysql.sh #运行安装脚本并回答预设问题
在这里, 你会被要求选择一种创建 Seafile 数据库的方式:
-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases
如果选择1, 你需要提供根密码. 脚本程序会创建数据库和用户。
如果选择2, ccnet/seafile/seahub 数据库应该已经被你(或者其他人)提前创建。我们没有创建过,所以选1。
What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] # 随便写 不支持中文
What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server’s ip or domain ] #填写域名或者主机地址,根据自己的实际情况填写
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” ] #端口默认
在这里, 你会被要求选择一种创建 Seafile 数据库的方式:
-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases
如果选择1, 你需要提供根密码. 脚本程序会创建数据库和用户。
如果选择2, ccnet/seafile/seahub 数据库应该已经被你(或者其他人)提前创建。我们没有创建过,所以选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 ] # 输入数据库初始化设置的数据库登录密码
输入正确后会有提示。
Enter the name for mysql user of seafile. It would be created if not exists.
[ default “seafile” ] #设置默认的seafile数据库名称 默认即可
Enter the password for mysql user “seafile”:
[ password for seafile ] #设置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” ] # 默认
#然后一直回车到结束完成安装
三、seafile
配置
1、启动seafile服务
#切换到seafile的文件目录
cd /opt/seafile/seafile-server-latest
#启动 Seafile服务
./seafile.sh start # 启动 Seafile 服务
#启动seafile网站服务
./seahub.sh start # 启动 Seahub 网站
#启动成功,第一次会提示设置管理员账户相关信息
What is the email for the admin account?
[ admin email ] #设置管理员账户邮箱
What is the password for the admin account?
[ admin password ] # 设置管理员密码
2、配置```nginx```反向代理
#7.0.x 版本之后,8000端口默认监听在127.0.0.1地址上,这意味着您无法直接通过8000端口访问Seafile服务 所以需要配置nginx反向代理
#打开nginx的配置文件目录
cd /etc/nginx/
#修改配置文件之前,先将配置文件备份一下
cp nginx.conf nginx.conf.bak
#nginx的配置文件 直接覆盖就可以
vim nginx.conf
#user www wwww;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#error_log /data/logs/nginx/error.log crit;
#pid /usr/local/webserver/nginx/nginx.pid;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
client_max_body_size 0;
send_timeout 180;
#gzip on;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_connect_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
proxy_connect_timeout 18000;
proxy_send_timeout 18000;
proxy_read_timeout 18000;
server {
listen 80;
server_name localhost;
proxy_set_header X-Forwarded-For $remote_addr;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
**#seahub端口,根据实际情况设置,默认是8000**
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;
***#seafile的端口,根据实际情况设置,默认是8082***
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 {
**#静态文件路径,根据实际安装路径找到/seafile-server-latest/seahub的位置**
root /opt/seafile/seafile-server-7.0.5/seahub;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
#修改完成后,检查配置文件是否正确
nginx -t
#重启nginx服务
systemctl restart nginx
网友评论