nginx日志数据提取 nginx apache nginx php nginx rewrite
程序员文章站
2024-02-04 14:56:16
...
分析nginx日志$s_line = '1.202.39.44 - - [22/Mar/2016:17:12:25 +0800] "POST /auth/login HTTP/1.1" 200 261 "http://www.halfcookie.cn/auth/login" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" "-"'; $p = '/^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s-\s(.*)\s\[(.*)\]\s"(.*)\"\s(\d{3})\s(\d+)\s"(.*)"\s"(.*)"\s\"(.*)\"$/u';preg_match($p,$s_line,$a_match); var_dump($a_match);array(13) { [0] => string(233) "1.202.39.44 - - [22/Mar/2016:17:12:25 +0800] "POST /auth/login HTTP/1.1" 200 261 "http://www.halfcookie.cn/auth/login" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" "-"" 'ip' => string(11) "1.202.39.44" [1] => string(11) "1.202.39.44" [2] => string(1) "-" 'time' => string(26) "22/Mar/2016:17:12:25 +0800" [3] => string(26) "22/Mar/2016:17:12:25 +0800" [4] => string(25) "POST /auth/login HTTP/1.1" 'status' => string(3) "200" [5] => string(3) "200" [6] => string(3) "261" [7] => string(35) "http://www.halfcookie.cn/auth/login" [8] => string(108) "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" [9] => string(1) "-" }$s_line = '1.202.39.44 - - [22/Mar/2016:17:12:25 +0800] "POST /auth/login HTTP/1.1" 200 261 "http://www.halfcookie.cn/auth/login" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" "-"'; $p = '/^(?P\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s-\s(.*)\s\[(?P preg_match($p,$s_line,$a_match); var_dump($a_match);array(13) { [0] => string(233) "1.202.39.44 - - [22/Mar/2016:17:12:25 +0800] "POST /auth/login HTTP/1.1" 200 261 "http://www.halfcookie.cn/auth/login" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" "-"" 'ip' => string(11) "1.202.39.44" [1] => string(11) "1.202.39.44" [2] => string(1) "-" 'time' => string(26) "22/Mar/2016:17:12:25 +0800" [3] => string(26) "22/Mar/2016:17:12:25 +0800" [4] => string(25) "POST /auth/login HTTP/1.1" 'status' => string(3) "200" [5] => string(3) "200" [6] => string(3) "261" [7] => string(35) "http://www.halfcookie.cn/auth/login" [8] => string(108) "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" [9] => string(1) "-" }解析:
?P
:命名捕获组 nginx配置日志文档。。
https://www.ttlsa.com/linux/the-nginx-log-configuration/
以上就介绍了nginx日志数据提取,包括了nginx方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
推荐阅读
-
nginx日志数据提取 nginx apache nginx php nginx rewrite
-
Apache/Nginx+PHP+MySQL一键环境安装包
-
隐藏Nginx或Apache以及PHP的版本号的方法_PHP
-
浅谈apache和nginx的rewrite的区别
-
一起了解nginx-基本介绍+单点安装+基本应用 nginx apache nginx php nginx rewrite
-
解决Nginx和Fpm-Php等内部多进程之间共享数据问题
-
浅谈apache和nginx的rewrite的区别_PHP教程
-
解决Nginx和Fpm-Php等内部多进程之间共享数据问题
-
隐藏Apache、Nginx和PHP的版本号的配置方法
-
apache前端+nginx后端,nginx如何rewrite正确的地址