准备:nginx version: nginx/1.24.0 三台服务器
1.web-1 :运行静态项目 ip 192.168.200.100
安装nginx : yum -y isntall nginx //默认安装的是旧版本,如果安装新版本,去nginx官网获取仓库,再安装,就是最新版本
运行服务:systemctl start nginx
echo "web-1" > /usr/share/nginx/index.html
2.web-2:运行动态项目 IP:192.168.200.66
安装nginx php php-fpm php-mysql
yum -y isntall nginx php php-fpm php-mysql
systemctl start nginx php-fpm
编辑nginx配置文件:vim /etc/nginx/conf.d/default.conf
将server块里面的root 后面改为 index index.php;
重新加载配置文件: nginx -s reload
vim /usr/share/nginx/html/index.php
index.php (文件名)
<?php
phpinfo();
?>
3.动静分离服务器:ip 192.168.200.6
安装nginx
vim /etc/nginx/nginx.conf
vim /etc/nginx/conf.d/default.conf
systemctl start nginx
测试:
在网页输入动静分离服务器的IP :192.168.200.6/index.html 结果 :web-1
再输入192.168.200.6/index.php 结果
动静分离配置完成!