This experiment is intended to practice the httpd and NFS configurations that have just been learned, enabling the use of NFS file systems to complete the storage of httpd unformatted data.
Lab Environment:
Host a 192.168.1.100 CentOS6.6 httpd server
Host B 192.168.1.101 CentOS6.6 httpd server
Host C 192.168.1.102 CentOS6.6 MySQL server
Experimental principle:
Hosts A and b are the MySQL databases that connect host C to the front-end Web server, and the blog pictures and attachments created on host A are also available on Host B:
Experimental topology:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/70/28/wKiom1Wy9qayFMpkAAGRowvt8Qk135.jpg "title=" Xfs-richie.jpg "width=" "height=" 311 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:600px;height:311px; "alt=" Wkiom1wy9qayfmpkaagrowvt8qk135.jpg "/>
Experimental Analysis:
Since both host A and B are mounted using NFS partitions, the blog program only needs to be installed once, the NFS permissions are configured, host C on the establishment of NFS server and MySQL server, provided to host A, B remote access rights can be
Experimental steps:
First, configure the MySQL server
MySQL Server (192.168.1.102):
#yum Install sql-server #chkconfig mysqld on#service mysqld Start
To create a database:
#mysql #mysql> CREATE DATABASE WordPress;
To give remote MySQL permission:
Remote access to MySQL for 192.168.1.100/101 two httpd servers
#mysql >grant all on wordpress.* to [e-mail protected] identified by ' password ', #mysql >grant all on wordpress.* to [em AIL protected] identified by ' password '; #mysql >flush privileges; #mysql >\q
To start the NFS service:
To create an NFS shared directory:
#mkdir/nfs
To configure NFS Share permissions:
#vim/etc/exports
What to modify:
/nfs 192.168.1.100 (NO_ROOT_SQUASH,RW) 192.168.1.101 (NO_ROOT_SQUASH,RW) Save exit: Wq
To start the NFS service:
#service NFS Start
To view NFS shared status:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/70/2D/wKioL1WzYh-jhQWuAABG_nGuQIQ864.jpg "title=" Qqcommend.jpg "alt=" Wkiol1wzyh-jhqwuaabg_nguqiq864.jpg "/>
You can already see the share of NFS on the 192.168.1.102.
Second, host a (192.168.1.100) configuration
Mount the NFS partition on the HTTPD server:
Create mount point Directory
#mkdir/var/www/html/wp
Temporary entry into force:
#mount-T NFS 192.168.1.102:/nfs/var/www/html/wp
Permanent after reboot:
#vim/etc/fstab
Add a line:
192.168.1.102:/nfs/var/www/html/wp NFS Defualts,_netdev 0 0
Save exit: Wq
Install httpd and PHP extensions:
#yum install-y httpd php php-mysql
Download Install wordpress blog:
#wget https://cn.wordpress.org/wordpress-4.2.2-zh_CN.tar.gz #tar XF wordpress-4.2.2-zh_cn.tar.gz-c/var/www/html/wp
Ensure that upload attachments have permission:
#chown: Apache-r wp-content/
To start the HTTPD service:
#chkconfig httpd on#service httpd start
Note: Be sure to turn off iptables and SELinux, otherwise the page cannot be displayed, that is 403 permissions issue
Effective in time:
#service iptables Stop#setenforce 0
Permanent entry into force:
#chkconfig iptables off#vim/etc/selinux/config--> Edit selinux=disabled
Third, Host B (192.168.1.101) configuration:
Mount the NFS partition:
Create mount point Directory
#mkdir/var/www/html/wp
Temporary entry into force:
#mount-T NFS 192.168.1.102:/nfs/var/www/html/wp
Permanent after reboot:
#vim/etc/fstab
Add one line: 192.168.1.102:/nfs/var/www/html/wp NFS Defualts,_netdev 0 0 Save exit: Wq
Installing httpd and PHP extensions
#yum install-y httpd php php-mysql
Start the httpd service
#chkconfig httpd on#service httpd start
Here, the experimental command section ends.
Accessing http://192.168.1.100/wp from the client browser for a simple WordPress configuration is not detailed here.
Then create a blog post on http:192.168.1.100/wp and upload an attachment:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/70/30/wKiom1WzXiSiynwnAAH0Nhy05Cw804.jpg "title=" Qq20150725175948.jpg "width=" "height=" 417 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:600PX;HEIGHT:417PX; "alt = "Wkiom1wzxisiynwnaah0nhy05cw804.jpg"/>
Then access the http://192.168.1.101/wp using the client browser
If you're lucky, you'll see the same picture:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/70/30/wKiom1WzXtPDZhcAAAKDIdkYX8A663.jpg "title=" Qqwp.jpg "width=" "height=" 408 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:600px;height:408px; "alt=" Wkiom1wzxtpdzhcaaakdidkyx8a663.jpg "/>
In fact, this use of IP access, in fact, there are some problems.
Login backstage, due to the reasons of the WordPress program, or jump to the 192.168.1.100 server management background, using DNS to create a domain name, and then add two a record points to the two servers can be achieved experimental purposes.
This article is from the "Richier" blog, make sure to keep this source http://richier.blog.51cto.com/1447532/1678325
HTTPD+NFS load Balancing experiment for basic application of NFS