当前位置:首页 > Linux > 正文内容

多台服务器分离部署lnmp

tszi2年前 (2023-04-06)Linux902

使用三台主机部署lnmp架构

   nginx主机ip:192.168.1.241

   php主机ip:192.168.1.242

   mariadb主机ip:192.168.1.101

image.png



三台主机关闭selinux及firewalld

setenforce 0

systemctl stop firewalld

nginx主机:

1.安装nginx

yum  install   -y  nginx

image.png

2.配置nginx关联php-fpm

vi   /etc/nginx/nginx.conf


 

location  /  {

root   /usr/share/nginx/html;

index  index.php  index.html  index.htm;

 

}

 

location  ~  \.php$  {

fastcgi_pass  192.168.1.242:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include fastcgi_params;

 

}


image.png 

3.安装nfs-utils客户端

yum  install   -y    nfs-utils   

image.png

4.编辑/etc/exports文件

vi   /etc/exports

 /usr/share/nginx/html     192.168.1.242(rw,sync,insecure,root_squash)

 image.png

5.启动rpcbindnfs服务

systemctl    start      rpcbind   

systemctl    start      nfs-server

 image.png

image.png

6./usr/share/nginx/html编写测试文件

vi  index.php


<?php

phpinfo();

?>

image.png

php主机:

1.安装php,php-fpm,php-mysqlnd

yum  install  -y  php  php-fpm   php-mysqlnd

 image.png

2.配置php-fpm

vi     /etc/php-fpm.d/www.conf

user=nginx

group=nginx

listen=192.168.1.242:9000

listen.allowed_clients=192.168.1.241

image.png


3.启动php-fpm

systemctl start  php-fpm

image.png

image.png

mariadb主机:

1.安装mariadb-server  mariadb

yum     install     -y     mariadb-server  mariadb

 image.png

2.启动mariadb-server

systemctl  start  mariadb

image.png

 

 

挂载php主机的/usr/share/nginx/html   nginx主机的/usr/share/nginx/html目录

安装nfs-utils:

image.png

mount  -t  nfs   192.168.1.242:/usr/share/nginx/html   /usr/share/nginx/html

image.png


扫描二维码推送至手机访问。

版权声明:本文由IT农场发布,如需转载请注明出处。

本文链接:http://www.iterx.cn/?id=28

分享给朋友:

“多台服务器分离部署lnmp” 的相关文章

新版TinyCore Linux系统安装

新版TinyCore Linux系统安装

1.设置软件仓库源echo "https://mirrors.163.com/tinycorelinux">/opt/tcemirror 2.安装启动加载器及其依赖tce-load -wi  grub2-multi.tcz    li...

主流操作系统网络配置

主流操作系统网络配置

网络时代,任何一台设备想接入网络,最基本的是要有网络地址。很多人的设备都是有dhcp服务自动分配ip地址。所以会说我从来没有配置过这些东西,还不是照样上网。有时难免会遇到配置网络地址的情况。一台设备务必要有:    ip地址:设备在互联网上的唯一的公网地址,或...

RockyLinux 9.1  部署kms密钥管理服务

RockyLinux 9.1 部署kms密钥管理服务

使用RockyLinux 9.1系统部署kms服务。生产企业没人用这么新的版本,谁也不想做小白鼠,耽误企业生产。不过个人私底下自娱自乐,也无碍。        下载vlmcsd源码包wget -c https://github.com/Wind4/v...