CentOS7 安装Nextcloud17

2023-05-16

CentOS7 安装Nextcloud17

nextcloud是继承owncloud后的开源项目,并且跨各大平台,提供安卓、Mac、window、IOS等平台应用。
安装参考:docs.nextcloud.com
安装参考

0.搭建环境说明

因为计划在CentOS系统下运行多个应用,所以方案选择会有一点不同。
详细组成:

  • Nginx 1.16.1
  • MySql 5.7.27
  • Redis 5.0.6
  • PHP 7.2.23 (fpm-fcgi)
    还有就是,赋予部署用户是pi,需要自行创建该用户。

1.安装基础环境

安装基础依赖和工具。

yum install -y epel-release yum-utils unzip curl wget \
bash-completion policycoreutils-python mlocate bzip2

1.1安装MySql

安装教程:CentOS 7 安装MySql
下面建一个nextcloud数据库。

# 进入myql
mysql -u root -p

create database nextcloud;          

# 设置超强密码!!
create user nextcloud@'%' identified by '****************';

grant all privileges on nextcloud.* to nextcloud@'%' identified by '****************';

flush privileges;
quit;

1.2安装Redis

安装教程:CentOS7 安装 redis

1.3安装PHP

PHP需要集成较多的依赖,安装会比较繁琐。

#yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php72

yum -y install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql php-mbstring php-intl php-pecl-apcu php-mysqlnd php-pecl-redis php-imagick  php-fpm php-zip php-xml php-process php-pear php-pdo php-json php-devel php-xmlrpc php-soap php-ldap


# 配置PHP-FPM
vi /etc/php-fpm.d/www.conf

# 将用户和组都改为pi
user = pi                         
group = pi

# 注意:php-fpm所监听的端口为9000
listen = 127.0.0.1:9000

# 去掉下面几行注释
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp


# 增加php内存
vi /etc/php.ini
# 每个脚本可以消耗的时间,单位也是秒
max_input_time = 60

# 脚本运行最大消耗的内存
memory_limit = 4096M

# 上载文件的最大许可大小
upload_max_filesize = 4096M


# 进入缓存设置
vi /etc/php.d/10-opcache.ini
opcache.enable=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
# -------END--------

# 在/var/lib目录下为session路径创建一个新的文件夹,并将用户名和组设为nginx
mkdir -p /var/lib/php/session
chown pi:pi -R /var/lib/php/session/

重启:systemctl restart php-fpm
开机自启:systemctl enable php-fpm

1.4安装Nginx

安装教程:CentOS7 安装Nginx
配置参考:Nginx configuration

安装完nginx后,首先为Nextcloud生成自签名SSL证书,如果有就不需要自己生成,拷贝到对应目录下就好。

# 创建证书目录
mkdir -p /etc/nginx/cert

openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/1_nextcloud.kioye.cn_bundle.crt -keyout /etc/nginx/cert/2_nextcloud.kioye.cn.key
# 修改权限
chmod 700 /etc/nginx/cert
chmod 600 /etc/nginx/cert/*

配置nginx。

# 进入nextcloud.conf编辑状态
vi /etc/nginx/conf.d/nextcloud.conf

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php/php7.2-fpm.sock;
}

server {
    listen 80;
    listen [::]:80;
    server_name nextcloud.kioye.cn;
    # enforce https
    return 301 https://$server_name:443$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name nextcloud.kioye.cn;

    # Use Mozilla's guidelines for SSL/TLS settings
    # https://mozilla.github.io/server-side-tls/ssl-config-generator/
    # NOTE: some settings below might be redundant
    ssl_certificate /etc/nginx/cert/1_nextcloud.kioye.cn_bundle.crt;
    ssl_certificate_key /etc/nginx/cert/2_nextcloud.kioye.cn.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=15552000; includeSubDomains; preload;" always;
    #
    # 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 Referrer-Policy "no-referrer" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Download-Options "noopen" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Permitted-Cross-Domain-Policies "none" always;
    add_header X-Robots-Tag "none" always;
    add_header X-XSS-Protection "1; mode=block" always;

    # Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;

    # 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;

    # The following rule is only needed for the Social app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/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$request_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\/.+|oc[ms]-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;
        # Enable pretty urls
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
    }

    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        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;" always;
        #
        # 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 Referrer-Policy "no-referrer" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Download-Options "noopen" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Permitted-Cross-Domain-Policies "none" always;
        add_header X-Robots-Tag "none" always;
        add_header X-XSS-Protection "1; mode=block" always;

        # Optional: Don't log access to assets
        access_log off;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

重启:systemctl restart nginx
开机自启:systemctl enable nginx

2.安装Nextcloud

# 先下载
wget https://download.nextcloud.com/server/releases/nextcloud-17.0.0.zip
# 解压
unzip nextcloud-*.zip
# 移动到指定目录下
mv nextcloud /var/www/
# 修改权限
chown -R pi:pi /var/www/nextcloud

关闭防火墙!

# 临时关闭
setenforce 0
# 进入编辑
vi /etc/selinux/config
# 设置为禁用状态
SELINUX=disabled

# 关闭并取消开机自启
systemctl stop firewalld
systemctl disable firewalld

自行修改一下hosts文件。
访问网站:https://nextcloud.kioye.cn

在这里插入图片描述

初始化完成,查看nextcloud环境状态。

在这里插入图片描述

初始化后,添加redis缓存。

# 进入编辑状态
vi /var/www/nextcloud/config/config.php
# 添加如下内容
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'memcache.local' => '\OC\Memcache\APCu',
  'redis' => array(
    'host' => 'localhost',
    'port' => 6379,
    'password' => '1234',
    'database' => 15,
  ),

安装smbclient扩展模块

yum -y install libsmbclient libsmbclient-devel php-smbclient
pecl install smbclient

3.集成onlyoffice

onlyOffice服务使用docker安装。所以需要提前安装好docker环境。
docker环境安装: CentOS7下安装docker
nextcloud下的onlyoffice插件:ONLYOFFICE
onlyoffice的GitHub:onlyoffice docker


# 下载onlyffice插件
wget https://github.com/ONLYOFFICE/onlyoffice-nextcloud/releases/download/v3.0.2/onlyoffice.tar.gz

# 解压
tar zxvf onlyoffice.tar.gz
# 移动到apps下
mv onlyoffice /var/www/nextcloud/apps/
# 赋权
chown -R pi:pi /var/www/nextcloud/apps/onlyoffice

# 创建密钥
mkdir -p /home/pi/onlyoffice/certs

chown -R pi:pi /home/pi/onlyoffice
chmod 700 /home/pi/onlyoffice
chmod 600 /home/pi/onlyoffice/*

# 后台运行
#docker run -i -t -d -p 9300:80 onlyoffice/documentserver
docker run -i -t -d -p 9300:443 -v /home/pi/onlyoffice/:/var/www/onlyoffice/Data  onlyoffice/documentserver

# 启动正常后,设置开机自启容器

docker update --restart=always xxx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

CentOS7 安装Nextcloud17 的相关文章

  • Centos7安装使用Docker

    Centos7安装使用Docker 系统环境与软件版本说明 名称 详情 系统环境 CentOS Linux release 7 5 1804 Core Docker docker ce 18 06 1 ce 3 el7 Docker安装 官
  • Download-centos7-repo

    Setup Local Yum Repository On CentOS 7 使用ftp和createrepo来构建iso中的rpm包源 install and cache rpm package cat etc yum conf more
  • CentOS7 安装Redis6过程详解

    CentOS7 安装Redis6过程详解 一 安装redis 1 下载Redis 2 解压 3 使用make编译 4 编译完成后在目录中执行make install安装redis服务 5 安装完成 二 设置redis后台运行以及远程连接 1
  • 记一次centos7 下根目录扩容操作(步骤详细!!!)

    文章目录 需求描述 具体步骤 查看本机磁盘环境 添加磁盘分区 开始扩容 同步到文件系统 参考内容 需求描述 由于测试环境需要 虚拟机根目录需要扩容至120G 具体步骤 查看本机磁盘环境 root localhost df h 文件系统 容量
  • CentOS7修改SSH端口

    CentOS7 修改SSH端口 文章目录 CentOS7 修改SSH端口 1 修改ssh配置文件 1 1 查看默认端口 1 2 修改端口 2 防火墙放行 2 1 查看防火墙状态 2 2 防火墙放行端口 202 2 3 查看已开启端口 2 4
  • KVM热迁移

    KVM热迁移 介绍 KVM热迁移的前提是拥有共享存储 以下通过NFS实现KVM热迁移 迁移过程 将一处于运行状态的KVM虚拟机从节点kvm 01迁移到kvm 02后继续运行 准备 主机准备 hostname IP地址 系统 配置 kvm 0
  • InnoDB:错误:空间标头页由数据文件 ./ibdata1 中的零字节组成

    我的 WordPress 设置非常好 但今天服务器突然停止加载我的网站 我登录并重新启动我的 centos 7 VPS 重启后没有启动MariaDB 这是我在日志中发现的内容 141026 18 13 50 Note usr libexec
  • xinetd 服务调用 python 脚本(无法正确执行)

    我读到了这个 您可以使用 xinetd 添加启动 python 脚本的服务 标准输入和输出将通过网络在所需端口上传输 因此您不需要修改脚本 input raw input 和 print 方法可以正常工作 因此 当建立到 192 168 2
  • CentOS 7 上 Ambari 2.7.5 安装失败

    我正在 CentOS 7 计算机上安装 Apache Ambari 2 7 5 我正在关注Apache 网站上的安装指南 指南第 1 步的最后一个命令 mvn B 全新安装 rpm rpm DnewVersion 2 7 5 0 0 Dbu
  • 具有多个位置指令和子域的 nginx

    我正在尝试在 nginxconf 中实现类似的东西 子域 sub domain com gt 提供 html sub domain com api gt 代理到端口 3001 sub domain com viewer gt 提供另一个 h
  • 无法获得 D-Bus 连接:不允许操作

    我正在尝试在 docker centos7 映像上安装 ambari 2 6 但在 ambari 设置步骤中以及在初始化 postgresql 数据库时 我收到此错误 无法获得 D Bus 连接 不允许操作 每次我尝试在 Docker 映像
  • 我无法启动服务器 PostgreSQL 11:“pg_ctl:无法启动服务器”

    我使用的是 CentOS Linux 版本 7 5 1804 核心 当我登录时postgres并运行 bash 4 2 usr pgsql 11 bin initdb D var lib pgsql 11 data The files be
  • Javascript 无效或意外的标记 (\u0)

    正如您将在图像中看到的那样 有许多红点 显然每个红点都标识为 u0 文件内容或编辑器没有区别 正在编译或未编译的 JS 文件没有区别 事实上 由于空格和换行符 在非缩小版本中会出现更多红点 甚至加载一个空白文件 然后添加一些简单的内容 如
  • Centos 7 - openjdk8 的 jfx 库在哪里?

    我有centos 7 1 我安装了openjdk8和openjdk devel8 但是 当我尝试在 netbeans 中编译我的 jfx 应用程序时 我得到包 javafx 不存在 经过一番调查 我发现jdk中没有jfxrt jar 除了
  • 无法安装 phpMyAdmin 错误:php71w-common 与 php-common-5.4.16-43.el7_4.1.x86_64 冲突

    我刚刚安装了 CentOS 7 和 PHP 7 1xx 和 MySQL 但无法安装 phpMyAdmin 我有一条错误消息 但在 Google 上没有答案 是的 只有一个答案 但它本身给了我相同的错误消息 rpm iUvh http dl
  • 如何在 centos 7 上链接 python3 以使用 openssl11/或最新版本的 openssl (1.1.1)

    我们想在centos 7中升级OpenSSL但没有成功 原因可能是这样的 通过 yum install openssl11 将 CentOS 7 升级到 OpenSSL 1 1 1 https stackoverflow com quest
  • Centos 7 Postgres 服务的环境变量

    最近我遇到了使用自定义 PGDATA 路径启动 postgresql 服务的问题 它尝试查找未初始化的默认数据目录 var lib pgsql 9 3 data 因此触发了这些错误 问题似乎是 Centos 7 上的服务启动器删除了所有环境
  • 无法在 CentOS 7 上启动 postgresql 服务

    无法在 CentOS 7 上启动 postgresql 9 5 我关注了这个页面 https wiki postgresql org wiki YUM Installation https wiki postgresql org wiki
  • Dotnet 构建失败:Linux 中的代理背后的 NuGet

    这看起来可能是一个类似的issue https stackoverflow com questions 9232160 nuget behind a proxy但在 CentOS 上 我已经尝试过此线程以及其他线程上的所有解决方案 但是我仍
  • psql:符号查找错误:psql:未定义符号:PQsetErrorContextVisibility

    我将 postgres 版本从 9 2 24 切换到 9 6 因为我需要 jsonb 兼容性以及其他最新功能 我在 centos 7 上运行虚拟机 我决定擦除所有现有的 postgres 实例 因为它是临时的 所以几乎是空的 然后安装了 9

随机推荐