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.
I remove comment on the following line from http.conf
file:
LoadModule unique_id_module libexec/apache2/mod_unique_id.so
and I am trying to reference the ID in this simple php script:
<?php print("Hello worldn"); print($_SERVER['UNIQUE_ID']); ?>
Yet this script returns only Hello World
.
Is this possible to do? I’m running macos if that makes any difference.
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) }
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
Advertisement
Answer
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….