一、安装系统&配置网络

·首先安装CentOS 7 64位系统
·安装时选择最小华安装
·系统安装完成后查询网卡信息

IP ADDR

·查询到网卡信息为eno1
·进入网卡配置目录配置网络信息

cd /etc/sysconfig/network-scripts/
vi ifcfg-eno1

·打开配置文件后更改并增加以下内容

BOOTPROTO=static  #dhcp改为static启用静态IP地址
ONBOOT=no  #将no改为yes
IPADDR=192.168.1.21  #设置IP地址
PREFIXO=24  #设置子网掩码
GATEWAY=192.168.1.1  #设置网关
DNS1=8.8.8.8  #设置主DNS
DNS2=8.8.4.4  #设置备DNS

·esc退出编辑模式,:wq 保存
·启动网卡

ifup eno1

·重启网卡

service network restart

·可以尝试ping www.baidu.com 验证网络

二、配置LNAP 运行环境

1、使用yum命令安装基本工具 wget unzip gcc

yum -y install epel-release wget unzip gcc

安装完成后需要关闭SElinux
可先通过sestatus -v命令查看SELinux是否开启

/usr/sbin/sestatus -v

修改/etc/selinux/config,将’SELINUX=enforcing’改为’SELINUX=disabled’,保存重启系统即可生效,或者本次可以使用’setenforce 0’临时关闭,建议直接关闭。

2、安装Nginx

yum -y install epel-release
yum -y install nginx
mkdir /var/www
chown -R nginx:nginx /var/www

创建nextcloud数据目录

mkdir /data/nextcloud/data
chown -R nginx:nginx /data/nextcloud/data

开启、启动Nginx服务

systemctl enable nginx.service
systemctl start nginx.service

小提示:使用nginx -s reload可以重载配置而不需要重启nginx

开放防火墙HTTP、HTTPS端口

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
systemctl restart firewalld

2、安装PHP7
添加PHP7-FPM webtatic仓库,安装php7主体以及nextcloud需要的一些模块。

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php71w-fpm php71w-cli php71w-gd php71w-mcrypt php71w-mysql php71w-pear php71w-xml php71w-mbstring php71w-pdo php71w-json php71w-opcache php71w-pecl-apcu php71w-pecl-apcu-devel php71w-pecl-igbinary php71w-pecl-igbinary-devel php71w-pecl-imagick php71w-pecl-imagick-devel php71w-pecl-redis php71w-pecl-redis-devel
vi /etc/php-fpm.d/www.conf

PHP7 安装完成后,编辑/etc/php-fpm.d/www.conf

vi /etc/php-fpm.d/www.conf
;在第 8 行和第 10行,user 和 group 赋值为 nginx。
user = nginx
group = nginx;在第 22 行,确保 php-fpm 运行在指定端口。
listen = 127.0.0.1:9000;取消第 366-370 行的注释,启用 php-fpm 的系统环境变量。
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/

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

vi /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

3、安装MariaDB
通过yum安装MariaDB

yum -y install mariadb mariadb-server

开启、启动服务,

systemctl enable mariadb.service
systemctl start mariadb.service

运行管理工具

mysql_secure_installation

mysql_secure_installation输入后,直接确认,出现是否设置密码,输入y,开始设置root的密码,并牢记自己的数据库root密码。

Set root password? [Y/n] Y
New password:
Re-enter new password:Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

下面开始为nextcloud创建数据库及用户,先登录数据库

mysql -u root -p

验证密码正确后会登录到mysql shell命令行,输入以下命令创建数据库及用户。

create database nextcloud_db;
create user nextclouduser@localhost identified by 'nextclouduser@';
grant all privileges on nextcloud_db.* to nextclouduser@localhost identified by 'nextclouduser@';
flush privileges;
exit

创建信息如下
数据库:nextcloud_db
用户:nextclouduse
密码:为nextclouduser@

三、下载安装及配置nextcloud程序

1、下载nextcloud并解压到www目录

wget https://download.nextcloud.com/server/releases/nextcloud-12.0.4.zip
unzip nextcloud-12.0.2.zip
mv nextcloud /var/www/
chown -R nginx:nginx /var/www

2、生成自签名SSL证书

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/*

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

#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 httpsreturn 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 installationroot /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 sizeclient_max_body_size 512M;fastcgi_buffers 64 4K;# Enable gzip but do not remove ETag headersgzip 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 twicefastcgi_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 blocklocation ~ \.(?: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 assetsaccess_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 assetsaccess_log off;}}}

让Nginx重新载入配置

nginx -s reload

4、初始化

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

5、添加信任域名
Nextcloud本身的安全机制,会检查访问的域名,如果没有配置在信任域名中,会提示正在通过不信任的域名访问。

Nextcloud初始化完毕后,会生成“/var/www/nextcloud/config/config.php”配置文件,里面的’trusted_domains’配置项为信任域名,初始化完毕后只有一项,为主机的IP地址。可以修改该配置项,添加绑定的域名。

'trusted_domains' =>
array (0 => '192.168.56.101',1 => 'yourname.domain',
),

6、安装并开启内存Redis缓存

开启内存缓存,可以提升响应速度。之前我们已经通过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文件,在配置加入以下内容

vi /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

至此nextcloud安装全部完成。

CentOS7 配置nextcloud相关推荐

  1. CentOS7部署nextcloud最新版本

    Nextcloud 是一个免费专业的私有云存储网盘「开源」项目,Nextcloud开发人员来自owncloud.Nextcloud 跨平台支持 Windows.Mac.Android.iOS.Linu ...

  2. 1vmware中的centos7配置静态变量

    vmware中的centos7配置静态变量 安装centos7时推荐最小化安装,避免占用过多资源 问题: 解决虚机中的Centos7连不上网 https://blog.csdn.net/u014271 ...

  3. 阿里云 centos7 配置SSH 从无到有

    阿里云 Centos7 Linux服务器配置SSH: 注意:centOS 6和centOS7的重启ssh指令不一样. 首先,我们搜索一下CentOS的软件库里面有没有已经定义好的SSH服务器包. 重要 ...

  4. linux7配置静态地址,Centos7 配置静态 IP 地址的方法

    Centos7 配置静态 IP 地址的方法 一, 不使用网络管理器 nmcli 配置静态 IP 地址的方法 进入 / etc/sysconfig/network-scripts 目录, 找到该接口的配 ...

  5. centos7配置IP地址CentOS7 修改hostname,ip地址以及hosts(永久生效)

    CentOS7 修改hostname,ip地址以及hosts(永久生效) https://blog.csdn.net/ntuxiaolei/article/details/81130866 在局域网内 ...

  6. Centos7配置Samba服务实现与Windows文件共享

    一.安装samba软件包 yum insatll samba -y 二.关闭selinux和防火墙,开启samba服务,开机启动samba服务 setenforce 0 sed -i 's/SELIN ...

  7. 如何在Centos7配置ssh/rsh免密互信集群服务

    导读 分享如何在Centos7配置ssh/rsh免密互信集群服务 ssh免密互信操作 一.在SSH服务器所在机器上 1.以root用户登录,更改ssh配置文件 /etc/ssh/sshd_config ...

  8. 服务器(CentOS7)配置R以及R Studio Server

    服务器(CentOS7)配置R以及R Studio Server 本文主要介绍了利用服务器(系统Centos7)远程配置R以及R Studio Server. 在介绍之前废话几句,想告诉看到本文的朋友 ...

  9. Centos7 配置netatalk搭建mac Time Machine

    Centos7 配置netatalk搭建mac Time Machine mac的Time Machine是一个备份的功能,他会增量的为我们备份系统,如果你的mac丢失了或者是进水了(彻底死亡)这是你 ...

最新文章

  1. AI时代,为何机器人公司无法盈利只能走向倒闭?
  2. 取代人类医生?AI给你做的诊断你敢信吗
  3. 从技术岗位走向管理岗位:机会是留给有准备的人
  4. mysql登录root 1130_通过Navicat for MySQL远程连接的时候报错mysql 1130的解决方法
  5. Go基础编程:工作区
  6. 易支付v5.8个人二维码免签系统破解版
  7. mpa和pis_有关压力单位pis、bar与Mpa换算
  8. 1 10000以内的质数表C语言,求1万以内的质数表,有急用
  9. 2021春考计算机技能考什么,春季高考技能考试-信息技术类专业考试样题
  10. scannable dest type struct with >1 columns (3) in result
  11. React中使用worker线程
  12. 华易记账宝 v6.5
  13. redis的三大模式主从,哨兵和集群
  14. HikariCP配置max-lifetime
  15. [Constraints 18-5210] No constraints selected for write.
  16. leetcode189 python旋转数组
  17. 4.15 最短路 题
  18. Android解决部分手机拍照照片自动旋转的问题
  19. Ubuntu 如何更换内核
  20. 21英里法则_一英里的跑道将带您到任何地方

热门文章

  1. 内部RAID 0:OCZ将推廉价高速固态硬盘
  2. matlab如何打开历史纪录,Matlab创建有价值历史纪录(完整版)
  3. echarts 区域缩放
  4. JAVA多线程设计模式篇 7、Read-Write Lock 模式——霸气侧漏的写,唯唯诺诺的读
  5. JZOJ3296. 【SDOI2013】刺客信条
  6. SPSS 简单效应检验
  7. ifcfg-eth0文件参数PREFIX 和 NETMASK的配置不一致问题
  8. 《爱在 ZStack Cube 超融合》三部曲
  9. 模仿360水晶球的效果
  10. python:json转excel