什么是NFS服务器
NFS服务器可以让PC将网络中的NFS服务器共享的目录挂载到本地端的文件系统中,而在本地端的系统中来看,那个远程主机的目录就好像是自己的一个磁盘分区一样,在使用上相当便利;
实验环境owncloud是什么
ownCloud 是一个来自 KDE 社区开发的免费软件,提供私人的 Web 服务。当前主要功能包括文件管理(内建文件分享)、音乐、日历、联系人等等,可在PC和服务器上运行。
- 两台centos7服务器,
- IP: 192.168.44.129 搭建owncloud
- IP: 192.168.44.130 搭建nfs
- 搭建nfs服务
- 把nfs服务挂载到owncloud的服务器里
- 搭建owncloud服务
- 访问服务
[root@localhost ~]# hostnamectl set-hostname nfs-server.comNFS搭虚拟机的防火墙
[root@localhost ~]# systemctl stop firewalld [root@localhost ~]# systemctl disable firewalld [root@localhost ~]# vi /etc/sysconfig/selinux SELINUX=enforcing 改为 SELINUX=disabled [root@localhost ~]# setenforce 0创建共享目录并赋予其他人写的权限
[root@localhost ~]# mkdir /nfs [root@localhost ~]# touch /nfs/1.html [root@localhost ~]# ls /nfs/ [root@localhost ~]# 1.html [root@localhost ~]# ls -ld /nfs/ [root@localhost ~]# chmod -R 777 /nfs/安装nfs软件 nfs-utils rpcbind
[root@localhost ~]# yum install -y nfs-utils rpcbind修改配置文件/etc/exports
[root@localhost ~]# vim /etc/exports /nfs 192.168.44.129(rw,no_root_squash,sync)
注:ip地址为owncloud机器的ip地址,非本机!
启动nfs服务并设置为开机自动启动服务[root@localhost ~]# systemctl start nfs-server [root@localhost ~]# systemctl enable nfs-server查看nfs进程
[root@localhost ~]# ps -elf | grep nfs配置owncloud服务器 owncloud搭虚拟机的防火墙
[root@localhost ~]# systemctl stop firewalld [root@localhost ~]# systemctl disable firewalld [root@localhost ~]# vi /etc/sysconfig/selinux SELINUX=enforcing 改为 SELINUX=disabled [root@localhost ~]# setenforce 0修改主机名
[root@localhost ~]# hostnamectl set-hostname owncloud.com安装nfs文件系统
[root@localhost ~]# yum install -y nfs-utils永久挂载共享目录
[root@localhost ~]# vim /etc/fstab 192.168.44.130:/nfs /mnt nfs defaults 0 0 mount -a //挂载查看共享目录挂在情况
[root@owncloud ~]# df -hT | grep nfs 192.168.1.10:/nfs nfs4 17G 1.9G 16G 11% /mnt验证共享文件是否成功
[root@localhost ~]# ls /mnt/ 1.html安装http、mariadb服务
[root@localhost ~]# yum install -y httpd mariadb-server mariadb启动httpd、mariadb服务,并设置成开机自启
[root@owncloud ~]# systemctl start httpd [root@owncloud ~]# systemctl enable httpd [root@owncloud ~]# systemctl start mariadb [root@owncloud ~]# systemctl enable mariadb验证http服务和mariadb服务是否启动成功
192.168.44.129
将owncloud包拖拽到 owncloud虚拟机中的/mnt目录下[root@owncloud mnt]# unzip owncloud-complete-20210326.zip 修改/mnt目录下的所有文件的属主和属组为apache [root@owncloud ~]# chown -R apache:apache /mnt/更新yum源
[root@owncloud ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm [root@owncloud ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm安装php软件包
[root@owncloud ~]# yum install -y php72w php72w-opcache php72w-xml php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring创建http虚拟主机
[root@owncloud ~]# vim /etc/httpd/conf.d/owncloud.conf检查http虚拟主机语法是否正确ServerName owncloud.linux.com DocumentRoot /mnt/owncloud ErrorLog /var/log/httpd/vedio_error.log CustomLog /var/log/httpd/vedio_access.log combined Require all granted
[root@owncloud ~]# httpd -t Syntax OK重新启动httpd服务
[root@owncloud ~]# systemctl restart httpd进入数据库
[root@owncloud ~]# mysql -uroot -p 创建owncloud库 MariaDB [(none)]> create database owncloud; Query OK, 1 row affected (0.00 sec)nfs服务器授权用户可以登录服务器
MariaDB [owncloud]> grant all on owncloud.* to own@192.168.1.10 identified by '123'; Query OK, 0 rows affected (0.00 sec) 刷新授权表 MariaDB [owncloud]> flush privileges; Query OK, 0 rows affected (0.00 sec) 退出数据库 MariaDB [owncloud]> exit Bye验证nfs-server 是否可以登录数据库 测试owncloud是否搭建成功
避坑指南在浏览器:http://192.168.44.129/index.php
访问提示 You don’t have permission to access
执行这个
[root@localhost ~]# vim /etc/sysconfig/selinux SELINUX=enforcing 改为 SELINUX=disabled [root@localhost ~]# systemctl restart httpd [root@localhost ~]# setenforce 0
原文来自:https://qu1u1.cn/archives/centos7-gua-zai-nfs-ying-pan-da-jian-owncloud-wang-pan



