linux(centos7.7)安装seafile7.0教程

本文档主要用来说明如何使用预编译安装包来部署 Seafile 服务器。参考seafile官方的文档,但是官方文档太过简略,可操作性也不是很强。所以写这个文档,供大家参考。

seafile服务器端建议使用 MySQL 数据库,并将 Seafile 部署在 Nginx 或者 Apache 上,如果对于 Nginx 和 Apache 都不是很熟悉的话,我们建议使用 Nginx,相对于 Apache 来说,Nginx 使用起来比较简单。
** 本教程的服务器采用虚拟主机,25g ssd,单cpu,1g内存,硬件配置是足够的。系统为centos7.7,搭配Mariadb数据库和Nginx配置反向代理。**

一、环境准备

1、 安装Nginx

yum install nginx -y

如果提示安装包未找到,先安装下linux的扩展源。

yum install epel-release -y

然后再运行上面的安装代码就可以。

安装完nginx1.16.1版本。
在这里插入图片描述
安装完成后,启动nginx,并设置开机启动

systemctl start nginx
systemctl enable nginx

**2、**安装Mariadb(Mysql)

yum安装Mariadb。

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] #是否删除匿名用户,生产环境建议删除,所以直接回车

Disallow root login remotely? [Y/n] #是否禁止root远程登录,根据自己的需求选择Y/n,这里选择允许。

Remove test database and access to it? [Y/n] #是否删除test数据库,直接回车

Reload privilege tables now? [Y/n] #是否重新加载权限表,直接回车
在这里插入图片描述
**3、**安装其他依赖组件

yum install -y  python-setuptools python-imaging python-ldap MySQL-python python-memcached python-urllib3

安装完成。

在这里插入图片描述

二、安装seafile服务器端

**1、**下载seafile安装文件
到seafile官网下载
seafile的linux的服务器端程序。
linux(centos7.7)安装seafile7.0教程_第1张图片

下载完成后可以用wincap软件,将文件传输到linux服务器的opt文件夹里。

**2、**创建文件目录(采用官方的目录结构)

mkdir /opt/seafile
mv seafile-server_* /opt/seafile
cd /opt/seafile

#将 seafile-server_* 移动到 seafile 目录下后,解压安装包

tar -xzf seafile-server_*

创建目录

mkdir installed

将安装包移动到install目录

mv seafile-server_* installed

seafile

├── installed

│ └── seafile-server_7.0.5_x86-64.tar.gz

└── seafile-server-7.0.5

├── reset-admin.sh

├── runtime

├── seafile

├── seafile.sh

├── seahub

├── seahub.sh

├── setup-seafile-mysql.sh

└── upgrade

这样设计目录的好处在于

和 seafile 相关的配置文件都可以放在 /opt/seafile/conf 目录下,便于集中管理.

后续升级时,你只需要解压最新的安装包到 /opt/seafile 目录下。
**3、**安装seafile
进入到解压后的目录

cd seafile-server-7.0.5/

运行安装脚本

./setup-seafile-mysql.sh #运行安装脚本并回答预设问题

linux(centos7.7)安装seafile7.0教程_第2张图片
如果你的系统中没有安装上面的某个软件,那么 Seafile初始化脚本会提醒你安装相应的软件包.

该脚本会依次询问你一些问题,从而一步步引导你配置 Seafile 的各项参数:
linux(centos7.7)安装seafile7.0教程_第3张图片

在这里, 你会被要求选择一种创建 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” ] # 默认

完成上述后,会有如下提示界面:
linux(centos7.7)安装seafile7.0教程_第4张图片

然后回车开始配置,创建完成后提示。
linux(centos7.7)安装seafile7.0教程_第5张图片

至此,seafile安装完成!

三、seafile配置

**1、**启动seafile服务
切换到seafile的文件目录

cd /opt/seafile/seafile-server-latest

启动 Seafile服务

 ./seafile.sh start  # 启动 Seafile 服务

启动成功,如下图所示
linux(centos7.7)安装seafile7.0教程_第6张图片

启动seafile网站服务

./seahub.sh start # 启动 Seahub 网站 

启动成功,第一次会提示设置管理员账户相关信息。
linux(centos7.7)安装seafile7.0教程_第7张图片
What is the email for the admin account?
[ admin email ] #设置管理员账户邮箱

What is the password for the admin account?
[ admin password ] # 设置管理员密码

设置完成后会启动seahub服务。如下图:
linux(centos7.7)安装seafile7.0教程_第8张图片
**2、**配置nginx反向代理

7.0.x 版本之后,8000端口默认监听在127.0.0.1地址上,这意味着您无法直接通过8000端口访问Seafile服务。所以需要配置nginx反向代理。

打开nginx的配置文件目录

cd /etc/nginx/nginx.conf

修改配置文件之前,先将配置文件备份一下

cp nginx.conf nginx.conf.bkb

nginx的配置文件,可以将下面的内容直接覆盖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

然后就可以在浏览器直接输入主机地址,就可以访问了,不需要加端口号。
linux(centos7.7)安装seafile7.0教程_第9张图片
至此,大功告成。
也可以将域名解析到此主机地址,就可以通过域名访问了。
注意防火墙放行相关服务端口,8000,8082等。

你可能感兴趣的:(linux,数据库,centos,数据库,nginx,linux)