zoukankan      html  css  js  c++  java
  • Nginx*LAMP解析PHP环境

    1.Nginx充当中介,将请求转发给其他LAMP

    192.168.200.112中yum安装LAMP

    [root@localhost ~]# yum -y install httpd mairadb mariadb-server php php-mysql

    [root@localhost ~]# systemctl start httpd
    [root@localhost ~]# systemctl start mariadb

    [root@localhost ~]# vim /var/www/html/test.php     //添加测试文档

    192.168.200.111中安装nginx

    [root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf  //修改主配置文件,添加location

      location ~* .php$ {
      proxy_pass http://192.168.200.112;
      }

    [root@localhost ~]# nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    [root@localhost ~]# killall -HUP nginx   // 重启

    在网页中测试

     

     111/112中测试结果相同,转发成功

    2.Nginx通过FPM模块,调用PHP环境

    [root@nginxetc]# vim /usr/local/nginx/conf/nginx.conf       //修改主配置文件,添加location

    server {

    …… //省略部分信息

      location / {

                  root   html;

      index  index.php index.html index.htm;

              }

      location ~ .php$ {                                    //访问php页面的配置段

      root html;                                            //PHP网页文档根目录

      fastcgi_pass 127.0.0.1:9000;         //php-fpm的监听地址

      fastcgi_indexindex.php;                 //PHP首页文件

      include fastcgi.conf;                        //包括fastcgi.conf样本配置

      }

    }

    [root@nginx~]# cat /usr/local/nginx/html/php.php  //创建测试文档

    <?php

    phpinfo();

    ?>

    测试成功

  • 相关阅读:
    Linux脚本中使用特定JDK
    redis 模糊匹配批量清理 keys
    git push 本地项目推送到远程分支
    extentreports报告插件之extentX之服务搭建(三)
    extentreports报告插件与testng集成(二)
    extentreports报告插件与testng集成(一)
    初识ios自动化(一)
    css 选择器
    appium移动端测试之滑动(二)
    使用appium进行ios测试,启动inspector时遇到的问题(一)
  • 原文地址:https://www.cnblogs.com/zhiyuan-yu/p/11525536.html
Copyright © 2011-2022 走看看