lnmp动静分离实验

2017-09-10  本文已影响0人  lijincheng

LNMP代表的就是:Linux系统下Nginx+MySQL+PHP(php-fpm独立服务器)这种网站服务器架构。

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

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

以上为两台CentOS7.3主机

试验拓扑图如下:

172.16.253.131(fpm server mariad bserver)后端主机的配置信息

#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 #定义后端主页

<?php
  phpinfo();
?>

172.16.250.149前端nginx 主机配置:

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

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

<h1>Nginx server</h1>

![Uploading image_839581.png . . .]


(fpm server mariad bserver) 172.16.253.131

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

[mysqld]
skip_name_resolver=on
innodeb_file_per_table=on
#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   #是否删除test数据库
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

实验相关扩展

(nginx主机)172.16.252.245

(nginx代理主机)172.16.250.149

(mariadb server)172.16.253.131

以上为三台CentOS7.3主机

试验拓扑图如下:

(nginx主机)172.16.252.245

#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
server {
      listen 80;
      server_name;
      root /data/nginx/html

}

缓存相关

(nginx代理主机)172.16.250.149

vim /etc/nginx/nginx.conf


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


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

上一篇下一篇

猜你喜欢

热点阅读