lnmp的mysql分离_搭建lnmp实现动静分离

LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。

(nginx主机)web处理静态内容 172.16.250.149

(fpm server   mariad bserver)处理动态内容 172.16.253.131

以上为两台CentOS7.3主机

试验拓扑图如下:

3c8ce6380daa33c267ccb0e2e66a02de.png

===========================================================================

(fpm server   mariad bserver) 172.16.253.131

#yum install php-fpm php-mysql php-mbstring php-mcrypt mariadb-server -y

下载phpMyAdmin-4.0.10.20-all-languages.tar.gz

#vim /etc/php-fpm.d/www.conf

listen = 0.0.0.0:9000

;listen.allowed_clients = 127.0.0.1

pm.max_children = 150

pm.status_path = /status

ping.path = /ping

#mkdir /var/lib/php/session

#chown apache:apache /var/lib/php/session

#systemctl start php-fpm.service

#ss -tnl | grep "9000"

LISTEN 0 128 *:9000 *:*

#mkdir /data/apps -pv

#vim /data/apps/index.php #定义后端主页

phpinfo();

?>

===========================================================================

(nginx主机)172.16.250.149

#vim /etc/nginx/conf.d/ilinux.conf

3c8ce6380daa33c267ccb0e2e66a02de.png

#vim /data/nginx/html/index.html #nginx server主页

Nginx server

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

===========================================================================

(fpm server   mariad bserver) 172.16.253.131

#vim /etc/my.cnf.d/server.cnf

关闭地址解析

3c8ce6380daa33c267ccb0e2e66a02de.png

#systemctl start mariadb.service

#ss -tnl | grep "3306"

LISTEN 0 50 *:3306 *:*

#mysql_secure_installation

Set root password? [Y/n] y #是否设置密码

New password: #输入要设置的密码

Re-enter new password:

Remove anonymous users? [Y/n] y #是否删除匿名用户

Disallow root login remotely? [Y/n]n #是否禁止管理员远程登录(为了试验方便,设置成不要,生成中禁止远程登录)

Remove test database and access to it? [Y/n]n #删除测试数据库

Reload privilege tables now? [Y/n]y #重载

#tar xf phpMyAdmin-4.0.10.20-all-languages.tar.gz -C /data/apps/

#cd /data/apps/

#ln -sv phpMyAdmin-4.0.10.20-all-languages pma

#cd pma/

#vim config.inc.php

$cfg['blowfish_secret'] = 'aqwer8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

#scp phpMyAdmin-4.0.10.20-all-languages.tar.gz 172.16.250.149:/root/

===========================================================================

(nginx主机)172.16.250.149

#tar xf phpMyAdmin-4.0.10.20-all-languages.tar.gz -C /data/nginx/html/

#cd /data/nginx/html/

#ln -sv phpMyAdmin-4.0.10.20-all-languages pma

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

===========================================================================

实验相关扩展

(nginx主机)172.16.252.245

(nginx代理主机)172.16.250.149

(mariadb server)172.16.253.131

以上为三台CentOS7.3主机

试验拓扑图如下:

3c8ce6380daa33c267ccb0e2e66a02de.png

===========================================================================

(nginx主机)172.16.252.245

#yum install nginx -y

#mkdir /data/nginx/html -pv

下载phpMyAdmin-4.0.10.20-all-languages.tar.gz

#tar xf phpMyAdmin-4.0.10.20-all-languages.tar.gz -C /data/nginx/html/

#cd /data/nginx/html/

#ln -sv phpMyAdmin-4.0.10.20-all-languages pma

#vim /etc/nginx/nginx.conf

3c8ce6380daa33c267ccb0e2e66a02de.png

#nginx -t

#systemctl start nginx.service

===========================================================================

(nginx代理主机)172.16.250.149

#vim /etc/nginx/conf.d/ilinux.conf

3c8ce6380daa33c267ccb0e2e66a02de.png

===========================================================================

缓存相关

(nginx代理主机)172.16.250.149

#vim /etc/nginx/nginx.conf

3c8ce6380daa33c267ccb0e2e66a02de.png

#vim /etc/nginx/conf.d/ilinux.conf

3c8ce6380daa33c267ccb0e2e66a02de.png

#nginx -t

#nginx -s reload

#curl http://www.ilinux.io/pma/index.php

#ls /data/nginx/fcgicache/d4/41/c4/3eaa46f5754097b1e7ed0fe21fc441d4

/data/nginx/fcgicache/d4/41/c4/3eaa46f5754097b1e7ed0fe21fc441d4

#vim /etc/nginx/conf.d/ilinux.conf

3c8ce6380daa33c267ccb0e2e66a02de.png

#nginx -t

#nginx -s reload

3c8ce6380daa33c267ccb0e2e66a02de.png

3c8ce6380daa33c267ccb0e2e66a02de.png

获取完整内容

3c8ce6380daa33c267ccb0e2e66a02de.png

原创文章,作者:Linux.rookie,如若转载,请注明出处:http://www.178linux.com/82132

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值