Use OwnCloud Docker container + Alibaba Cloud OSS to build your own cloud disk service on Centos 7

Use OwnCloud Docker container + Alibaba Cloud OSS to build your own cloud disk service on Centos 7

 

Alibaba Cloud's OSS storage is cheaper

OwnCloudFree

Docker container deployment is simple

 

First, mount oss to the ECS host of Alibaba Cloud

For ossfs installation, please refer to:

http://crabdave.iteye.com/blog/2355690

 

Unmount ossfs (if needed)

umount Mount directory on the host # root user

 

mount ossfs

Before mounting, you need to create a user used by the owncloud service, and the container uses the www-data user

useradd -u 33 -G root www-data

At this time, I use the user ID is 33, the root user group ID of this machine is 0

即 www-data root

ID numbers can be viewed through /etc/passwd and /etc/group

 

Start mounting (-ouid=33 -ogid=0 -oumask=007 -o allow_other mainly solves the problem that owncloud prompts to mount directory 0770)

ossfs mount directory on your bucket host -ourl=http://oss-cn-beijing-internal.aliyuncs.com -ouid=userid -ogid=groupid -oumask=007 -o allow_other

 

Orchestrate Docker containers (including owncloud:9 and MySQL 5.7)

For the installation of docker-compose, please refer to:

http://crabdave.iteye.com/blog/2359617

 

vi docker-compose.yml 

 

owncloud:

  image: owncloud:9

  restart: always

  privileged: true

  links:

    - mysql:mysql

  volumes:  

    - /host directory:/container directory 

  ports:

    - "Host port: 80"

mysql:

  image: mysql:5.7

  restart: always

  environment:

    MYSQL_ROOT_PASSWORD: 数据库密码

    

后台启动:

docker-compose up -d

 

打开首页(宿主机IP:端口)进行配置,其中需要调整以下内容

管理员账号密码

配置数据文件目录,即挂载的OSSFS目录(compose描述文件中容器内部目录---/容器目录)

选择MYSQL数据库,填写账号密码、数据库名(owncloud)、地址(mysql)

 

配置数据库时偶尔会出现

error while trying to create admin user: failed to connect to the database: an exception occured in driver:SQLSTAT[HY000][1045]错误,

仔细观察后发现,使用的mysql数据库地址不对(docker mysql 容器对应的IP),界面上展示使用的是owncloud容器自己的IP (估计是默认数据库地址为localhost造成的)

然后我改一下管理员密码 就成功了,不知道为什么,估计是有缓存之类的

 

如果以后打算使用域名访问,最好是在安装的时候就使用域名打开首页进行安装,不然还得修改PHP配置文件设置可信任站点

 

nginx域名转发配置如下:

server {

    listen       80;

    server_name  你的域名;

 

    #charset utf-8;

    #access_log  /var/log/nginx/log/host.access.log  main;

 

    location / {

       proxy_set_header Host $host;

       proxy_set_header X-Real-IP $remote_addr;

       #proxy_set_header X-Forwarded-Proto https;

       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

       proxy_pass http://127.0.0.1:宿主机端口;

    }

 

 

参考:

https://bbs.aliyun.com/read/299139.html

https://github.com/aliyun/ossfs/issues/5

https://yq.aliyun.com/articles/67160

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326683148&siteId=291194637