如何在 apache 中访问唯一 ID? [英] How can I access Unique ID in apache?

查看:32
本文介绍了如何在 apache 中访问唯一 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问 apache 为每个请求跟踪的 unique_id?我想在它调用的任何 php 脚本中跟踪它,并为每个请求记录它.

How can I access the unique_id that apache tracks for each request? I'd like to track it in any php scripts it calls as well as have it logged for each request.

我从 http.conf 文件中删除了以下行的注释:

I remove comment on the following line from http.conf file:

LoadModule unique_id_module libexec/apache2/mod_unique_id.so

我试图在这个简单的 php 脚本中引用 ID:

and I am trying to reference the ID in this simple php script:

<?php

print("Hello world
");
print($_SERVER['UNIQUE_ID']);
?>

然而这个脚本只返回Hello World.

这可以吗?如果这有什么不同,我正在运行 macos.

Is this possible to do? I'm running macos if that makes any difference.

$_SERVER 的 var_dump 如下:

A var_dump of $_SERVER is as follows:

array(29) { ["HTTP_HOST"]=> string(9) "localhost" 
["HTTP_CONNECTION"]=> string(10) "keep-alive" 
["HTTP_CACHE_CONTROL"]=> string(9) "max-age=0" 
["HTTP_ACCEPT"]=> string(74) "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" ["HTTP_USER_AGENT"]=> string(120) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36" ["HTTP_ACCEPT_ENCODING"]=> string(17) "gzip,deflate,sdch" 
["HTTP_ACCEPT_LANGUAGE"]=> string(14) "en-US,en;q=0.8" 
["HTTP_COOKIE"]=> string(11) "undefined=0" 
["PATH"]=> string(186) "/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/opt/local/lib/postgresql84/bin:/Applications/XAMPP/xamppfiles/bin" 
["SERVER_SIGNATURE"]=> string(0) "" 
    ["SERVER_SOFTWARE"]=> string(67) "Apache/2.2.24 (Unix) DAV/2 PHP/5.3.26 mod_ssl/2.2.24 OpenSSL/0.9.8y" 
    ["SERVER_NAME"]=> string(9) "localhost" 
    ["SERVER_ADDR"]=> string(3) "::1" 
    ["SERVER_PORT"]=> string(2) "80" 
    ["REMOTE_ADDR"]=> string(3) "::1" 
    ["DOCUMENT_ROOT"]=> string(28) "/Library/WebServer/Documents" 
    ["SERVER_ADMIN"]=> string(15) "you@example.com" 
    ["SCRIPT_FILENAME"]=> string(35) "/Library/WebServer/Documents/id.php" 
    ["REMOTE_PORT"]=> string(5) "49669" 
    ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" 
    ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" 
    ["REQUEST_METHOD"]=> string(3) "GET" 
    ["QUERY_STRING"]=> string(0) "" 
    ["REQUEST_URI"]=> string(7) "/id.php" 
    ["SCRIPT_NAME"]=> string(7) "/id.php" 
    ["PHP_SELF"]=> string(7) "/id.php" 
    ["REQUEST_TIME"]=> int(1397681759) 
    ["argv"]=> array(0) { } 
    ["argc"]=> int(0) }

我在同一区域遇到的另一个问题可能指向手头的问题:https://apple.stackexchange.com/questions/127801/where-are-the-apache-config-files-stored?noredirect=1#comment149749_127801

Another problem I am having in the same area may point to the problem at hand: https://apple.stackexchange.com/questions/127801/where-are-the-apache-config-files-stored?noredirect=1#comment149749_127801

推荐答案

我不得不做一个 /usr/sbin/httpd -k stop 然后一个 /usr/sbin/httpd-k start 获取配置.不确定为什么 sudo apachectl restart 看起来像是在重新启动,但它不是....

I had to do a /usr/sbin/httpd -k stop and then a /usr/sbin/httpd -k start to get the config to take. Unsure why sudo apachectl restart LOOKED like it was restarting, but it wasn't....

这篇关于如何在 apache 中访问唯一 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆