seafile搭建https私有云

自己的服务器到期,转移自己博客内容至此。

seafile搭建企业、个人私有云,并将站点配置为https。      点击进入seafile官网

环境:Centos 7

一、安装seafile准备

[root@xifeng tools]# wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.1.2_x86-64.tar.gz     #下载seafile安装包
[root@xifeng tools]# mkdir /var/html/seafile -p    #创建seafile目录
[root@xifeng tools]# mv seafile-server_6.1.2_x86-64.tar.gz /var/html/seafile/
#将下载的seafile移动到指定路径


[root@xifeng tools]# cd /var/html/seafile/
[root@xifeng seafile]# mkdir installed
[root@xifeng seafile]# tar xf seafile-server_6.1.2_x86-64.tar.gz
[root@xifeng seafile]# mv seafile-server_6.1.2_x86-64.tar.gz installed/
[root@xifeng mycloud]# cd seafile-server-6.1.2/
#以上几步为解压安装包,并将安装包移至installed目录里,进入解压后的目录。

二、seafile数据库安装(mysql或者mariadb)       

seafile的官方脚本会默认安装三个数据库,默认库名分别如下:

        database             create new
    ccnet database:          ccnet-db
    seafile database:        seafile-db
    seahub database:         seahub-db

依照官方脚本,最后提示没有权限在本机创建数据库的表。删掉创建的文件后,可自行授权数据库:

#grant all privileges on `seafile-db`.* to ‘seafile’@’127.0.0.1’ identified by ‘yourpass’;
#grant all privileges on `seahub-db`.* to ‘seafile’@’127.0.0.1’ identified by ‘yourpass’;
#grant all privileges on `ccnet-db`.* to ‘seafile’@’127.0.0.1’ identified by ‘yourpass’;

就是对seafile数据库用户授权在本机管理以上三个数据库。
做完数据库授权后,再进行安装:

[root@xifeng seafile-server-6.1.2]# ./setup-seafile-mysql.sh   #安装数据库
Checking python on this machine …
Checking python module: setuptools … Done.
Checking python module: python-imaging … Done.
Checking python module: python-mysqldb … Done.

—————————————————————–
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at

https://github.com/haiwen/seafile/wiki

Press ENTER to continue
—————————————————————–

[ server name ] mycloud
What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server’s ip or domain ] cloud.liuanhuaming.top

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default “/var/html/mycloud/seafile-data” ]

Which port do you want to use for the seafile fileserver?
[ default “8082” ]

——————————————————-
Please choose a way to initialize seafile databases:
——————————————————-

[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

[ 1 or 2 ] 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 ]

verifying password of user root … done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default “seafile” ] mycloud

Enter the password for mysql user “mycloud”:
[ password for mycloud ]

verifying password of user mycloud … done

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” ]

———————————
This is your configuration
———————————

server name: mycloud
server ip/domain: cloud.liuanhuaming.top

seafile data dir: /var/html/mycloud/seafile-data
fileserver port: 8082

database: create new
ccnet database: ccnet-db
seafile database: seafile-db
seahub database: seahub-db
database user: mycloud

———————————
Press ENTER to continue, or Ctrl-C to abort
———————————

Generating ccnet configuration …

done
Successly create configuration dir /var/html/mycloud/ccnet.
Generating seafile configuration …

Done.
done
Generating seahub configuration …

—————————————-
Now creating seahub database tables …

—————————————-

creating seafile-server-latest symbolic link … done

—————————————————————–
Your seafile server configuration has been finished successfully.
—————————————————————–

run seafile server: ./seafile.sh { start | stop | restart }
run seahub server: ./seahub.sh { start <port> | stop | restart <port> }

—————————————————————–
If you are behind a firewall, remember to allow input/output of these tcp ports:
—————————————————————–

port of seafile fileserver: 8082
port of seahub: 8000

When problems occur, Refer to

https://github.com/haiwen/seafile/wiki

for information.

安装完成!

三、启动seafile服务端,并创建管理员帐号密码

[root@xifeng seafile-server-6.1.2]# ./seafile.sh start

[12/01/17 13:27:36] ../common/session.c(132): using config file /var/html/mycloud/conf/ccnet.conf
Starting seafile server, please wait …
Seafile server started

Done.

[root@xifeng seafile-server-6.1.2]# ./seahub.sh start

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 …

—————————————-
It’s the first time you start the seafile server. Now let’s create the admin account
—————————————-

What is the email for the admin account?
[ admin email ] *****@gmail.com

What is the password for the admin account?
[ admin password ]

Enter the password again:
[ admin password again ]

—————————————-
Successfully created seafile admin
—————————————-

Seahub is started

Done.

服务启动、管理帐号创建完成!

四、配置nginx,让seafile为https站点

直接上nginx配置:

server {
listen 80;
server_name cloud.liuanhuaming.top;
rewrite ^ https://$http_host$request_uri? permanent;
server_tokens off;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/letsencrypt/live/cloud.liuanhuaming.top/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cloud.liuanhuaming.top/privkey.pem;
server_name cloud.liuanhuaming.top;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:5m;
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_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
}
location /media {
root /var/html/mycloud/seafile-server-latest/seahub;
}
}

重启nginx,全部完成,浏览器测试成功!

五、添加开机自启动

[root@xifeng seafile-server-latest]# vi /etc/rc.local

/var/html/mycloud/seafile-server-latest/seafile.sh start
/var/html/mycloud/seafile-server-latest/seahub.sh start

添加以上两行,路径改为自己的,完成!

六、遇到的问题

        由于服务器搭建其他应用,或者重启了服务器,某天发现seafile无法上传和访问。于是进到

服务器运行启动seafile.sh和seahub.sh脚本,发现无法运行,提示使用www用户运行,因为我把

seafile的所有目录授权为www用户,即nginx的运行用户。导致无法运行脚本。

错误提示:

[root@liuanhuaming seafile-server-6.1.2]# ./seafile.sh start

Error: the user running the script (“root”) is not the owner of “/var/html/mycloud/seafile-data” folder, you should use the user “www” to run the script.

通过翻译,只要将/var/html/mycloud/seafile-data授权为root用户所有,再用root运行脚本即可。

解决方法:

[root@liuanhuaming mycloud]# chown -R root.root seafile-data/
[root@liuanhuaming mycloud]# cd seafile-server-6.1.2/
[root@liuanhuaming seafile-server-6.1.2]# ./seafile.sh start

[01/23/18 10:05:41] ../common/session.c(132): using config file /var/html/mycloud/conf/ccnet.conf
Starting seafile server, please wait …
Seafile server started

Done.
[root@liuanhuaming seafile-server-6.1.2]# ./seahub.sh start

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 …

Seahub is started

Done.

 

posted @ 2018-06-04 16:57  catinsky  阅读(4046)  评论(0编辑  收藏  举报