I want to enable access logs for nginx. Baidu took a look, mainly configuring
in nginx.conf
This section
# log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#
# access_log logs/access.log main;
is commented out with # by default. I want to turn it on, that is, uncomment this section with #.
Then restart nginx but it cannot be restarted, prompting
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
It’s fine after adding # back. What’s the reason?
Including the error log at the beginning
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
I also removed the # to take effect, but nginx could not start.
`
1. Please use
nginx -t
to check the configuration file to view the specific error informationThe log is processed like this