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 {