实验目的:通过NFS实现共享
实验要求:实验环境下防火墙以及selinux都是要关闭的!!!
实验环境:三台虚拟机,以及相关安装程序
实验过程:
设置服务端centos 6-1
[root@centos6 ~]# yum install mysql-server
nfs-utils httpd
[root@centos6 ~]# service mysqld start #启动sql
[root@centos6 ~]# mysql mysql> create
database wpdb;
mysql> grant all on wpdb.* to
‘wpuser’@’172.18.24.1’ identified by ‘wppass’;
mysql> grant all on wpdb.* to
‘wpuser’@’172.18.24.3’ identified by ‘wppass’;
[root@centos6 ~]# mkdir /data/wpdata
[root@centos6 ~]# mkdir /data/mydata
[root@centos6 ~]#useradd -r -M -u 1002
wp1_mysql
[root@centos6 ~]#useradd -r -M -u 1003 wp1_web
[root@centos6~]# cd /data/wpdata
[root@centos6wpdata]# wget
ftp://172.18.0.1/pub/Sources/sources/httpd/wordpress-4.3.1-zh_CN.zip
[root@centos6 wpdata]# unzip
wordpress-4.3.1-zh_CN.zip
[root@centos6 wpdata]# chown -R wp1_web.
wp1_web /data/wpdata/
[root@centos6 ~]# vim /etc/exports
/data/wpdata 172.18.0.0/16(rw,all_squash,anonuid=1003,anongid=1003)
/data/mydata
172.18.0.0/16(rw,all_squash,anonuid=1002,anongid=1002)
[root@centos6 ~]# service nfs start
设置客户端1 centos7
[root@centos7 ~]# yum install nfs-utils
httpd php php-mysql
[root@centos7 ~]#useradd -r -M -u 1002
mysql
[root@centos7 ~]#useradd -r -M -u 1003 web
开机挂载
[root@centos7 ~]# vim /etc/fstab
172.18.24.1:/data/wpdata /var/www/html nfs defaults 0 0
临时挂载
[root@centos7 ~]# mkdir /data/mydata
[root@centos7 ~]# mount -t nfs 172.18.24.2:/data/mydata
/data/mydata/ 挂载共享目录
[root@centos7 ~]#mount -t nfs 172.18.24.2:/data/wpdata
/var/www/html/
#挂载到/var/www/html/
[root@centos7 ~]# systemctl start httpd
使用浏览器访问http://172.18.24.1安装wordpress,安装完成测试发表文章和上传图片功能。
设置客户端2 centos6-2
[root@centos6 ~]# yum install nfs-utils
httpd php php-mysql
开机挂载
[root@centos6 ~]# vim /etc/fstab
172.18.99.20:/data/wordpress /var/www/html
nfs defaults 0 0
临时挂载
[root@centos6~]#mount -t nfs 172.18.24.2:/data/wpdata
/var/www/html/
#挂载到/var/www/html/
[root@centos6 ~]# service httpd start
图解:
原创文章,作者:chenxu@magedu.com,如若转载,请注明出处:http://www.178linux.com/74719