本篇基于CentOS系统以及宝塔面板,安装Seafile文件服务。以下操作的前提是需要有宝塔面板的环境。Seafile官网:https://www.seafile.com。
首先,个人倾向于先安装最新版的Python(Anaconda),否则后续安装可能会报错。安装方法参考:安装Python环境。
在官网中下载Seafile服务器端安装包:https://www.seafile.com/download/。官方说明:“seafile 9.0.x 版本不支持在 Centos 系统 tar 包部署,支持 Docker 方式部署”。如果不想要通过Docker部署,那么可在网上寻找Seafile 8.0.x的安装包。本篇安装的是:seafile-server_8.0.5_x86-64.tar.gz。
在./opt文件夹中新建文件夹seafile,将安装包放进去,解压。
根据官网说明(https://cloud.seafile.com/published/seafile-manual-cn/deploy/using_mysql.md)安装初始环境:
# on CentOS 8
yum install python3 python3-setuptools python3-pip python3-ldap python3-devel mysql-devel gcc gcc-c++ -y
pip3 install --timeout=3600 django==2.2.* future mysqlclient pymysql Pillow pylibmc \
captcha jinja2 sqlalchemy==1.4.3 psd-tools django-pylibmc django-simple-captcha
# on CentOS 7
yum install python python-setuptools MySQL-python python-urllib3 python-ldap -y
由于自己的服务器环境是CentOS 7,同时是Seafile 8.0.x 版本,这里把以上两个初始环境都安装下。可能会报错,可先安装最新版的Python和以下内容,然后再安装上面的内容(可能同样报错,但可不用管)。
yum install python3 python3-setuptools python3-pip -y
yum -y install sqlite
yum install python3-devel mysql-devel gcc gcc-c++ -y
pip3 install captcha
pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools django-pylibmc django-simple-captcha python3-ldap
pip3 install future mysqlclient sqlalchemy==1.4.3
进入安装包文件夹,进行安装:
cd seafile-server-8.0.5
./setup-seafile-mysql.sh #运行安装脚本并回答预设问题
需要在服务器中提前开放三个默认端口:8082、3306、8000。
在安装过程中需要数据库的root密码,在宝塔面板中的界面获取。
如果在重装时,数据库seafile用户的密码忘了,不懂如何操作可以考虑重新安装数据库后重试。
安装结束后使用以下命令启动:
./seafile.sh restart # 停止当前的 Seafile 进程,然后重启 Seafile
./seahub.sh restart # 停止当前的 Seahub 进程,并在 8000 端口重新启动 Seahub
首次运行时需要填写邮箱和密码。
如果前面安装时填写的是域名,而不是IP地址,那么需要在宝塔面板中新建静态站点,域名为个人域名,和前面一致,同时需要做好域名解析。
在站点中设置反向代理,目标URL为:http://127.0.0.1:8000。
访问域名登录,如果上传和下载文件出现问题,需要检查设置中SERVICE_URL和SERVICE_URL中是http或者https,这和是否申请SSL有关。另外,还需要在宝塔面板的站点中设置配置文件,补充以下内容,否则无法正常上传或者下载(https://cloud.seafile.com/published/seafile-manual-cn/deploy/https_with_nginx.md):
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 /opt/seafile/seafile-server-8.0.5/seahub;
}
以下设置开机自启动(参考:Linux常用命令和超算中PBS常用命令):
将以下seafile.sh文件放置到/etc/init.d中:
#!/bin/bash
#chkconfig: 2345 80 99
#description:auto_run
export PATH="/opt/anaconda3/bin:$PATH"
/opt/seafile/seafile-server-8.0.5/seafile.sh restart
/opt/seafile/seafile-server-8.0.5/seahub.sh restart
分别输入:
- chkconfig --add seafile.sh
- chkconfig --list
- chkconfig seafile.sh on
- service seafile.sh start
如果遇到头像显示不完整,可以考虑删除以下缓存:
rm -rf /tmp/seahub_cache/*
【说明:本站主要是个人的一些笔记和代码分享,内容可能会不定期修改。为了使全网显示的始终是最新版本,这里的文章未经同意请勿转载。引用请注明出处:https://www.guanjihuan.com】