当前位置: 首页 > 知识库问答 >
问题:

ngnix-FastCGI在stderr中发送:”PHP消息:PHP通知:未定义的变量

汪和悌
2023-03-14

我安装了Ngnix服务器,并将其配置为:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
    #location /RequestDenied {
    #       proxy_pass http://127.0.0.1:8080;    
    #}
    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = / {
      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    #
    #       # With php5-cgi alone:
    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}

}

我收到以下错误(从我的error.log复制):

    *9 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined variable: confMsg in /usr/share/nginx/html/admin-interface/login.php on line 196" while reading upstream, client: 127.0.0.1, server: localhost, request: "GET /admin-interface/login.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost"

2015/12/16 00:27:37[错误]952#0:*9 FastCGI发送到stderr:“PHP消息:PHP通知:未定义索引:第245行/usr/share/nginx/html/admin interface/login.PHP中的用户名PHP消息:PHP通知:未定义索引:第249行/usr/share/nginx/html/admin interface/login.PHP中的用户名”,同时阅读上游,客户端:127.0。0.1,服务器:localhost,请求:“GET/admin interface/login.php HTTP/1.1”,上游:fastcgi://unix:/var/run/php5-fpm。sock:,主机:“本地主机”

我正在尝试使用Ngnix服务器配置此环境,此环境确实可以使用不同的主机。我确实改变了cgi。在我的php中修复\u pathinfo=0。伊尼

我的配置缺少什么?

共有2个答案

元俊雅
2023-03-14

很抱歉,这个问题很模糊,很难回答。。。有什么问题吗??

据我从错误文件中看到的,这里没有问题。只是PHP通知。

看看这个:

error_page 500 502 503 504 /50x.html;
location = /50x.html {

你看不出有什么不对吗?您正在将/位置包含到错误位置中,而不是逻辑我的朋友。。。“/”下的php文件将永远不会以这种方式传递给php5 fpm。除非我对你的要求一无所知,否则就这样做;

移除;

location = /50x.html {

向下。

添加以下内容:

location ~ [^/]\.php(/|$) { #open location bracket

    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) { #open condition bracket
        return 404;
    } #close condition bracket

    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/var/run/php5-fpm.sock;

} #close location bracket

然后

sudo nginx -t # to test your config.

如果有问题,寻找打开和关闭括号,因为这似乎是你的克星(你在你打开括号的服务器块中——确保你关闭了它)。如果全部通过;

sudo nginx -s reload

下次你发布代码时,请花点时间删除所有的垃圾评论。这将有助于你得到答案,或者至少询问你的问题。

如果一切都好,那么您可以考虑添加这些位置配置以获得更健壮/高效的服务器;

# send expire headers
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    access_log off; # optional
    log_not_found off; # optional
    expires max;
}

location = ^/favicon.ico {
    access_log off;
    log_not_found off;
}

# robots noise...
location = ^/robots.txt {
    log_not_found off;
    access_log off;
    allow all;
}

# block access to hidneen files (.htaccess per example)
location ~ /\. { access_log off; log_not_found off; deny all; }

如果你不理解一个设置,不要添加它。这就像盲目地在你的车里加油,却不知道它是什么类型。

孙胜泫
2023-03-14

这不是错误,这是一个通知。

脚本/usr/share/nginx/html/admin-interface/login。php正在访问变量$confMsg,该变量当时不存在。

您可以在php中更改错误报告级别。ini(这也会影响其他脚本,并且您不想关闭通知..)或者修复脚本中错误的变量访问。

第二个解决方案会更简单,因为您只需初始化$confMsg=''

 类似资料:
  • 我正在运行一个PHP脚本,并继续收到如下错误: 注意:第10行C:\wamp\www\myPath\index.php中未定义的变量:my_variable_name 注意:第11行未定义索引:my_index C:\wamp\www\myPath\index.php 第10行和第11行如下所示: 这些错误信息的含义是什么? 为什么他们突然出现?我曾经使用这个脚本多年,我从来没有遇到过任何问题。

  • 代码: 错误: 我该怎么解决这个问题?

  • 说明 此接口用于向排队的微信用户发送消息,如到号时的叫号信息 请求地址 http://api.dc78.cn/Api/wwnotify 请求方式 GET 请求参数 URL参数 参数名称 必填 描述 范例 id 排队号id msg 要发送的信息 POST参数 参数名称 必填 描述 范例 无 GET参数 参数名称 必填 描述 范例 id 排队号id 是 排队列表协议中的id 223729 msg 通知

  • 线下取的号不能发送通知 请求参数说明 参数 描述 必填 示例值 类型 最大长度 action 接口参数组 是 object └action 需要调用的接口名称 是 wwget string get GET参数组,本组参数需要参与签名 是 object └id 排队号id 否 47302320 number └msg 通知消息 否 38号客人请返回用餐啦 string 请求示例 { "action

  • 我有一个web应用程序,它通过WebLogic中的JMS与其他Java web应用程序通信。 我读到这样的答案:如何从PHP连接Jms? 我安装了ActiveMQ并尝试使用它。但是在Weblogic中,我们需要“jms_factory”和“queue_name”。我想它使用t3协议。

  • 我需要实现向带有属性的SQS发送消息。消息的正文上传良好,但我有问题的属性。消息属性需要具有属性名称、数据类型和值的关联数组。我有这样的错误: $Attributes数组应该是什么样子?