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

多台服务器分离部署lnmp

tszi2年前 (2023-04-06)Linux895

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

命令行查询本机公网ip地址

命令行查询本机公网ip地址

有时需要查询本机公网ip:不论你的操作系统是否有图形界面,都能通过命令行获得公网地址.Unix,Linux,MacOS 系统使用curl指令即可获取公网ip:        curl  cip.ccWindow...

主流操作系统网络配置

主流操作系统网络配置

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

docker部署kms密钥管理服务激活windows作业系统

docker部署kms密钥管理服务激活windows作业系统

     微软视窗作业系统是一款商业化闭源的作业系统,用户想要使用微软的操作系统,得向微软购买 windows系统的授权许可,俗称密钥。密钥是由25个字符组成。字母数字混合组合的字符串。每组5位字符,一共五组.比如:WN7JF-6PBCM-HDPG9-9GMT3-Y4D...

ArchLinux 作业系统安装教程

ArchLinux 作业系统安装教程

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