CentOS7安装Seafile7并使用Nginx代理
为什么要安装Seafile?
BD云盘上传与下载限速严重,个人资源和谐严重。
专业版与社区版区别?
专业版默认只能添加三个账户,社区版无限制。专业版提供文件检索功能。个人使用专业版三个用户足够,企业使用建议支持国产优秀项目。
Seafile7与Seafile6不同?
Seafile7访问需要借助Nginx代理,Seafile7解决了Seafile6浏览器文件夹上传可能存在的Bug,Seafile7.0.4版本之后提供与钉钉和企业微信的集成。
第一步:CentOS7安装与配置
网络模式建议为桥接模式,请参考:https://www.jianshu.com/p/aa9773669fcd
第二步:下载Seafile7 专业版
请下载7.0.4以上,CentOS版本, 下载链接: https://download.seafile.com/d/6e5297246c/?p=/pro
第三步: 安装Python3和pip3
1. 安装 EPEL库
yum install epel-release -y
2. 安装Python3.6
yum install python36 -y
yum install python36-devel -y
3. 安装pip3
yum install python36-pip -y
第四步: 安装Nginx
1. 安装编译软件及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
2. 下载PCRE
cd /usr/local/src/
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
3. 安装PCRE
tar zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make && make install
4. 下载Nginx
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
5. 安装Nginx
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --prefix=/usr/local/src/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
make
make install
6. 创建nginx运行使用用户meichen
/usr/sbin/groupadd meichen
/usr/sbin/useradd -g meichen meichen
第五步: 安装Seafile7
1. 将Seafile7专业版安装包复制到CentOS7
(1) SecureCRT中,按下ALT+P,打开SFTP界面, 输入 put 安装包文件全路径,等待完成上传,比如我的在桌面上,名字为:seafile-pro-server_7.1.5_x86-64_CentOS.tar.gz。
put C:\Users\Administrator\Desktop\seafile-pro-server_7.1.5_x86-64_CentOS.tar.gz
(2) 查看Seafile7安装文件
cd ~
ls
(3) 安装Seafile7
创建安装目录、解压安装文件,执行安装命令。
mkdir -p /usr/local/src/seafile-server
tar -zxvf seafile-pro-server_7.1.5_x86-64_CentOS.tar.gz -C /usr/local/src/seafile-server
cd /usr/local/src/seafile-server/seafile-pro-server-7.1.5/
./setup-seafile-mysql.sh
(4) 有的需要执行此语句
yum install MySQL-python
第六步: 配置安装Seafile7
1. 回车进入下一步
2. 输入服务的名字:
3. 输入服务器的地址或域名
4. Seafile Server默认端口8082,直接回车即可。
5. 是否需要新建Seafile数据库,1新建,2使用现有库。如果是首次搭建Seafile,请选择1。
6. 请输入mysql服务器地址,默认localhost,直接回车即可。
7. 请输入mysql端口号,默认3306,直接回车即可。
8. 请输入root用户密码:
9. 指定seafile数据库用户,默认seafile,直接回车即可。
10. 为seafile用户设置密码:
11. 指定ccnet-server数据库,默认ccnet-db,直接回车即可。
12. 指定seafile-server数据库,默认seafile-db,直接回车即可。
13. 指定seahub数据库,默认seahub-db,直接回车即可。
14. 确认信息,无误后直接回车即可。有问题CTRL+C直接退出安装。
15. 安装完成及常用命令
16. 安装office库,实现在线查看OFFICE文档。
yum install -y libreoffice
17. 开放8082和8000端口
firewall-cmd --zone=public --add-port=8082/tcp --permanent
firewall-cmd --zone=public --add-port=8000/tcp --permanent
firewall-cmd --reload
18. 可选:永久关闭防火墙
service firewalld stop
systemctl disable firewalld
第七步: 配置Nginx代理监听
1. vim新建error.log日志文档并esc :wq保存。
vim /usr/local/src/nginx/logs/error.log
2. 修改Nginx核心配置文件nginx.conf,并esc :wq保存。
vim /usr/local/src/nginx/conf/nginx.conf
user meichen meichen;#第四步-6,输入创建nginx运行使用用户。
worker_processes 4;#虚拟机CPU数量。
error_log /usr/local/src/nginx/logs/error.log crit;
pid /usr/local/src/nginx/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 0;
send_timeout 180;
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;
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;
}
location /media {
root /usr/local/src/seafile-server/seafile-server-latest/seahub;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
3. 测试nginx是否正常
cd /usr/local/src/nginx/sbin
./nginx -t
4. 开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
5. 可选:永久关闭防火墙
service firewalld stop
systemctl disable firewalld
第八步: 启动
1. 启动Nginx
cd /usr/local/src/nginx/sbin
./nginx
2. 启动Seafile
cd /usr/local/src/seafile-server/seafile-server-latest/
./seafile.sh start
3. 启动Seahub
cd /usr/local/src/seafile-server/seafile-server-latest/
./seahub.sh start
4. 首次启动Seahub需要配置管理员用户密码
如果Seahub启动失败,执行此语句后重启Seafile与Seahub
yum install MySQL-python
5. 访问测试
已做Nginx代理并监听80端口,直接输入服务器IP地址即可访问。(桥接模式)
NAT网络模式需要做虚拟机网络映射,请参考:https://www.jianshu.com/p/cd6c54265f53