Enable LNMP website access logs and analyze website log files

888u

Last update at :2024-06-12,Edit by888u

When we built and created the website on the VPS, we may not have opened the log file at first, so it was difficult to know the data from the crawling logs we used to analyze the website. For example, when we installed the llsmp package before, Snail shared to\ \"Set LiteSpeed ​​log options to enable website access log files\\" Many users may use the LNMP installation package, so how to reopen NGINX log files in this environment?

First, find the conf file where you need to open the website, located at

/usr/local/nginx/conf/vhost/laozuo.org.conf

Secondly, open the above file with a text editor and find the bottom one

access_log off;

Replace this with:

access_log /home/wwwlogs/laozuo.org.log laozuo.org;

Then add the following code to the top of the conf:

log_format laozuo.org \\\'$remote_addr - $remote_user [$time_local] \\\"$request\\\" \\\' \\\'$status $body_bytes_sent \\\"$http_referer\\\" \ \\' \\\'\\\"$http_user_agent\\\" $http_x_forwarded_for\\\';

Finally, restart LNMP

/root/lnmp restart

Restart LNMP to take effect. The log files are saved under the home/wwwlogs folder. Remember to delete them regularly, otherwise the files occupied by your machine will become larger and larger.

Note: Replace the red URL part above with your corresponding website.

Recommended site search: independent ip host, registration query, webmaster ip, Korean proxy server, telecom hosting, Singapore server, domain name registration, rent server, dynamic dial-up vps host, buy domain name,

Enable LNMP website access logs and analyze website log files

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码