1.调整http中 access_log 中的参数,打开on; 注意里面的:log_format main '$cookie_phisrandomflag - $remote_addr - $upstream_addr - [$time_local] - "$request" '; 输出参数格式;
http {
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 4k;
large_client_header_buffers 4 4k;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
log_format main '$cookie_phisrandomflag - $remote_addr - $upstream_addr - [$time_local] - "$request" ';
access_log on;
#access_log logs/access.log main;
2.在server 下面打开log日志:access_log logs/host.access.log main;
server {
listen x;
server_name x.x.x.x;
#charset koi8-r;
#access_log logs/host.access.log main;
3.在控制台执行相关命令:
cd /usr/local/nginx/sbin 进入nginx sbin路径命令
./nginx -t 查询是否成功
/nginx -s reload 执行生成