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

多台服务器分离部署lnmp

tszi2年前 (2023-04-06)Linux816

使用三台主机部署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://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...

RockyLinux 9.1  部署kms密钥管理服务

RockyLinux 9.1 部署kms密钥管理服务

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

ArchLinux 作业系统安装教程

ArchLinux 作业系统安装教程

如果你能看到此文,想必你一定玩过不少的发行商发行的 Linux 作业系统或者听说过很多发行商发行的 Linux 作业系统。如果你玩过不少的 Linux 作业系统,对于安装系统可谓是轻车熟路,就是闭着眼睛都能安装上吧。众多发行版可能默认都是使用图形界面的安装向导一步一步的指导着你完成安装,纵然支持命令...