![Nginx 服务器不写入访问日志](https://linux22.com/image/702211/Nginx%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8D%E5%86%99%E5%85%A5%E8%AE%BF%E9%97%AE%E6%97%A5%E5%BF%97.png)
我的服务器出现了一个奇怪的问题。
每个域的每个 access.log - error.log 都可以正常工作,但 /var/log/nginx/access.log 上所有站点的主 access.log 根本不起作用(error.log 可以正常工作)
我尝试删除它并重新启动 nginx,它确实创建了日志,但它并没有改变它这是我的 nginx 配置
user www-data;
worker_processes auto;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
log_format upstream_time '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"'
'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"';
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
more_clear_headers Server;
# server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log upstream_time;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
# gzip_vary on;
# gzip_proxied any;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_names_hash_bucket_size 128;
}
ls -l /var/日志/
total 114336
-rw-r--r-- 1 root root 481 Apr 6 01:16 alternatives.log
-rw-r--r-- 1 root root 3004 Mar 31 14:36 alternatives.log.1
-rw-r--r-- 1 root root 1679 Feb 24 03:53 alternatives.log.2.gz
-rw-r--r-- 1 root root 3431 Jan 25 18:44 alternatives.log.3.gz
drwxr-x--- 2 root adm 4096 Jan 19 06:25 apache2
-rw-r----- 1 root adm 0 Mar 11 06:25 apport.log
-rw-r----- 1 root adm 1103 Mar 10 21:27 apport.log.1
-rw-r----- 1 root adm 272 Feb 17 19:15 apport.log.2.gz
drwxr-xr-x 2 root root 4096 Apr 1 06:25 apt
-rw-r----- 1 syslog adm 11092121 Apr 10 11:39 auth.log
-rw-r----- 1 syslog adm 63598571 Apr 9 06:25 auth.log.1
-rw-r----- 1 syslog adm 3094301 Apr 2 06:25 auth.log.2.gz
-rw-r----- 1 syslog adm 2099363 Mar 26 06:25 auth.log.3.gz
-rw-r----- 1 syslog adm 3433467 Mar 20 06:25 auth.log.4.gz
-rw-r--r-- 1 root root 0 Apr 10 11:00 bandwidth
-rw-r--r-- 1 root root 57457 Jul 19 2016 bootstrap.log
-rw------- 1 root utmp 384 Apr 7 10:36 btmp
-rw------- 1 root utmp 933888 Mar 18 13:36 btmp.1
drwxr-xr-x 2 clamav clamav 4096 Apr 9 06:25 clamav
drwxr-xr-x 2 root root 4096 Apr 26 2016 dist-upgrade
-rw-r----- 1 root adm 31 Jul 19 2016 dmesg
-rw-r--r-- 1 root root 41011 Apr 10 08:15 dpkg.log
-rw-r--r-- 1 root root 227634 Mar 31 14:36 dpkg.log.1
-rw-r--r-- 1 root root 21382 Feb 28 21:52 dpkg.log.2.gz
-rw-r--r-- 1 root root 58764 Jan 27 15:10 dpkg.log.3.gz
-rw-r--r-- 1 root root 32032 Mar 10 16:36 faillog
-rw-r--r-- 1 root root 588 Feb 21 17:07 fontconfig.log
drwxr-xr-x 2 root root 4096 Jan 17 22:06 fsck
drwxr-xr-x 3 root root 4096 Jan 17 22:17 installer
-rw-r----- 1 syslog adm 1113870 Apr 10 11:39 kern.log
-rw-r----- 1 syslog adm 7790596 Apr 9 06:23 kern.log.1
-rw-r----- 1 syslog adm 998131 Apr 2 06:25 kern.log.2.gz
-rw-r----- 1 syslog adm 663229 Mar 26 06:24 kern.log.3.gz
-rw-r----- 1 syslog adm 3932240 Mar 20 06:24 kern.log.4.gz
-rw-rw-r-- 1 root utmp 292292 Apr 7 10:36 lastlog
drwxr-xr-x 2 root root 4096 Jun 30 2016 lxd
-rw-r----- 1 syslog adm 0 Feb 6 06:25 mail.err
-rw-r----- 1 syslog adm 105 Feb 3 10:24 mail.err.1
-rw-r----- 1 syslog adm 785 Jan 27 00:55 mail.err.2.gz
-rw-r----- 1 syslog adm 751 Jan 21 19:58 mail.err.3.gz
-rw-r----- 1 syslog adm 8476 Apr 10 09:47 mail.log
-rw-r----- 1 syslog adm 290793 Apr 9 00:00 mail.log.1
-rw-r----- 1 syslog adm 55658 Apr 2 00:00 mail.log.2.gz
-rw-r----- 1 syslog adm 30300 Mar 26 06:22 mail.log.3.gz
-rw-r----- 1 syslog adm 23429 Mar 20 00:00 mail.log.4.gz
drwxrws--- 2 root list 4096 Apr 9 06:25 mailman
drwxr-xr-x 2 mongodb debian-spamd 4096 Apr 9 06:25 mongodb
drwxr-x--- 2 mysql adm 4096 Apr 10 06:25 mysql
drwxr-xr-x 2 www-data www-data 4096 Apr 9 06:25 nginx
drwxrwxr-t 2 root postgres 4096 Jan 22 06:25 postgresql
-rw-r--r-- 1 root root 372 Apr 10 06:57 procmail.log
-rw-r--r-- 1 root root 306 Apr 10 00:00 procmail.log.1.gz
-rw-r--r-- 1 root root 307 Apr 9 00:00 procmail.log.2.gz
-rw-r--r-- 1 root root 310 Apr 8 00:00 procmail.log.3.gz
-rw-r--r-- 1 root root 309 Apr 7 00:00 procmail.log.4.gz
-rw-r--r-- 1 root root 310 Apr 6 00:00 procmail.log.5.gz
drwxr-xr-x 2 root root 4096 Apr 9 06:25 proftpd
-rw-r----- 1 syslog adm 645606 Apr 10 11:39 syslog
-rw-r----- 1 syslog adm 3262359 Apr 10 06:25 syslog.1
-rw-r----- 1 syslog adm 261921 Apr 9 06:25 syslog.2.gz
-rw-r----- 1 syslog adm 286213 Apr 8 06:25 syslog.3.gz
-rw-r----- 1 syslog adm 321555 Apr 7 06:25 syslog.4.gz
-rw-r----- 1 syslog adm 321139 Apr 6 06:25 syslog.5.gz
-rw-r----- 1 syslog adm 291409 Apr 5 06:25 syslog.6.gz
-rw-r----- 1 syslog adm 318186 Apr 4 06:25 syslog.7.gz
drwxr-xr-x 2 root root 4096 May 12 2016 sysstat
-rw-r----- 1 syslog adm 1043651 Apr 10 11:39 ufw.log
-rw-r----- 1 syslog adm 6978511 Apr 9 06:23 ufw.log.1
-rw-r----- 1 syslog adm 831489 Apr 2 06:25 ufw.log.2.gz
-rw-r----- 1 syslog adm 559149 Mar 26 06:24 ufw.log.3.gz
-rw-r----- 1 syslog adm 864901 Mar 20 06:24 ufw.log.4.gz
drwxr-x--- 2 root adm 4096 Apr 1 06:25 unattended-upgrades
drwx--x--x 2 root root 4096 Apr 9 06:25 virtualmin
-rw-rw-r-- 1 root utmp 8832 Apr 7 17:38 wtmp
-rw-rw-r-- 1 root utmp 42624 Mar 30 10:24 wtmp.1
-rw-r--r-- 1 root root 1145316 Feb 5 15:40 xferlog
ls -l /var/log/nginx/
total 4
-rw-r--r-- 1 www-data root 0 Apr 7 14:01 access.log
-rw-r----- 1 www-data adm 0 Apr 9 06:25 error.log
-rw-r--r-- 1 root root 395 Apr 9 06:25 error.log.1
当 nginx 创建文件时,它们都有 -rw-r--r-- 1 www-data root
当 nginx 添加信息时,文件权限更改为 -rw-r----- 1 www-data adm