LNMP搭建Nextcloud-20.0.4私有同步云盘及配置redis缓存

本文详细介绍了如何在CentOS 7.9上使用LNMP环境搭建Nextcloud 20.0.4,包括配置nginx、PHP、MariaDB,以及解决登录循环、内存限制、离线下载和添加AriaNg web界面等问题,同时设置了Redis缓存和SSL证书。
摘要由CSDN通过智能技术生成

Nextcloud是一款开源免费的私有云存储网盘项目,可以让你快速便捷地搭建一套属于自己或团队的云同步网盘,从而实现跨平台跨设备文件同步、共享、版本控制、团队协作等功能。

搭建版本:CentOS Linux release 7.9.2009 (Core)+Nextcloud-20.0.4+nginx/1.16.1+PHP 7.3.25+10.4.17-MariaDB

首先安装操作系统,我安装的是7.4的

cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

关闭防火墙和selinux
systemctl stop firewalld.service
vim /etc/selinux/config
SELINUX=disabled
setenforce 0
更新补丁

yum install epel-release -y
yum update -y

安装Nginx
yum install nginx -y
安装PHP 及PHP 依赖
安装 Yum 源管理工具
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
安装 PHP7.3

yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml php73-php-pecl-zip php73-php-pecl-imagick php73-php-phpiredis php73-php-pecl-geoip php73-php-xmlrpc php73-php-intl php73-php-common php73-php-pecl-igbinary php73-php-pecl-msgpack php73-php-process php73-php-gmp php73-runtime php73-php-pecl-redis php73-php-pecl-apcu

安装MariaDB
添加MariaDB 10.4存储库

cat >/etc/yum.repos.d/MariaDB.repo<<EOF 
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

然后更新yum缓存索引:
yum makecache fast
安装MariaDB
yum -y install MariaDB-server MariaDB-client
这里下载比较慢,如果下载失败可以打开这个网址自己下载http://yum.mariadb.org/10.4/centos7-amd64
然后放到/var/cache/yum/x86_64/7/mariadb/packages/目录下,重新执行刚刚的命令

配置数据库
初始化数据库
先启动服务
systemctl start mariadb.service

mysql_secure_installation        //按照提示设置密码,首先会询问当前密码,密码默认为空,直接回车即可
Enter current password for root (enter for none):          //直接回车
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

设置完MariaDB的密码后,使用命令行登录MariaDB,并为Nextcloud创建相应的用户和数据库

mysql -uroot -p
create database nextcloud_db; 
create user nextclouduser@localhost identified by 'nextcloudpasswd';
grant all privileges on nextcloud_db.* to nextclouduser@localhost identified by 'nextcloudpasswd';
flush privileges;

配置PHP

vim  /etc/opt/remi/php73/php-fpm.d/www.conf
在第 24 行和第 26 行,user 和 group 赋值为 nginx
user = nginx
group = nginx
取消第 396-4000 行的注释,启用 php-fpm 的系统环境变量
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

配置nginx
vim /etc/nginx/nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
   
    worker_connections 1024;
}

http {
   
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
   
        #listen       80 default_server;
        #listen       [::]:80 default_server;
        #server_name  _;
        #root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        #location / {
   
        #}

        error_page 404 /404.html;
        location = /404.html {
   
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
   
        
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值