目录
[四、 配置php使nginx能够解析.php](#四、 配置php使nginx能够解析.php)
一、概述
LNMP代表 Linux、Nginx、MySQL、PHP,是一种常用的服务器架构。它由以下组件组成:
Linux:作为操作系统,提供服务器的基本功能和稳定性。
Nginx:作为Web服务器,处理和响应客户端的HTTP请求,并将请求分发给后端的PHP处理程序。
MySQL:作为关系型数据库管理系统,用于存储和管理网站的数据。
PHP:作为服务器端脚本语言,用于处理和生成动态内容。
LNMP架构在Web开发中广泛使用,因为它结合了优秀的开源软件,具有高性能、高稳定性和高灵活性的特点。
二、LNMP环境部署
需要三台主机 ,分别部署nginx、mysql、php 以实现多台主机的LNMP分布式部署
关闭防火墙 ,设置selinux宽容模式,配置静态ip
nginx ip 192.168.100.3
mysql ip 192.168.100.4
php ip 192.168.100.5
三、配置nginx
可采用两种安装方式网络源安装(需下载或配置epel源)和编译安装
主要演示编译安装nginx的部署
1、yum安装
yum install -y epel-release (下载epel源)
yum install -y nginx
2、编译安装
下载nginx源码包 //nginx.org/en/download.html(下载需要下载的nginx版本)
tar xf nginx-1.20.2.tar.gz
cd nginx-1.20.2.tar.gz

做nginx的命令优化,启动并测试 nginx
查看是否解析php,发现不能解析php

四、 配置php使nginx能够解析.php
采用yum安装php
查看php版本,确认phpMyAdmin所需版本
更换rpm源
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

删除已安装php相关包并安装新版本服务
yum -y remove php*
安装 yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-ldap php72w-mcrypt
修改配置文件

因为nginx是编译安装默认的网页访问目录 /usr/local/nginx/html
mkdir -p /usr/local/nginx/html并且两边添加相同的测试文件
修改ngin配置文件

进行访问,确定nginx php解析php

五、配置mysql
可采用yum安装(快捷方便)
给予管理用户和ultrax数据库、登录数据库的用户

在任意主机进行远程访问测试

六、配置discuz进行登录论坛访问测试
将discuz压缩包拖入终端 解压 (nginx和php服务都需要进行)
访问测试