CentOS7环境部署NextCloud 13

介绍:Nextcloud是一款免费开源的私有网盘软件,支持存储文件,在线预览视频、图片,支持多用户(Seafile免费版只支持到3用户),支持移动端使用,并且可以扩展功能。

安装环境要求:

Nextcloud安装环境要求

本次安装环境:

CentOS 7.4 3.10.0-862

Mariadb-5.5.56

PHP-7.1.18

Nginx-1.12.2

Nextcloud-13

安装过程

操作系统准备(略)

我选择在Azure上搭建虚拟机来部署。

关闭防火墙和selinux(使用网络安全组开放22端口和80/443端口)

systemctl stop firewalld

setenforce 0(临时关闭,但建议修改/etc/sysconfig/selinux文件关闭)

安装基本工具

yum –y install lrzsz unzip vim gcc wget epel-release

yum -y install libsmbclient libsmbclient-devel redis

安装运行Mariadb(yum安装即可),配置开机自启

yum -y install mariadb mariadb-server

systemctl enable mariadb.service

systemctl start mariadb.service

初始化数据库(设置root密码,具体过程略),为nextcloud创建数据库用户

mysql_secure_installation

mysql –u root –p

create database nextcloud_db;

grant all privileges on nextcloud_db.* to nextclouduser@localhost identified by 'nextcloudpass';

flush privileges;

exit

这样就创建了一个拥有nextcloud_db库全部权限的nextclouduser用户,该用户可本地连接,密码为nextcloudpass

安装启动Nginx,设置开机自启

yum -y install nginx

mkdir /var/www

chown -R nginx:nginx /var/www

systemctl enable nginx.service

systemctl start nginx.service

安装PHP

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

yum -y install php71w php71w-fpm

yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt

yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel

yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache

vi /etc/php-fpm.d/www.conf

;修改user和group这两行,大概在8行左右

user = nginx

group = nginx

;取消这几行的注释,大概在第370行左右

env[HOSTNAME] = $HOSTNAME

env[PATH] = /usr/local/bin:/usr/bin:/bin

env[TMP] = /tmp

env[TMPDIR] = /tmp

env[TEMP] = /tmp

建立相关目录,修改相关目录权限

mkdir -p /var/lib/php/session

chown -R nginx:nginx /var/lib/php/session/

vi /etc/php.d/opcache.ini

修改/etc/php.d/opcache.ini,将以下行注释去掉,并修改为对应的配置值

zend_extension=opcache.so

opcache.enable=1

opcache.enable_cli=1

opcache.memory_consumption=128

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=10000

opcache.revalidate_freq=1

opcache.save_comments=1

安装smbclient扩展模块

yum -y install libsmbclient libsmbclient-devel

pecl install smbclient

vi /etc/php.d/smbclient.ini

新建/etc/php.d/smbclient.ini,添加如下内容

extension=smbclient.so

开启、启动php-fpm服务

systemctl enable php-fpm.service

systemctl start php-fpm.service

安装Nextcloud

下载Nextcloud(选择合适的版本,这里我选择了latest-13.zip)

解压

unzip latest-13.zip

mv nextcloud /var/www/

chown -R nginx:nginx /var/www

生成SSL证书(这里为自签名证书,如需要正规的免费证书,请访问SSL FOR FREE申请)

mkdir -p /etc/nginx/cert/

openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/nextcloud.crt -keyout /etc/nginx/cert/nextcloud.key

chmod 700 /etc/nginx/cert

chmod 600 /etc/nginx/cert/*

配置Nginx

修改nginx服务配置文件/etc/nginx/nginx.conf为以下内容,将“yourname.domain”替换为自己的域名,修改client_max_body_size可以设置最大可上传的文件大小

vim /etc/nginx/nginx.conf

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/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;

#gzip on;

upstream php-handler {

server 127.0.0.1:9000;

#server unix:/var/run/php5-fpm.sock;

}

server {

listen 80;

server_name yourname.domain;

# enforce https

return 301 https://$server_name$request_uri;

}

server {

listen 443 ssl http2;

server_name yourname.domain;

ssl_certificate /etc/nginx/cert/nextcloud.crt;

ssl_certificate_key /etc/nginx/cert/nextcloud.key;

# Add headers to serve security related headers

# Before enabling Strict-Transport-Security headers please read into this

# topic first.

# add_header Strict-Transport-Security "max-age=15768000;

# includeSubDomains; preload;";

#

# WARNING: Only add the preload option once you read about

# the consequences in https://hstspreload.org/. This option

# will add the domain to a hardcoded list that is shipped

# in all major browsers and getting removed from this list

# could take several months.

add_header X-Content-Type-Options nosniff;

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;

# Path to the root of your installation

root /var/www/nextcloud/;

location = /robots.txt {

allow all;

log_not_found off;

access_log off;

}

# The following 2 rules are only needed for the user_webfinger app.

# Uncomment it if you're planning to use this app.

#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;

#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json

# last;

location = /.well-known/carddav {

return 301 $scheme://$host/remote.php/dav;

}

location = /.well-known/caldav {

return 301 $scheme://$host/remote.php/dav;

}

# set max upload size

client_max_body_size 512M;

fastcgi_buffers 64 4K;

# Enable gzip but do not remove ETag headers

gzip on;

gzip_vary on;

gzip_comp_level 4;

gzip_min_length 256;

gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;

gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

# Uncomment if your server is build with the ngx_pagespeed module

# This module is currently not supported.

#pagespeed off;

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/.+)\.php(?:$|/) {

fastcgi_split_path_info ^(.+\.php)(/.*)$;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param HTTPS on;

#Avoid sending the security headers twice

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;

}

# Adding the cache control header for js and css files

# Make sure it is BELOW the PHP block

location ~ \.(?:css|js|woff|svg|gif)$ {

try_files $uri /index.php$uri$is_args$args;

add_header Cache-Control "public, max-age=15778463";

# Add headers to serve security related headers (It is intended to

# have those duplicated to the ones above)

# Before enabling Strict-Transport-Security headers please read into

# this topic first.

# add_header Strict-Transport-Security "max-age=15768000;

# includeSubDomains; preload;";

#

# WARNING: Only add the preload option once you read about

# the consequences in https://hstspreload.org/. This option

# will add the domain to a hardcoded list that is shipped

# in all major browsers and getting removed from this list

# could take several months.

add_header X-Content-Type-Options nosniff;

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;

# Optional: Don't log access to assets

access_log off;

}

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {

try_files $uri /index.php$uri$is_args$args;

# Optional: Don't log access to other assets

access_log off;

}

}

}

让Nginx重新载入配置

nginx -s reload

初始化Nextcloud

使用域名或者IP进行访问,出现初始设置页面在这里设置Nextcloud管理员用户名和密码,然后选择使用的数据库为MySQL/MariaDB,填入之前设置数据库时的用户名(nextclouduser)、密码(nextcloudpass)、数据库名称(nextcloud_db),然后确认进行初始化后就可以使用了

开启缓存

开启内存缓存,可以提升响应速度。之前我们已经通过yum安装了redis服务,通过pecl安装了php的apcu、redis组件,下面先把redis设置为系统服务,再修改Nextcloud的配置。

安装、配置redis服务,设置服务自启、启动服务

yum -y install redis

systemctl enable redis

systemctl start redis

修改/var/www/nextcloud/config/config.php文件,在配置加入

vim /var/www/nextcloud/config/config.php

'memcache.local' => '\OC\Memcache\APCu',

'memcache.locking' => '\OC\Memcache\Redis',

'redis' => array(

'host' => 'localhost',

'port' => 6379,

),

让Nginx重新载入配置

nginx -s reload

11.一个可能遇到的无法登陆的问题

创建完成可能无法登陆,建议检查一下你的/var/lib/php目录权限,我的遇到这个问题发现是这个目录的属主属组为root,修改为nginx:nginx后就可以正常访问了。

nextcloud php 部署,CentOS7环境部署Nextcloud相关推荐

  1. CentOS7环境部署kubenetes1.12版本五部曲之四:安装dashboard

    本文是<CentOS7环境部署kubenetes1.12版本五部曲>系列的第四篇,前面的实站已经搭建了kubernetes1.12集群,操作都是在控制台用kubectl命令来完成的,今天咱 ...

  2. CentOS7环境部署kubenetes1.12版本五部曲之一:标准化机器

    前提 本次部署实战需要科学上网,才能顺利安装和部署kubernetes用于学习和实践,请确保您已经完成了相关操作: 系列文章简述 本次搭建过程由五部分实战构成: 标准化机器:kubernetes环境中 ...

  3. minio 单机安装、部署 centos7环境

    文章目录 一.默认模式下载运行 1. 下载 2. 访问minio控制台 3. 创建目录 3. 上传文件 二.企业自定义模式 2.1. 指定用户密码 2.2. 配置目录 2.3. 控制台端口 2.4. ...

  4. Atlas 200 DK开发者套件环境部署(1.0.9.alpha)极简版

    Atlas 200 DK开发者套件环境部署(1.0.9.alpha)极简版 前言 Atlas 200 DK开发者套件介绍 环境部署介绍 资源要求 开发环境部署 安装Docker 获取镜像(两种方法任选 ...

  5. ubuntu部署私人云盘nextcloud

    目录 ubuntu部署私人云盘nextcloud 一.服务器 二.安装snap 三.安装nextcloud 四.配置https 4.1 自己申请/配置证书 4.2 snap默认提供的免费证书 4.3 ...

  6. 【Mysql】_1在centos7虚拟机上完成Mysql环境部署

    步骤1:点击链接  MySQL Yum Repository  进入mysql官网,选择linux7版本下载到电脑桌面 步骤二:打开centos7虚拟机,rz  导入桌面下载的压缩包  . 步骤三:v ...

  7. 完整部署CentOS7.2+OpenStack+kvm 云平台环境(3)--为虚拟机指定固定ip

    之前在测试环境(centos7.2)上部署了openstack云平台(完整部署CentOS7.2+OpenStack+kvm 云平台环境(1)--基础环境搭建),openstack在neutron组网 ...

  8. 在CentOS7环境下部署TiDB

    在CentOS7环境下部署TiDB 一.安装CentOS系统 1. 下载CentOS系统镜像 点击这里可以前往官网下载系统镜像 2. 使用Windows自带虚拟机工具Hyper-v创建虚拟机 在程序管 ...

  9. CentOS7+ApacheServer2.4+MariaDB10.0+PHP7.0+禅道项目管理软件8.0环境部署

    CentOS7+ApacheServer2.4+MariaDB10.0+PHP7.0+禅道项目管理软件8.0环境部署 by:授客 QQ:1033553122 目录 一.         实践环境... ...

最新文章

  1. 【C++】google gtest 详解
  2. 用windows自带压缩备份mysql_Windows下配合计划任务的Mysql定时压缩备份
  3. 流程控制 - PHP手册笔记
  4. Scala,Spark和IDEA学习笔记
  5. 计算机应用英语考什么,网考计算机应用基础(本)试卷10(国外英语资料).doc
  6. 自定义ViewGroup (3) 与子View之间 Touch Event的拦截与处理
  7. 基于组织目标采用合适的敏捷方法
  8. HDU 5900(区间DP)
  9. python自动答题助手_GitHub - SmileSmith/autoAnswer: 客户端答题工具,集成3个答题助手,包含AI自动答题,手动答题,adb控制多台手机等...
  10. ppt学习-默认设置
  11. python毕业设计 基于django框架企业公司网站系统毕业设计设计与实现
  12. Linux初学者如何安装jdk,tomcat,mysql和svn
  13. canvas在PC端实现振幅大小可变的动态波浪图
  14. 计算机系统的层次结构 1,1.1 计算机系统的层次结构
  15. 查看网站的爬虫协议,简单介绍爬虫协议robots.txt,避免爬虫爬的好,牢饭吃得早(保姆级图文)
  16. GitChat·人工智能 | 肿瘤医疗影像 AI 识别技术实践
  17. Modbus RTU转MQTT网关的登录配置
  18. 半导体器件基础01:关于PN结的那些事(3)
  19. 如何在万能地图下载器中购买流量下载地图
  20. SpaceX 推出星链奖励计划,最高赏金2.5万美元

热门文章

  1. MediaInfo库的编译 使用
  2. 使用百度分享api实现网页分享功能
  3. 相似性度量方法(欧式距离等各种距离)
  4. 一、T100之料件管理
  5. 为什么很多人说现在做什么生意都不好做?
  6. PDF制作软件Adobe Acrobat及相关资源
  7. 黑莓8830 功能建介绍 图片
  8. 容器云系列之Docker容器资源隔离
  9. TPS7A8300画了一个简单的转接板
  10. PPT 、word 、pdf、 txt 格式转换