Seafile完整部署文档
Seafile部署文档
系统:centos7.6
要求:使用nginx反向代理+https
1关闭防火墙、Selinux
2. 安装Seafile依赖项
2.1 在CentOS服务器上安装EPEL存储库
# yum -y install epel-release
2.2 安装python包,MariaDB和Nginx
# yum -y install python-imaging MySQL-python python-simplejson python-setuptools mariadb mariadb-server nginx
3. 配置MariaDB启动
3.1 MariaDB并使用以下命令配置root密码:
# systemctl start mariadb
# mysql_secure_installation
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
3.2 为seafile创建3个数据库:ccnet_db、seafile_db、seahub_db并创建一个新用户seacloud (非必做)
!!!下面是自己创建seafile在数据库里的用户和数据库,直接运行第4步./setup-seafile-mysql.sh, 可以跳过此步
使用您自己的密码替换下述命令中的yourpasswd
# mysql -u root -p
your password
>create database ccnet_db character set = 'utf8';
>create database seafile_db character set = 'utf8';
>create database seahub_db character set = 'utf8';
>create user seacloud@localhost identified by 'yourpassword';
>grant all privileges on ccnet_db.* to seacloud@localhost identified by 'yourpassword';
>grant all privileges on seafile_db.* to seacloud@localhost identified by 'yourpassword';
>grant all privileges on seahub_db.* to seacloud@localhost identified by 'yourpassword';
>flush privileges;
>exit
4. 在/ var / www / seafile目录下安装seafile
4.1 创建安装目录
# mkdir -p /var/www/seafile
# cd /var/www/seafile
4.2 下载seafile
# https://download.seadrive.org/seafile-server_6.3.4_x86-64.tar.gz
# tar -xzvf seafile-server_6.3.4_x86-64.tar.gz
4.3 将目录重命名为seafile-server并切换到该目录
# mv seafile-server-6.3.4 seafile-server
# cd seafile-server/
4.4 执行setup-seafile-mysql.sh文件来配置数据库
# ./setup-seafile-mysql.sh
按Enter键,系统将要求您提供以下信息:
服务器名称 - 我将使用服务器主机名' seafile'
服务器的IP或域 - 服务器的IP地址,在我的情况下为' 172.16.50.45 '
默认数据dirctory - 只需按Enter键
默认端口 - 按Enter键
现在,对于数据库配置,请选择数字2,对于MySQL配置:
使用deafult主机 - localhost
默认端口 - 3306
mysql用户 - ' seacloud '
密码是' yourpassword '
ccnet数据库是' ccnet_db '
seafile数据库是' seafile_db '
seahub数据库是' seahub_db '
按Enter键,脚本将为seafile创建数据库表。
4.5 启动seafile和seahub服务并配置seahub服务
# ./seafile.sh start
# ./seahub.sh start
执行seahub.sh文件时,系统会要求我们进行管理配置。
输入您的管理员电子邮件和密码,然后seahub服务将运行。
Seafile现已安装并运行,我们可以通过端口8000上的服务器IP(在我的情况下为172.16.50.45:8000)从Web浏览器访问Seafile,但我们现在不会这样做因为我们将使用反向代理seafile服务器,我们将使用systemd服务文件运行seafile。
所以我们现在需要停止seafile和seahub服务。
# ./seafile.sh stop
# ./seahub.sh stop
5. 配置Seafile和Seahub服务
5.1 转到systemd目录并使用vim创建seafile.service文件
# cd /etc/systemd/system/
# vim seafile.service
[Unit]
Description=Seafile Server
After=network.target mariadb.service
[Service]
Type=oneshot
ExecStart=/var/www/seafile/seafile-server/seafile.sh start
ExecStart=/var/www/seafile/seafile-server/seahub.sh start
ExecStop=/var/www/seafile/seafile-server/seafile.sh stop
ExecStop=/var/www/seafile/seafile-server/seahub.sh stop
RemainAfterExit=yes
User=root
Group=root
[Install]
WantedBy=multi-user.target
5.3 重启加载systemd服务并使用systemctl启动seafile和seahub
# systemctl daemon-reload
# systemctl start seafile
6. 生成SSL证书文件
6.1 创建ssl目录。
# mkdir -p /etc/nginx/ssl
# cd /etc/nginx/ssl
6.2 生成自签名证书文件和dhparam文件,按照OpenSSL的要求回答证书详细信息,例如您的姓名,状态,电子邮件,域名等。然后更改目录和证书文件的权限。
# openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
# openssl req -new -x509 -sha256 -days 365 -newkey rsa:2048 -nodes -keyout server.key -out server.crt
# chmod -R 700 /etc/nginx/ssl
# chmod 400 server.*
# chmod 400 dhparam.pem
7. 将Nginx配置为反向代理
7.1 转到nginx配置目录并为seafile创建新的虚拟主机文件。
# cd /etc/nginx/
# vim conf.d/seafile.conf
server {
listen 80;
server_name 172.16.50.45 seafile.cloud; #主机名
rewrite ^ https://$http_host$request_uri? permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/seafile.cloud.crt; #cacert.pem 文件路径
ssl_certificate_key /etc/nginx/ssl/seafile.cloud.key; #privkey.pem 文件路径
server_name seafile.cloud;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES12
8-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-R
SA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:HIGH:!aN
ULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS';
ssl_prefer_server_ciphers on;
proxy_set_header X-Forwarded-For $remote_addr;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
server_tokens off;
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_set_header X-Forwarded-Proto https;
access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
proxy_read_timeout 1200s;
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;
}
location /media {
root /var/www/seafile/seafile-server-latest/seahub; #seahub的路径
}
}
7.2 测试Nginx配置并确保没有错误,启动nginx服务
# nginx -t
# systemctl start nginx
7.3 必须将域名添加到seafile配置中。转到seafile目录并编辑配置文件, 将服务URL更改为您的域名。
# cd /var/www/seafile/
# vim conf/ccnet.conf
SERVICE_URL = https://172.16.50.45:8000
7.4 编辑seahub配置文件。
# vim conf/seahub_settings.py
在第二行,添加以下配置:
HTTP_SERVER_ROOT = 'https://172.16.50.45/seafhttp'
7.5 重启服务并设置开机自启
# systemctl restart seafile
# systemctl enable nginx mariadb seafile
8. 测试Seafile
8.1 打开浏览器,输入网址 https://172.16.50.45/
eafile数据库备份脚本(脚本里库名是直接运行脚本自动生成的,非上述文档库名)
更多推荐
所有评论(0)