码迷,mamicode.com
首页 > Web开发 > 详细

zabbix_配置Nginx连接php

时间:2017-11-15 10:46:38      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:zabbix_php连接nginx

配置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();

?>

保存退出

技术分享

2、配置Nginx

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

# vi nginx.conf

技术分享

技术分享

代码如下:

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;

       }

下面测试也可以:

技术分享

(代码:如下

   #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

技术分享

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


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

zabbix_配置Nginx连接php

标签:zabbix_php连接nginx

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!