国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > Nginx > 正文

Nginx實(shí)現(xiàn)瀏覽器可實(shí)時(shí)查看訪問日志的步驟詳解

2024-08-30 12:22:47
字體:
供稿:網(wǎng)友
我們經(jīng)常需要在頁面上實(shí)時(shí)查看nginx的日志輸出,并且能在頁面上顯示,那么下面小編就給大家說下怎么在瀏覽器上實(shí)時(shí)動(dòng)態(tài)的查看nginx的訪問日志,有需要的朋友們可以參考借鑒。

一、首先查看nginx版本,我使用的是1.9.7的版本,安裝目錄在/application/nginx-1.9.7

[root@AnSheng ~]# /application/nginx-1.9.7/sbin/nginx -Vnginx version: nginx/1.9.7built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)configure arguments: --prefix=/application/nginx-1.9.7 --user=nginx --group=nginx --with-http_stub_status_module

二、檢查語法并啟動(dòng)nginx

[root@AnSheng ~]# /application/nginx-1.9.7/sbin/nginx -tnginx: the configuration file /application/nginx-1.9.7/conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.9.7/conf/nginx.conf test is successful[root@AnSheng ~]# /application/nginx-1.9.7/sbin/nginx

三、把nginx配置文件內(nèi)多余的注視行和空行刪掉

[root@AnSheng ~]# cd /application/nginx-1.9.7/conf/[root@AnSheng conf]# egrep -v "#|^$" nginx.conf.defaultworker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server {  listen 80;  server_name localhost;  location / {   root html;   index index.html index.htm;  }  error_page 500 502 503 504 /50x.html;  location = /50x.html {   root html;  } }}[root@AnSheng conf]# egrep -v "#|^$" nginx.conf.default nginx.conf

四、在nginx配置文件的server標(biāo)簽內(nèi)加入以下標(biāo)簽和內(nèi)容

location /logs { alias /application/nginx-1.9.7/logs; #Nginx日志目錄 autoindex on; #打開目錄瀏覽功能 autoindex_exact_size off; #默認(rèn)為on,顯示出文件的確切大小,單位是bytes #顯示出文件的大概大小,單位是kB或者M(jìn)B或者GB autoindex_localtime on; #默認(rèn)為off,顯示的文件時(shí)間為GMT時(shí)間。 #改為on后,顯示的文件時(shí)間為文件的服務(wù)器時(shí)間 add_header Cache-Control no-store; #讓瀏覽器不保存臨時(shí)文件}

五、開啟在瀏覽器打開log文件,如果不開啟再點(diǎn)擊文件的時(shí)候就下載而不是打開

[root@AnSheng conf]# vim mime.typestypes { text/html html htm shtml; text/log log; text/css css; text/xml xml; .............

六、檢測語法,然后讓nginx配置生效,在瀏覽器查看

[root@AnSheng conf]# /application/nginx-1.9.7/sbin/nginx -tnginx: the configuration file /application/nginx-1.9.7/conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.9.7/conf/nginx.conf test is successful[root@AnSheng conf]# /application/nginx-1.9.7/sbin/nginx -s reload

打開瀏覽器輸入域名或者IP,后面加上logs,然后點(diǎn)擊文件就可以打開了,如果日志隨隨便便就可以被別人查看是不是很不安全,所以我們要在加一層nginx用戶認(rèn)證。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临沂市| 拜泉县| 玛多县| 秦安县| 蒙阴县| 铅山县| 南和县| 库车县| 新沂市| 和静县| 台前县| 剑阁县| 桃园县| 长乐市| 筠连县| 邻水| 崇义县| 财经| 夏津县| 如皋市| 济南市| 武山县| 天台县| 淮安市| 上林县| 安龙县| 鄂托克前旗| 奈曼旗| 东至县| 安庆市| 榆树市| 慈利县| 禹城市| 巴南区| 太原市| 科尔| 兴宁市| 湖北省| 资源县| 城步| 唐山市|