1. Experimental Requirements:
1) NFS Server Export/data/application/web, in the directory to provide WordPress;
(2) NFS Client Mounts NFS Server exported file system to/var/www/html;
(3) the client (lamp) to deploy WordPress, and let its normal access, to ensure that the normal post, upload pictures;
(4) Client 2 (lamp), Mount NFS server exported file system to/var/www/html, check that its WordPress can be accessed, to ensure that the normal post, upload pictures;
2. Experimental environment:
1) Server Environment
Linux Server OS version: CentOS release 6.7 (Final)
DNS) ip:172.16.66.50
Lamp) ip:172.16.66.60
Lamp) ip:172.16.66.70
NFS) ip:172.16.66.80
2) test environment
WIN7 system client): ip:172.16.66.100
3, the experimental premise:
1) Turn off firewall and SELinux
~]# Service Iptables Stop
~]# sed-i s/selinux=enforcing/selinux=disabled/g/etc/selinux/config
4, the experimental process:
The first part:
Deploying Hosts ip:172.16.66.50
1. Install the DNS server
1.1 Installing the DNS service side
# yum Install Bind-y
1.2 Editing the Master profile/etc/named.conf
Options {
Listen-on Port 53 {172.16.66.50;};
allow-query {localhost;};
Dnssec-enable No;
Dnssec-validation No;
1.3 Edit/etc/named.rfc1912.zones
# sed-n ' 43,46p '/etc/named.rfc1912.zones
Zone "Yang.com" in {
Type master;
File "Yang.com.zone";
};
1.4 Create the corresponding zone resolution library file (the primary record is a or AAAA record) forward
# Cat/var/named/yang.com.zone
$TTL 3600
@ in SOA ns1.yang.com. Dnsadmin.yang.com. (
20160721
1D
10M
3H
)
In NS ns1
NS1 in A 172.16.66.50
www in A 172.16.66.60
WWW1 in CNAME www
www in A 172.16.66.70
WWW2 in CNAME www
1.5 Checking the configuration file for errors
# named-checkconf
1.6 Check the Zone resolution library for errors
# Named-checkzone Yang.com/var/named/yang.com.zone
1.7 Modifying a newly created Zone resolution library file group, owner, and permission
# CHGRP Named/var/named/yang.com.zone
# chmod o=/var/named/yang.com.zone
1.8 Setting named Boot and start service
# chkconfig named on
# Service named start
# Ss-ntl
2 Testing DNS
2.1 Test a record on the primary domain machine:
# dig-t A www.yang.com @172.16.66.50
Part II:
Deploying Hosts ip:172.16.66.60
1 Basic settings
1.1 Set HTTPD host name HOSTNAME
echo "HOSTNAME=LAMP1" >>/etc/sysconfig/network
1.2 Updating the HOSTS configuration file/etc/hosts
# echo "172.16.66.60 www1 www2" >>/etc/hosts
1.3 Creating a Software tools Catalog
# Mkdir/tools
1.4 Adding a DNS configuration file/etc/
# servicename 172.16.66.50
2. Installing the LAMP1 Environment
2.1 Yum Pack installation amp
#yum Install httpd php php-mysql mariadb mariadb-server-y
2.2 Check whether the package is installed successfully
# rpm-qa httpd php php-mysql mariadb mariadb-server
2.3 Starting the Service
# Systemctl Start httpd
# Systemctl Start mariadb
2.4 See if the service starts properly
# SS-NLT
# PS aux | grep httpd
# PS aux |grep myslq
2.5 Set Boot auto start
# Systemctl Enable httpd
# Systemctl Enable MARIADB
2.6 Check whether it is set to boot from start
# Systemctl is-enabled httpd
# Systemctl is-enabled mariadb
2.7 Creating a configuration file backup directory
# Mkdri ~/confbak
2.8 Backing up the configuration file to the specified directory
# cp-r/etc/httpd/* ~/confbak/
2.9 A virtual host provides/etc/httpd/conf.d/www1.conf
<virtualhost 172.16.66.60:80>
Servername WWW1
Documentroot/data/vhosts/www1
Errorlog Logs/www1-error_log
Customlog Logs/www1-access_log Combiend
<directory "/DATA/VHOSTS/WWW1" >
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
3. Create and configure a database
3.1 Logging into the database
~]# mysql-uroot-p
3.2 Create a database for Bolg named: WordPress
MariaDB [(None)]> CREATE DATABASE WordPress;
3.3 Check whether the database was created successfully
MariaDB [(None)]> SHOW DATABASES;
3.4 Authorized users, create accounts and passwords;
MariaDB [(None)]> GRANT all on wordpress.* to [e-mail protected] ' 172.16.%.% ' identified by ' Liyang ';
Query OK, 0 rows Affected (0.00 sec)
4. Mount Server for NFS
4.1 Client mount (temporary mount)
# mount-t NFS 172.16.66.80:/data/application/web/var/www/html/
4.2 Viewing Mounts
# df-th
4.3 Boot auto mount
echo "Mount-t NFS 172.16.66.80:/data/application/web/var/www/html/" >>/ETC/RC.D/INIT.D
Part III:
Deploying Hosts ip:172.16.66.70
1 Basic settings
1.1 Set HTTPD host name HOSTNAME
echo "HOSTNAME=LAMP1" >>/etc/sysconfig/network
1.2 Creating a Software tools Catalog
# Mkdir/tools
1.3 Adding a DNS configuration file/etc/
# servicename 172.16.66.50
2. Installing the AP2 Environment
2.1 Yum Package Installation AP
#yum Install httpd php php-mysql-y
2.2 Check whether the package is installed successfully
# Rpm-qa httpd php php-mysql
2.3 Starting the Service
# Systemctl Start httpd
2.4 See if the service starts properly
# SS-NLT
# PS aux | grep httpd
2.5 Set Boot auto start
# Systemctl Enable httpd
2.6 Check whether it is set to boot from start
# Systemctl is-enabled httpd
2.7 Creating a configuration file backup directory
# Mkdri ~/confbak
2.8 Backing up the configuration file to the specified directory
# cp-r/etc/httpd/* ~/confbak/
2.9 A virtual host provides/etc/httpd/conf.d/www2.conf
<virtualhost 172.16.66.70:80>
Servername WWW1
Documentroot/data/vhosts/www1
Errorlog Logs/www2-error_log
Customlog Logs/www2-access_log Combiend
<directory "/DATA/VHOSTS/WWW1" >
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
3. Mount Server for NFS
3.1 Client mount (temporary mount)
# mount-t NFS 172.16.66.80:/data/application/web/var/www/html/
3.2 Viewing Mounts
# df-th
3.3 Boot Auto Mount
echo "Mount-t NFS 172.16.66.80:/data/application/web/var/www/html/" >>/ETC/RC.D/INIT.D
Part II
Deploying Hosts ip:172.16.66.80
1. Build Server for NFS
1.1 Creating an NSF shared directory
# MKDIR/DATA/APPLICATION/WEB-PV
1.2 Creating users-note: NFS client and service-side IDs are consistent
# useradd-r-U Cetnos
1.3 Setting up a shared directory owner and owner group
# setfacl-m U:cetnos:rwx/data/application/web
1.4 Creating an NFS share/etc/exports
/data/application/web 172.16.0.0/16 (Rw,async,no_root_squash)
1.4 View shared NFS shares
# SHOWMOUNT-E
2. Deploy the Site Directory WordPress
2.1 Unpacking the WordPress package
tools]# Unzip Wordpress-4.3.1-zh_cn.zip
2.2 Copy to NFS shared directory
# CP Wordpress/data/application/web
2.3 Renaming the WordPress config file for wp-config.php
]# CP wp-config-sample.php wp-config.php
2.4 Modifying the wp-config.php File connection database
~]# sed-n ' 22,38p '/data/vhosts/www1/wordpress/wp-config.php
/** Name of WordPress database */
Define (' db_name ', ' WordPress ');
/** MySQL Database user name */
Define (' Db_user ', ' admin ');
/** MySQL Database password */
Define (' Db_password ', ' admin ');
/** MySQL Host */
Define (' Db_host ', ' 172.16.66.80 ');
/** The default text encoding when creating data tables */
Define (' Db_charset ', ' UTF8 ');
/** the database collation type. If you are unsure do not change */
Define (' db_collate ', ');
Fifth part
1. Testing
1.1 Access a host: 172.16.66.60
http://www.yang.com/wordpress/index.php
1.2 Access to Host B: 172.16.66.70
http://www.yang.com/wordpress/index.php
1.3 can be accessed normally, can upload pictures and send articles!! ---experiment is complete.
This article is from the "8752057" blog, please be sure to keep this source http://yang90.blog.51cto.com/8752057/1828694
Lamp+nfs Load Balancing