本文共 3861 字,大约阅读时间需要 12 分钟。
.环境
10.100.5.55 mysql nfs server dns10.100.5.56 web1 10.100.5.57 web2一.配置mysql nfs server dns1.1基本配置逻辑分区yum -y install mariadb mariadb-server mariadb-devel rpcbind nfs-utils lvm2 bind bind-utils使用逻辑分区模式
分出类型为Linux LVM sdb1 sdb2pvcreate /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/nfsmkfs.xfs /dev/vg0/mydata备注:扩展分区命令 例如加了一块盘为sdcpvcreate /dev/sdbcpvsvgextend vg0 /dev/sdclvextend --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 #改为mysqlchown -R nfsnobody.nfsnobody /var/www/ #改为nfs1.2配置数据库
systemctl start mariadb
systemctl enable mariadb #开机自启mysqlgrant all privileges on . to maxthon@'%' identified by 'maxthon';flush privileges;create database wordpress;#后续测试使用1.3 配置nfssystemctl start rpcbind
systemctl start nfssystemctl enable rpcbind
systemctl enable nfsvim /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 0scp /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.gzcp -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.zonevim 5.100.10.zone
chown root.named 5.100.10.zone c.com.zonechmod 640 5.100.10.zone c.com.zonesystemctl start named
systemctl enable named二 配置web1
2.1基本配置yum -y install httpd php php-mysql rpcbind nfs-utilssystemctl start rpcbindsystemctl enable rpcbindshowmount -e 10.100.5.55mount -t nfs 10.100.5.55:/var/www /var/www/vim/etc/fstab #设置开机自动挂载
10.100.5.55:/var/www /var/www nfs defaults 0 0vim /etc/httpd/conf/httpd.conf
注释#DocumentRoot "/var/www/html"
添加AddType application/x-httpd-php .phpAddType 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.comDocumentRoot "/var/www"ServerName www.c.comErrorLog logs/c.com-error_logCustomLog logs/c.com-access_log common#ProxyRequests Off
#ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/www/c.com/$1<Directory "/var/www" >Options nonerequire all granted</Directory></VirtualHost>systemctl start httpd
systemctl enable httpd #开机自动启动三 配置web2
yum -y install rpcbind nfs-utils httpd php php-mysqlsystemctl start rpcbindsystemctl enable rpcbindmount -t nfs 10.100.5.55:/var/www /var/www
vim/etc/fstab #设置开机自动挂载
10.100.5.55:/var/www /var/www nfs defaults 0 0vim /etc/httpd/conf/httpd.conf
#注释#DocumentRoot "/var/www/html" #添加AddType application/x-httpd-php .phpAddType 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.comDocumentRoot "/var/www"ServerName www.c.comErrorLog logs/c.com-error_logCustomLog logs/c.com-access_log common#ProxyRequests Off
#ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/www/c.com/$1<Directory "/var/www" >Options nonerequire all granted</Directory></VirtualHost>systemctl start httpdsystemctl enable httpd四 测试改dns为10.100.5.55 访问www.c.com
#连接数据库
#设置添加文件#登录 发布一篇文章#换另外一台服务器 登录
That is all.
转载于:https://blog.51cto.com/13564078/2112652