部署Nextcloud私有云
以CentOS 7、MariaDB、PHP 7、Nginx为环境部署Nextcloud。
一、安装操作系统
首先安装操作系统,Nextcloud只支持Linux,由于个人习惯的原因,选择了CentOS 7,使用最小化安装(为了保证之后的步骤能在只有最小化安装的VPS上重现,也为了节约硬件资源)。
最小化的CentOS 7安装完毕后,默认是没有启用网卡的,在本地登录系统后,首先进入网络配置目录,列出目录中的网卡配置文件
cd /etc/sysconfig/network-scripts/
ll | grep ifcfg-
运行结果
[root@localhost network-scripts]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ll | grep ifcfg
-rw-r--r--. 1 root root 312 Aug 30 10:01 ifcfg-enp0s3
-rw-r--r--. 1 root root 254 Sep 12 2016 ifcfg-lo
除了ifcfg-lo以外的那个文件就是网卡配置文件,具体名称可能会有所不同。
然后使用vi编辑该文件,将最后一行“ONBOOT=no”改成“ONBOOT=yes”并保存退出。
通过命令重启网络服务,是配置生效
service network restart
如果不想通过DHCP动态获取IP地址,也可以在网络配置文件中添加以下配置项指定网络参数
IPADDR0=192.168.21.128 #设置IP地址
PREFIXO0=24 #设置子网掩码
GATEWAY0=192.168.21.2 #设置网关
DNS1=8.8.8.8 #设置主DNS
DNS2=8.8.4.4 #设置备DNS
网卡启用后,就可以通过SSH远程操作、通过yum方便的安装程序了。
查看ip地址,可以通过ip命令
ip addr
二、安装配置环境
1、安装基本工具
安装yum额外源、wget、unzip、gcc等基本工具
yum -y install epel-release wget unzip gcc
yum -y install libsmbclient libsmbclient-devel redis
关闭SELinux,可先通过sestatus -v命令查看SELinux是否开启
/usr/sbin/sestatus -v
修改/etc/selinux/config,将’SELINUX=enforcing’改为’SELINUX=disabled’,重启系统即可生效,或者本次可以使用’setenforce 0’临时关闭。
2、安装MariaDB
通过yum安装MariaDB
yum -y install mariadb mariadb-server
开启、启动服务,运行管理工具
systemctl enable mariadb.service
systemctl start mariadb.service
mysql_secure_installation
mysql_secure_installation的输入如下,牢记自己的数据库root密码
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
登录到mysql shell为Nextcloud创建用户和数据库。