在CentOS8.2上搭建Nextcloud私人网盘

前言

Nextcloudd是一个开源的、基于本地的文件共享和协作平台,它允许您保存文件并通过多个设备(如PC、智能手机和平板电脑)访问它们。
同样的我们可以自己购买一个云服务器,部署一个属于自己的私人网盘,用来存储一些图片,文件等东西,以后需要可以从私人网盘上下载,就会比其他的例如百度网盘快很多

首先是关闭防火墙和selinux

[root@localhost ~]# systemctl enable --now firewalld
[root@localhost ~]# cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled         //改成disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

改完后重启机器

[root@localhost ~]# reboot

一条命令部署LAMP架构

[root@localhost ~]# yum install -y httpd mariadb-server php

NextCloud需要一些必需的PHP模块才能正常工作,接着安装PHP拓展包

[root@localhost ~]# yum install -y php-mysqlnd php-xml php-zip  php-curl php-gd php-intl php-json php-ldap php-mbstring php-opcache

这里不需要启动php-fpm

启动httpd、mariadb服务,并设置开机自启

[root@localhost ~]# systemctl enable --now httpd
[root@localhost ~]# systemctl enable --now mariadb

设置数据库管理员密码

[root@localhost ~]# mysqladmin -u root password 'your_password'
your_password是需要自己设置的密码

进入数据库,给Nextcloud创建数据库,并授权

[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 246
Server version: 10.3.17-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database nextcloud;
MariaDB [(none)]> creant all privileges on nextcloud.* to 'root'@'localhost';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| nextcloud          |
| performance_schema |
+--------------------+
4 rows in set (0.003 sec)
MariaDB [(none)]> exit
Bye

上传nextcloud压缩包

访问Nextcloud官网:https://nextcloud.com/install/#instructions-server

在CentOS8.2上搭建Nextcloud私人网盘

点击下载到本地

也可以使用: wget https://download.nextcloud.com/server/releases/nextcloud-19.0.3.zip 但是这种方式很慢,推荐先下载到本地,再上传到机器上

上传完成后,将文件解压缩到/var/www/html/目录下

[root@localhost ~]# unzip nextcloud-16.0.3.zip -d /var/www/html/

接着,创建一个目录来存储管理用户数据

[root@localhost ~]# mkdir -p /var/www/html/nextcloud/data

修改NextCloud的目录权限,以便Apache用户可以向其中添加数据

[root@localhost ~]# chown -R apache:apache /var/www/html/nextcloud/

到这个人网盘就搭建完成,接着访问:ip/nextcloud完成安装即可

上一篇:1.Nextcloud云盘部署(Docker环境)


下一篇:nextcloud 使用markdown editor 编辑器(xjl456852整理)