1、更换yum阿里云的源
备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载阿里云源配置
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清理缓存并生成新的缓存
yum clean all
yum makecache
2、安装docker
官方自动安装脚本
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
添加用户到docker 组
sudo usermod -aG docker root
sudo usermod -aG docker nextcloud
3、设置docker 服务自启
systemctl start docker
sudo docker run hello-world
systemctl enable docker.service
4、安装docker-compose工具
curl -L “https://github.com/docker/compose/releases/download/1.23.2/docker-compose-
(
u
n
a
m
e
−
s
)
−
(uname -s)-
(uname−s)−(uname -m)” -o /usr/local/bin/docker-compose
5、编辑docker-compose.yml文件设置镜像信息:vi docker-compose.yml
version: "2"
services:
mysql:
image: mysql
restart: always
ports:
- 13306:3306
volumes:
- /root/docker/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=nextcloud
- MYSQL_DATABASE=nextcloud
nextcloud:
image: docker.io/nextcloud
ports:
- 10080:80
links:
- mysql
volumes:
- /root/docker/nextcloud:/var/www/html
restart: always
6、更新配置
docker-compose up -d
7、启动ip访问
二、非docker 模式下 装 next cloud
1、安装Apache:
yum install httpd
systemctl start httpd
防火墙开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
浏览器输入ip 访问成功 即可
2、安装php7以上
此处用RPM获取Centos7的YUM源:
# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
or
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装PHP:
# yum -y install php70w php70w-opcache php70w-xml php70w-mcrypt php70w-gd php70w-devel php70w-mysql php70w-intl php70w-mbstring php70w-fpm
查看PHP版本验证是否安装成功:# php -v
必须7.2以上才行
3、安装mysql
设置MySQL源
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum localinstall mysql80-community-release-el7-3.noarch.rpm
安装mysql
yum install mysql-community-server
启动服务
systemctl status mysqld
设置开机自启
systemctl enable mysqld
设置初始密码
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p加初始密码
修改密码
ALTER USER 'root'@'%' IDENTIFIED BY 'TestBicon@123';
FLUSH PRIVILEGES;
使用的老的密码加密策略
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'
FLUSH PRIVILEGES;
修改默认端口
vim /etc/my.cnf
port=13306
创建数据库:
CREATE DATABASE `nextcloud` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin';
4、安装nextcloud
wget https://download.nextcloud.com/server/releases/nextcloud-21.0.0.zip
安装unzip工具:# yum install unzip
解压到指定目录下
unzip nextcloud-20.0.8.zip -d /var/www/html
授权用户组 访问权限
chown apache:apache /var/www/html
浏览器访问 ip 即可
5、配置数据目录
切记不要放在 /var/www/html下,要放在 web服务目录之外 例如单独放home或者usr下
注:php 链接 mysql8 时 需要注意在 php.ini 内规定 使用链接的加密方式 为
[Pdo_mysql]
default_authentication_plugin=mysql_native_password
否则会出现初始化时 提示 数据库账户密码错误的问题