使用逻辑分区模式
分出类型为Linux LVM sdb1 sdb2
pvcreate /dev/sdb{1,2}
vgcreate vg0 /dev/sdb{1,2}
lvcreate -L 20G -n nfs vg0 #nfs 逻辑卷
lvcreate -L 19G -n mydata vg0 #mydata逻辑卷
mkfs.xfs /dev/vg0/nfs
mkfs.xfs /dev/vg0/mydata
备注:扩展分区命令 例如加了一块盘为sdc
pvcreate /dev/sdbc
pvs
vgextend vg0 /dev/sdc
lvextend --resize -L +60G /dev/vg0/nfs将逻辑卷/dev/vg0/nfs增大60G。然后执行df -lh查看 /var/www/目录空间是否增大.
mount /dev/vg0/mydata /var/lib/mysql/
mount /dev/vg0/nfs /var/www/
chown mysql.mysql /var/lib/mysql #改为mysql
chown -R nfsnobody.nfsnobody /var/www/ #改为nfs
1.2配置数据库
systemctl start mariadb
systemctl enable mariadb #开机自启
mysql
grant all privileges on . to maxthon@‘%‘ identified by ‘maxthon‘;
flush privileges;
create database wordpress;#后续测试使用
1.3 配置nfs
systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind
systemctl enable nfs
vim /etc/exports #添加挂载分区
/var/www 10.100.0.0/16(rw,sync,root_squash)
exportfs -ra #重新加载
showmount -e localhost #查看是否已经挂载
vim/etc/fstab #添加自动挂载
/dev/vg0/mydata /var/lib/mysql xfs defaults 0 0
/dev/vg0/nfs /var/www xfs defaults 0 0
scp /Users/macos/Desktop/study/LAMP/论坛源码/wordpress-4.9.4-zh_CN.tar.gz root@10.100.5.55:/root #拷贝wordpress
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz
cp -r wordpress/* /var/www/
1.4.配置dns
vim/etc/named.conf
#listen-on port 53 { 127.0.0.1; };
#listen-on-v6 port 53 { ::1; };
allow-query { any; };
vim /etc/named.rfc1912.zones #尾部插入
zone "c.com" IN {
type master;
file "c.com.zone";
allow-update { none; };
};
zone "5.100.10.in-addr.arpa" IN {
type master;
file "5.100.10.zone";
allow-update { none; };
};
cd/var/named
vim c.com.zone
vim 5.100.10.zone
chown root.named 5.100.10.zone c.com.zone
chmod 640 5.100.10.zone c.com.zone
systemctl start named
systemctl enable named
二 配置web1
2.1基本配置
yum -y install httpd php php-mysql rpcbind nfs-utils
systemctl start rpcbind
systemctl enable rpcbind
showmount -e 10.100.5.55
mount -t nfs 10.100.5.55:/var/www /var/www/
vim/etc/fstab #设置开机自动挂载
10.100.5.55:/var/www /var/www nfs defaults 0 0
vim /etc/httpd/conf/httpd.conf
注释#DocumentRoot "/var/www/html"
添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php #添加index.php
</IfModule>
vim /etc/httpd/conf.d/c.com.conf #添加虚拟主机配置文件
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/var/www"
ServerName www.c.com
ErrorLog logs/c.com-error_log
CustomLog logs/c.com-access_log common
#ProxyRequests Off
#ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/www/c.com/$1
<Directory "/var/www" >
Options none
require all granted
</Directory>
</VirtualHost>
systemctl start httpd
systemctl enable httpd #开机自动启动
三 配置web2
yum -y install rpcbind nfs-utils httpd php php-mysql
systemctl start rpcbind
systemctl enable rpcbind
mount -t nfs 10.100.5.55:/var/www /var/www
vim/etc/fstab #设置开机自动挂载
10.100.5.55:/var/www /var/www nfs defaults 0 0
vim /etc/httpd/conf/httpd.conf
#注释#DocumentRoot "/var/www/html"
#添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php #添加index.php
</IfModule>
vim /etc/httpd/conf.d/c.com.conf #添加虚拟主机配置文件
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/var/www"
ServerName www.c.com
ErrorLog logs/c.com-error_log
CustomLog logs/c.com-access_log common
#ProxyRequests Off
#ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/www/c.com/$1
<Directory "/var/www" >
Options none
require all granted
</Directory>
</VirtualHost>
systemctl start httpd
systemctl enable httpd
四 测试
改dns为10.100.5.55 访问www.c.com
#连接数据库
#设置添加文件
#登录 发布一篇文章
#换另外一台服务器 登录
That is all.
原文:http://blog.51cto.com/13564078/2112652