/web 192.168.0.103/255.255.255.0(ro,no_root_squash)
EOF
--定义只192.168.0.103这台计算机可以访问
默认等于 /web *(ro,root_squash) --root_squash代表客户端以nfsnobody用户挂载
所以被挂载的/web,对nfsnobody用户也就是other位要有读权限
[root@test1 ~]# ll -d /web
drwxr-xr-x 9 root root 4096 Mar 25 16:09 /web
[root@test1 ~]# /etc/init.d/nfs restart
test3:
mkdir /web
[root@test3 ~]# showmount -e 192.168.0.101
Export list for 192.168.0.101:
/web 192.168.0.103/255.255.255.0
[root@test3 ~]# mount 192.168.0.101:/web /web
==========================================================
第二步:在test1,test3机器上都修改php.ini指向test2的MySQL数据库
vim /usr/local/lib/php.ini
mysqli.default_port = 3307
mysqli.default_socket = /var/run/mysqld/mysql5.socket
mysqli.default_host = 192.168.0.102
mysqli.default_user = root
mysqli.default_pw = 123
scp /usr/local/lib/php.ini 192.168.0.103:/usr/local/lib/php.ini
==========================================================
第三步:测试test1和test2是否能连接test3的MySQL,和在test3的MySQL上做相应的授权
test1:
[root@test1 ~]# /usr/local/mysql/bin/mysql -h 192.168.0.102 -p123 -P3307
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 5.1.36-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
test3:(连接MySQL失败) ---因为test2的MySQL没对192.168.0.103授权,所以访问遭到拒绝
[root@test3 ~]# /usr/local/mysql/bin/mysql -h 192.168.0.102 -u phpwind -p123 -P3307
ERROR 1130 (HY000): Host '192.168.0.103' is not allowed to connect to this MySQL server
test2:MySQL对test3授权
mysql> grant all on phpwind.* to 'phpwind'@'192.168.0.103' identified by '123';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
test3:(连接MySQL成功)
[root@test3 ~]# /usr/local/mysql/bin/mysql -h 192.168.0.102 -u phpwind -p123 -P3307
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.1.36-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
==========================================================
第四步:测试最终效果:输入两个ip都访问同样的内容
test1:
/etc/init.d/apache restart
test3:
/etc/init.d/apache restart
firefox http://192.168.0.103/phpwind/
firefox http://192.168.0.101/phpwind/