分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

zabbix_配置Nginx连接php

发布时间:2023-09-06 01:25责任编辑:彭小芳关键词:配置

配置Nginx连接php

一、Nginx连接php

1、准备测试php文件

站点创建

# mkdir -p /data/site/huotouyihao/

存放Nginx日志

#mkdir -p /data/logs/nginx

#vi /data/site/huotouyihao/info.php

<?php

Phpinfo();

?>

保存退出

650) this.width=650;" src="https://s5.51cto.com/oss/201711/15/eefb02474b2a1768dd42c39aa65c89ea.png-wh_500x0-wm_3-wmp_4-s_784075324.png" title="1.png" alt="eefb02474b2a1768dd42c39aa65c89ea.png-wh_" />

2、配置Nginx

# cd /usr/local/nginx-1.8.1/conf

# vi nginx.conf

650) this.width=650;" src="https://s4.51cto.com/oss/201711/15/4c0ef6ced9aabb76d4fceffe2da184fe.png-wh_500x0-wm_3-wmp_4-s_1186567631.png" title="2.png" alt="4c0ef6ced9aabb76d4fceffe2da184fe.png-wh_" />

650) this.width=650;" src="https://s4.51cto.com/oss/201711/15/6d0c3c7e1502889f4bfbd7d0cedce76e.png-wh_500x0-wm_3-wmp_4-s_1615192969.png" title="3.png" alt="6d0c3c7e1502889f4bfbd7d0cedce76e.png-wh_" />

代码如下:

server {

       listen       80;

       server_name  localhost;

       #charset koi8-r;

       #access_log logs/host.access.log  main;

        access_log /data/logs/nginx/nginxaccess.log ;

        index index.php index.html index.html;

        root /data/site/huotouyihao;

       location / {

       #    root   html;

       #    index  index.html index.htm;

       try_files $uri $uri/ /index.php?$args;

       }

       location ~ .*\.(php)?$

       {

       expires -1s;

       try_files $uri =404;

       fastcgi_split_path_info ^(.+\.php)(/.+)$;

       include fastcgi_params;

       fastcgi_param PATH_INFO $fastcgi_path_info;

       fastcgi_index index.php;

       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_pass 127.0.0.1:9000;

       }

下面测试也可以:

650) this.width=650;" src="https://s1.51cto.com/oss/201711/15/6c3796436e6bac3d1b3948e4e3d5e6ba.png-wh_500x0-wm_3-wmp_4-s_3292467919.png" title="4.png" alt="6c3796436e6bac3d1b3948e4e3d5e6ba.png-wh_" />

(代码:如下

   #gzip on;

    server {

        listen       80;

        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        access_log  /data/logs/nginx/nginxaccess.log;

        index index.phpindex.html;

        location / {

        #    root  html;

        #    index index.html index.htm;

        try_files $uri$uri/ /index.php?$args;

        }

        location ~ \.php${

        root html;

        fastcgi_pass127.0.0.1:9000;

        fastcgi_indexindex.php;

        includefastcgi_params;

        fastcgi_paramSCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;

        }

        #error_page  404              /404.html;

        # redirect servererror pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location =/50x.html {

            root   html;

        }

3、重新启动Nginx服务

#/usr/local/nginx-1.8.1/sbin/nginx -sreload

4、测试http://localhost/info.php

650) this.width=650;" src="https://s3.51cto.com/oss/201711/15/490bc633ef53288a1eb2e800a1c29a7f.png" title="5.png" alt="490bc633ef53288a1eb2e800a1c29a7f.png" />

5、注意服务器本机防火墙策略


本文出自 “向ITAT看齐” 博客,请务必保留此出处http://zhangshuai2010.blog.51cto.com/1511867/1981894

zabbix_配置Nginx连接php

原文地址:http://zhangshuai2010.blog.51cto.com/1511867/1981894

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved