当我在Ubuntu环境下开发时,我得到了一个警告,说服务器很快就会被淘汰。 所以我跟踪了哪个文件在磁盘上占用了太多的空间。 而且我能够发现在etc/nginx下面有一个文件名。 (我正在使用nginx)
这个文件是做什么的? 这个文件占用了7.7G,其types是ASCII文本,很长的行(我通过使用file *命令)
我想通过删除这个文件来pipe理服务器的存储。 这样做是否安全? 我不能只是不断增加服务器的存储空间。
如果有什么看起来可疑和错误的,任何build议和意见,将不胜感激。
先谢谢你。
这里是nginx.conf
user www-data; worker_processes auto; error_log /var/log/nginx/error.log crit; pid /var/run/nginx.pid; events { worker_connections 4000; use epoll; multi_accept on; } http { # cache informations about FDs, frequently accessed files # can boost performance, but you need to test those values open_file_cache max=200000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; # to boost IO on HDD we can disable access logs access_log on; access_log /var/log/nginx/access.log; sendfile on; tcp_nopush on; tcp_nodelay on; types_hash_max_size 2048; server_tokens off; include /etc/nginx/mime.types; default_type application/octet-stream; gzip on; gzip_min_length 10240; gzip_proxied expired no-cache no-store private auth; #gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml; gzip_types text/plain text/css application/javascript text/xml application/xml+rss; gzip_disable "MSIE [1-6]\."; gzip_vary on; client_body_buffer_size 10K; client_header_buffer_size 1k; client_max_body_size 20m; large_client_header_buffers 2 1k; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; # limit the number of connections per single IP limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m; # limit the number of requests for a given session limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s; # zone which we want to limit by upper values, we want limit whole server server { limit_conn conn_limit_per_ip 10; limit_req zone=req_limit_per_ip burst=10 nodelay; # Expire rules for static content # cache.appcache, your document html and data location ~* \.(?:manifest|appcache|html?|xml|json)$ { expires -1; # access_log logs/static.log; # I don't usually include a static log } # Feed location ~* \.(?:rss|atom)$ { expires 1h; add_header Cache-Control "public"; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { expires 1M; access_log off; add_header Cache-Control "public"; } # CSS and Javascript location ~* \.(?:css|js)$ { expires 1y; access_log off; add_header Cache-Control "public"; } } # server will close connection after this time -- default 75 keepalive_timeout 30; # number of requests client can make over keep-alive -- for testing environment keepalive_requests 100000; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
检查存储
/etc/nginx# ls -alSh total 7.7G -rw-r--r-- 1 www-data root 7.7G Sep 20 00:36 on drwxr-xr-x 126 root root 12K Sep 15 16:15 .. drwxr-xr-x 5 root root 4.0K Jul 6 13:44 . drwxr-xr-x 2 root root 4.0K May 26 02:13 conf.d drwxr-xr-x 2 root root 4.0K Jul 6 13:42 sites-enabled drwxr-xr-x 4 root root 4.0K Nov 15 2016 ssl -rw-r--r-- 1 root root 3.9K Apr 26 01:48 mime.types -rw-r--r-- 1 root root 3.6K Sep 13 2016 win-utf -rw-r--r-- 1 root root 3.5K Nov 19 2016 docker_default -rw-r--r-- 1 root root 2.8K Jul 6 13:44 nginx.conf -rw-r--r-- 1 root root 2.8K Sep 13 2016 koi-utf -rw-r--r-- 1 root root 2.2K Sep 13 2016 koi-win -rw-r--r-- 1 root root 1007 Sep 13 2016 fastcgi_params -rw-r--r-- 1 root root 664 Sep 13 2016 uwsgi_params -rw-r--r-- 1 root root 636 Sep 13 2016 scgi_params -rw-r--r-- 1 root root 417 Dec 1 2016 Dockerfile lrwxrwxrwx 1 root root 22 Sep 13 2016 modules -> /usr/lib/nginx/modules
找出它是什么types
/etc/nginx# file * conf.d: directory docker_default: ASCII text, with very long lines Dockerfile: UTF-8 Unicode text fastcgi_params: ASCII text koi-utf: C source, ASCII text koi-win: C source, ASCII text mime.types: ASCII text modules: symbolic link to `/usr/lib/nginx/modules' nginx.conf: ASCII text on: ASCII text, with very long lines scgi_params: ASCII text sites-enabled: directory ssl: directory uwsgi_params: ASCII text win-utf: C source, ASCII text
据我所知,但我可能是错的,不存在这样的指令: access_log on;
我怀疑这个指令让NGinx写访问日志文件on而不是使用access_log /var/log/nginx/access.log;指定的文件access_log /var/log/nginx/access.log;
访问日志可以使用access_log off; ,这是一个现有的指令。
保持访问日志删除access_log on; ,那么它会将日志写入access_log指令中指定的文件中: access_log /var/log/nginx/access.log;
回答:是的,删除这个文件是安全的(或者备份它 – 在别处移动 – 如果你想跟踪这些访问日志)。