nextcloud在centos系统下搭建自己的私有云盘

搭建一套自己的私有云盘,让数据存储更加方便、可靠。自己搭建的云存储,首先没有什么容量、下载速度的限制,而且本地访问速度很快。一开始以为Nextcloud只是一个网盘云存储,后来看到Nextcloud内置了Office文档、图片相册、日历联系人、两步验证、文件管理、RSS阅读等丰富的应用,我发现Nextcloud已经仅仅可以用作个人或者团队存储与共享,还可以打造成为一个个人办公平台,几乎相当于一个个人的Dropbox了。

自己搭建私有云其实很简单,首先需要一台主机,然后需要选择一个私有云软件(比如ownCloud、nextCloud、seafile)。以下内容将介绍如何在 CentOS 7 服务器中安装和配置Nextcloud,并且会通过 Nginx 和 PHP7-FPM 来运行 Nextcloud,同时使用 MariaDB 数据库系统。具体部署方法如下:

一 . 部署环境的系统是Centos7版本

[root@nextcloud ~]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core)

二. 安装并配置Nginx和php-fpm

[root@nextcloud ~]# yum -y install epel-release

[root@nextcloud ~]# yum -y install nginx

添加一个yum源来安装php-fpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装相关组件

yum -y install php70w-fpm php70w-cli php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel

完成后,检查一下php-fpm是否已正常安装

[root@nextcloud ~]# php -v
PHP 7.0.27 (cli) (built: Jan 14 2018 09:00:22) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

配置php-fpm
vim /etc/php-fpm.d/www.conf
.....
user = nginx                          //将用户和组都改为nginx
group = nginx
.....
listen = 127.0.0.1:9000                            //php-fpm所监听的端口为9000
......
env[HOSTNAME] = $HOSTNAME                     //去掉下面几行注释
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
 
/var/lib目录下为session路径创建一个新的文件夹,并将用户名和组设为nginx
mkdir -p /var/lib/php/session
chown nginx:nginx -R /var/lib/php/session/
    
启动Nginx和php-fpm服务,并添加开机启动
systemctl start php-fpm
systemctl start nginx
systemctl enable php-fpm
systemctl enable nginx
 
三. 安装并配置MariaDB 或 mysql
使用MaraiDB作为Nextcloud数据库。yum安装MaraiDB服务
yum -y install mariadb mariadb-server
启动MariaDB服务并添加开机启动
systemctl start mariadb
systemctl enable mariadb
注意: 确保本地登陆数据库的相关帐号及权限都OK。
Mysql需要设置为mixed模式:
set global binlog_format=mixed;
 
下面创建数据库:
MariaDB [(none)]> create database nextcloud;          
MariaDB [(none)]> create user nextcloud@localhost identified by '123456';
MariaDB [(none)]> grant all privileges on nextcloud.* to nextcloud@localhost identified by '123456';
MariaDB [(none)]> flush privileges;
 
四. 配置Nextcloud生成自签名SSL证书

先为SSL证书创建一个新的文件夹:
cd /etc/nginx/cert/
penssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/nextcloud.crt -keyout /etc/nginx/cert/nextcloud.key
.....
Country Name (2 letter code) [XX]:cn                           //国家
State or Province Name (full name) []:beijing                       //省份
Locality Name (eg, city) [Default City]:beijing                      //地区名字
Organization Name (eg, company) [Default Company Ltd]:lxplwh                    //公司名
Organizational Unit Name (eg, section) []:Technology                    //部门
Common Name (eg, your name or your server's hostname) []:lxplwh                 //CA主机名
Email Address []:lxplwh@126.com                                                 
    
然后将证书文件的权限设置为660
chmod 700 /etc/nginx/cert
chmod 600 /etc/nginx/cert/*
 
五. 下载并安装Nextcloud
wget https://download.nextcloud.com/server/releases/nextcloud-12.0.4.zip
unzip nextcloud-12.0.4.zip
mv nextcloud /usr/share/nginx/html/
    
并为Nextcloud创建data目录,将Nextcloud的用户和组修改为nginx
mkdir -p nextcloud/data/
chown nginx:nginx -R nextcloud/
 
六. 配置Nginx虚拟主机
 
[root@nextcloud ~]# vim /etc/nginx/nginx.conf

#user nobody;
worker_processes 1;

events {

worker_connections 1024;
}

http {
  include mime.types;
  default_type application/octet-stream;

  sendfile on;

  keepalive_timeout 65;

  upstream php-handler {
  server 127.0.0.1:9000;
  }

  server {
  listen 80;
  server_name nextcloud.lxplwh.com;
  return 301 https://$server_name$request_uri;
  }

  server {
  listen 443 ssl;
  server_name nextcloud.lxplwh.com;

  ssl_certificate /etc/nginx/cert/nextcloud.crt;
  ssl_certificate_key /etc/nginx/cert/nextcloud.key;
  add_header Strict-Transport-Security "max-age=15768000;
  includeSubDomains; preload;";
  add_header X-Content-Type-Options nosniff;
  add_header X-Frame-Options "SAMEORIGIN";
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Robots-Tag none;
  add_header X-Download-Options noopen;
  add_header X-Permitted-Cross-Domain-Policies none;

  root /usr/share/nginx/html/nextcloud/;

  location = /robots.txt {
  allow all;
  log_not_found off;
  access_log off;
  }

  location = /.well-known/carddav {
  return 301 $scheme://$host/remote.php/dav;
  }
  location = /.well-known/caldav {
  return 301 $scheme://$host/remote.php/dav;
  }
  client_max_body_size 512M;
  fastcgi_buffers 64 4K;
  gzip off;

  error_page 403 /core/templates/403.php;
  error_page 404 /core/templates/404.php;

  location / {
  rewrite ^ /index.php$uri;
  }

  location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
  deny all;
  }
  location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
  deny all;
  }

  location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {

  include fastcgi_params;
  fastcgi_split_path_info ^(.+\.php)(/.*)$;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param HTTPS on;
  fastcgi_param modHeadersAvailable true;
  fastcgi_param front_controller_active true;
  fastcgi_pass php-handler;
  fastcgi_intercept_errors on;
  fastcgi_request_buffering off;
  }
  location ~ ^/(?:updater|ocs-provider)(?:$|/) {
  try_files $uri/ =404;
  index index.php;
  }

  location ~* \.(?:css|js)$ {
  try_files $uri /index.php$uri$is_args$args;
  add_header Cache-Control "public, max-age=7200";
  add_header Strict-Transport-Security "max-age=15768000;includeSubDomains; preload;";
  add_header X-Content-Type-Options nosniff;
  add_header X-Frame-Options "SAMEORIGIN";
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Robots-Tag none;
  add_header X-Download-Options noopen;
  add_header X-Permitted-Cross-Domain-Policies none;
  access_log off;
  }

  location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
  try_files $uri /index.php$uri$is_args$args;
  access_log off;
  }
 }

    
确保没有问题后重启Nginx服务

[root@nextcloud ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@nextcloud ~]# systemctl restart nginx
 
七. 安装Nextcloud
解析上面nginx中配置的域名nextcloud.lxplwh.com,邦定hosts. 访问http://nextcloud.lxplwh.com进行Nextcloud界面安装.

设置帐号密码,以及数据库的连接信息。如果不报错,即可安装完成,进入。

到此安装完成。

下面进行一些安全与性能优化

为了您服务的安全和性能, 请将所有设置配置正确. 我们将会进行一些自动化检查以帮助您完成这项工作. 详情请查看 "小提示" 部分及相关文档.

  • HTTP 请求头 "X-Frame-Options" 没有配置为 "SAMEORIGIN". 这是一个潜在的安全或隐私风险, 我们建议您调整这项设置.
  • 内存缓存未配置. 如果可用, 请配置 memcache 以增强性能. 更多信息请查看我们的文档.
  • PHP 的组件 OPcache 没有正确配置. 为了提供更好的性能, 我们建议在php.ini文件中使用下列设置:
    opcache.enable=1
    opcache.enable_cli=1
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=10000
    opcache.memory_consumption=128
    opcache.save_comments=1
    opcache.revalidate_freq=1

修改程序目录下的config目录中的config.php文件,在配置文件中添加多个Memcached实例,也可以添加一个:

'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Memcached',
'memcached_servers' => array(
     array('localhost', 11211),
     array('server1.example.com', 11211),
     array('server2.example.com', 11211),
     ),
 
添加redis缓存:
在配置文件中添加如下,这个是通过TCP连接的:

'memcache.local' => '\OC\Memcache\Redis',
'redis' => array(
     'host' => 'localhost',
     'port' => 6379,
      ),
 
还有性能更好的UNIX连接:
'memcache.local' => '\OC\Memcache\Redis',
'redis' => array(
     'host' => '/var/run/redis/redis.sock',
     'port' => 0,
     'dbindex' => 0,
     'password' => 'secret',
     'timeout' => 1.5,
      ),
同时,官方还推荐加入如下,来用于存储文件锁:
'memcache.locking' => '\OC\Memcache\Redis',

Nextcloud的邮件发信设置

使用管理员账号登陆Nextcloud。点击右上角的设置图标里的"管理"-"其他设置"

转载自:https://www.cnblogs.com/lxplwh/p/8398522.html

nextcloud私有云盘的部署的更多相关文章

  1. linux下使用URLOS搭建nextcloud私有云盘系统

    Nextcloud是一个免费专业的私有云存储网盘开源项目,可以让你简单快速地在个人/公司电脑.服务器甚至是树莓派等设备上架设一套属于自己或团队专属的云同步网盘,从而实现跨平台跨设备文件同步.共享.版本 ...

  2. Nextcloud私有云盘在Centos7下的部署笔记

    搭建个人云存储一般会想到ownCloud,堪称是自建云存储服务的经典.而Nextcloud是ownCloud原开发团队打造的号称是“下一代”存储.初一看觉得“口气”不小,刚推出来就重新“定义”了Clo ...

  3. 政务私有云盘系统建设的工具 – Mobox私有云盘

    序言 这几年,智慧政务已经成为了政府行业IT建设发展的重要进程.传统办公方式信息传递速度慢.共享程度低.查询利用难,早已成为政府机关获取和利用信息的严重制约因素.建立文档分享共用机制,加强数据整合,避 ...

  4. Docker部署Nextcloud私有网盘

    对于国内某度的网盘限速行为大家有目共睹,不过对于商业化的产品模式这样也无可厚非,毕竟企业也是盈利为目的.如果想享受互联网技术带来的便利,刚好也懂一点技术的话可以尝试搭建属于私有的网盘.个人比较推荐的是 ...

  5. 5分钟快速部署ownCloud私有云盘存储系统

    ownCloud 是一个开源免费专业的私有云存储项目,它能帮你快速在个人电脑或服务器上架设一套专属的私有云文件同步网盘,可以像 Dropbox 那样实现文件跨平台同步.共享.版本控制.团队协作等等.o ...

  6. docker 搭建私有云盘 Seafile

    缘起 现如今各种云存储服务其实挺多的,国外有经典的DropBox.Google Drive.微软的OneDrive等,国内也有可以免费使用的各种云. 那么为什么想要搭建私有云存储呢?主要是本着“自己的 ...

  7. 极客DIY:使用树莓派制作一套“NAS+私有云盘+下载机”

    原创作者:HackLiu 0×00 前言 ‍ ‍ 如果你家里有多台设备需要联网需要娱乐,你一定会或多或少遇到设备碎片化带来的烦恼.当然,已经有很多厂商包括新晋的小米.360在内的互联网公司做了这个事情 ...

  8. Nextcloud13私有云盘安装指南

    一.环境说明: ※操作系统版本CentOS 7.5 Minimal-1804 ※操作系统版本已经使用163 YUM源 ※ Nextcloud版本 13.05 ※ 数据库使用MariaDB,安装在同一台 ...

  9. 使用树莓派制作一套“NAS+私有云盘+下载机”

    ‍ ‍‍原创作者:HackLiu‍‍ ‍ 0×00 前言 ‍‍如果你家里有多台设备需要联网需要娱乐,你一定会或多或少遇到设备碎片化带来的烦恼.当然,已经有很多厂商包括新晋的小米.360在内的互联网公司 ...

随机推荐

  1. 坊间流传着的关于谷歌大牛Jeff Dean的传说

    Jeff Dean,Google的软件架构天才.Google大型并发编程框架Map/Reduce作者. 在Google,公司最顶尖的编程高手Jeff Dean曾发明过一种先进的方法,该方法可以让一个程 ...

  2. Xilinx官网查询各个版本软件的手册

    在Xilinx官网查询各个版本软件的手册需要点击 See All Versions

  3. Datatable转实体 实体转换辅助类

    using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.R ...

  4. C语言:存取结构体成员的点运算符(.)和箭头运算符(->)的区别

    转自:http://blog.csdn.net/taric_ma/article/details/7397362 一直以为这两个是没有什么区别的,可以相互替换,今天又翻了一下<C语言核心技术&g ...

  5. AsyncContext简介

    为了支持异步处理,在Servlet 3.0中,在ServletRequest上提供了startAsync()方法: AsyncContext startAsync() throws Java.lang ...

  6. .NET Core2.0 环境下MVC模式的支付宝扫码支付接口-沙箱环境开发测试

    所有配置以及相关信息均可以从PC支付中获取 使用的生成二维码的组件名为QRCoder,该组件引用了一个第三方实现的System.Drawing类库,和支付宝官网类似 当面付SDK为Alipay.Aop ...

  7. git stash 暂存恢复和文件误删恢复

    git commit提交文件,服务器返回本地文件有修改. 1.git stash :暂存本地代码 2.git pull origin develop : 获取远程分支代码 3.git stash po ...

  8. ARKit从入门到精通(1)-ARKit初体验

    ARKit从入门到精通(1)-ARKit初体验 转载自:http://blog.csdn.net/u013263917/article/details/72903174 该系列文章共十篇,笔者将由易到 ...

  9. Python os.popen() 方法

    简述 就是新建一个管道执行一个命令. 方法是os.popen(命令,权限,缓冲大小) 比如 a = 'mkdir def' b = os.popen(a,) print b 就是等同于使用命令去创建了 ...

  10. python 基础总计 2

    6.函数:      match.sqrt(),lower(),len(),type(),isinstance('a',str),max(),min(),dir(),hex(),setattar(ob ...