使用owncloud搭建属于自己的云盘

  • 使用owncloud搭建属于自己的云盘已关闭评论
  • 123 views
  • A+
所属分类:存储应用

简介

owncloud是一个开源的云盘解决方案,我们可以用owncloud快速地搭建起我们自己私有的云盘,这样文件地安全性和云盘地可靠性都有保证,对于公司和个人都是非常有用的。

需要用到的软件

centos7,Nginx、PHP、owncloud、ngrok

安装 Nginx

#yum install nginx

更新RPM

#rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm  
#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装 PHP

#yum -y install php72w php72w-cli php72w-common php72w-devel php72w-mysql php72w-xml php72w-odbc  php72w-curl php72w-gd  php72w-mcrypt  php72w-cgi php72w-zip php72w-dom php72w-mbstring
启动
#service php-fpm start

安装 MySql

下载安装yum源

#wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
#yum -y install mysql57-community-release-el7-10.noarch.rpm

安装

yum -y install mysql-community-server

启动

systemctl start mysqld.service

查找密码

grep "password" /var/log/mysqld.log

通过找到的密码进入数据库

 mysql -u root -p

修改密码:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

云盘安装

添加新的软件源

#rpm --import https://download.owncloud.org/download/repositories/10.1.1/CentOS_7/repodata/repomd.xml.key

安装owncloud-files

#wget http://download.owncloud.org/download/repositories/10.1.1/CentOS_7/ce:10.1.repo -O /etc/yum.repos.d/ce:10.1.repo 
#yum clean all
#yum install owncloud-files

检查是否下载成功

#cd /var/www/html
#ls

看是否有owncloud 文件夹

云盘 owncloud 配置文件:

server {
    listen 80 default_server;
  # 安装目录
    root /var/www/html/owncloud;
    index index.php index.htm;
    client_max_body_size    10G; 
    fastcgi_buffers    64    4K; 
    gzip    off; 
    rewrite    ^/caldav(.*)$    /remote.php/caldav$1 redirect; 
    rewrite    ^/carddav(.*)$    /remote.php/carddav$1 redirect;
    rewrite    ^/webdav(.*)$    /remote.php/webdav$1 redirect;
    index    index.php;
    error_page    403    /core/templates/403.php;
    error_page    404    /core/templates/404.php;
    location = /robots.txt {
        allow all; 
        log_not_found off; 
        access_log off; 
    } 
    location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
        deny all; 
    }
    location / {
        # The following 2 rules are only needed with webfinger 
        rewrite ^/.well-known/host-meta /public.php?service=host-meta last; 
        rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; 
        rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; 
        rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; 
        rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; 
        try_files $uri $uri/ /index.php; 
    }
    location ~ \.php(?:$|/) {
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.+)$; 
        include fastcgi_params; 
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
        fastcgi_param PATH_INFO $fastcgi_path_info; 
        #ifastcgi_pass php-handler; 
    }
    location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
          expires 30d; 
          # Optional: Don't log access to assets 
          access_log off; 
    } 

}

配置完成后,进入安装界面,输入管理员账号密码以及数据库相关信息,点击进入下一步即可安装成功:

使用owncloud搭建属于自己的云盘

初始页面:

使用owncloud搭建属于自己的云盘

内网穿透

如果你想要在非局域网中访问,就需要加一个穿透,来访问我们内网的服务。

这里请参考

Ngrok安装配置

通过内外穿透,就可以上公网了。

  • 安卓客户端下载
  • 微信扫一扫
  • weinxin
  • 微信公众号
  • 微信公众号扫一扫
  • weinxin
avatar