在CentOS7 RHEL 7 设置GRUB2菜单的超时时间

在CentOS7 RHEL 7 设置GRUB2菜单的超时时间
Update GRUB2 menu timeout on RHEL 7 Linux

系统启动期间GRUB2超时菜单选项的默认设置为5秒。 打开/etc/default/grub grub默认配置文件。
The default settings for the GRUB2 timeout menu selection during the system boot is 5 seconds. To change this value open /etc/default/grub grub default config file. The content of the file looks similar the the one shown below:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/root crashkernel=auto \
rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

自己动手给国内外各种云重装纯净版的CentOS7.x(2)

自己动手给国内外各种云重装纯净版的CentOS7.x(2)

一些基于openstack(阿里云云服务器ECS、百度云服务器BCC、京东云服务器,腾讯云服务器CVM,青云QingCloud)的架构使用上面的无法进行安装,那么就需要调整下配置参数才能进行自行重装

是对自己动手给国内外各种云重装纯净版的CentOS7.x的补充
需要自己动手给国内外各种云重装纯净版的CentOS7.x或者其他Linux系统

1、
wget -O /boot/vmlinuz.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/initrd.img

镜像也可以使用各大云服务提供商私有的(通过repo和私有DNS)
-------------------------------------------------------------------------------------------------
2、
cd /etc/grub.d

vi 40_custom

将下面的信息添加进去
menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
linux16 /boot/vmlinuz.centos.pxe inst.headless ip=dhcp nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /boot/initrd.img.centos.pxe
}

insmod ext2
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这四项信息需要查看/boot/grub2/grub.cfg具体来设置

如果磁盘用的是GPT格式的,需要添加inst.gpt选项。 If you are using GPT disk add inst.gpt option.
linux16 /vmlinuz.centos.pxe inst.gpt inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe

3、重新生成/boot/grub2/grub.cfg
grub2-mkconfig -o /boot/grub2/grub.cfg

4、设置默认启动项
grub2-set-default www.zhangfangzhou.cn

5、grub2-editenv list #查看确认

6、reboot
打开vnc连接选择启动项www.zhangfangzhou.cn就可以重装了


自己动手给国内外各种云重装纯净版的CentOS7.x

自己动手给国内外各种云重装纯净版的CentOS7.x
需要自己动手给国内外各种云重装纯净版的CentOS7.x或者其他Linux系统
前文 自己动手给国内外各种云重装纯净版的CentOS6.x

CentOS7使用的是grub2,/boot/grub2/grub.cfg (由grub2-mkconfig -o /boot/grub2/grub.cfg生成)
-----------------------------------------------------------------------------------------------
1、国内
wget -O /boot/vmlinuz.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/initrd.img

国外
wget -O /boot/vmlinuz.centos.pxe http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/images/pxeboot/initrd.img
-------------------------------------------------------------------------------------------------
2、cd /etc/grub.d
ls
00_header 01_users 20_linux_xen 30_os-prober 41_custom
00_tuned 10_linux 20_ppc_terminfo 40_custom README

vi 40_custom

将下面的信息添加进去
menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe headless ip=122.114.224.36 noipv6 netmask=255.255.255.0 gateway=122.114.224.1 dns=114.114.114.114 ksdevice=eth0 method=http://mirrors.aliyun.com/centos/7/os/x86_64/ devfs=nomount lang=en_US keymap=us
initrd16 /initrd.img.centos.pxe
}

上面的IP、掩码、网关、修改为你机器的就可以

set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这三项信息需要查看/boot/grub2/grub.cfg具体来设置

----------------
正规写法

menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe
}

insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这四项信息需要查看/boot/grub2/grub.cfg具体来设置

如果磁盘用的是GPT格式的,需要添加inst.gpt选项。 If you are using GPT disk add inst.gpt option.
linux16 /vmlinuz.centos.pxe inst.gpt inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe

CentOS 6 CentOS 7
vnc inst.vnc
vncpassword= inst.vncpassword=
Note: MUST at least 8 char
headless inst.headless
ip= ip=ip::gateway:netmask:hostname:interface:none
Example:
ip=10.0.0.10::10.0.0.1:255.255.255.0:host.example.com:eth0:none or ip=dhcp
gateway= See IP above
netmask= See IP above
dns= nameserver=
method= inst.repo=
lang= inst.lang=
keymap= inst.keymap=

你可以阅读整个选项变化
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-anaconda-boot-options
----------------

ls -l /etc/grub2.cfg
lrwxrwxrwx 1 root root 22 Oct 28 17:25 /etc/grub2.cfg -> ../boot/grub2/grub.cfg

3、重新生成/boot/grub2/grub.cfg
执行grub2-mkconfig -o /boot/grub2/grub.cfg

4、设置默认启动项
grub2-set-default www.zhangfangzhou.cn

5、grub2-editenv list #查看确认

6、reboot
打开vnc连接选择启动项www.zhangfangzhou.cn就可以重装了

7、信息补充
rhgb quiet
rhgb表示redhat graphics boot,就是会看到图片来代替启动过程中显示的文本信息,这些信息在启动后用dmesg也可以看到
quiet表示在启动过程中只有重要信息显示,类似硬件自检的消息不回显示

rhgb = redhat graphical boot - This is a GUI mode booting screen with
most of the information hidden while the user sees a rotating activity
icon spining and brief information as to what the computer is doing.
quiet = hides the majority of boot messages before rhgb starts. These
are supposed to make the common user more comfortable. They get alarmed
about seeing the kernel and initializing messages, so they hide them for
their comfort.

8、
也可以添加一些自定义的启动选项
menuentry "System shutdown" {
echo "System shutting down..."
halt
}

menuentry "System restart" {
echo "System rebooting..."
reboot
}

Linux服务器下rootkit后门检测工具chkrootkit安装使用

Linux服务器下rootkit后门检测工具chkrootkit安装使用
操作系统:CentOS6 7

一、安装编译工具包
yum install gcc gcc-c++ make glibc-static -y

二、安装chkrootkit
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz #下载软件包
tar -zxvf chkrootkit.tar.gz #解压
cd chkrootkit-0.52
make sense #安装
cd ..
mv chkrootkit-0.52 /usr/local/chkrootkit #拷贝到安装目录

三、使用chkrootkit

cd /usr/local/chkrootkit
./chkrootkit | grep INFECTED
出现INFECTED就说明系统可能有问题了

CentOS 7.x 可能会出现下面的提示,原因是系统默认缺少netstat命令chkrootkit: can't find `netstat'.
yum whatprovides *netstat #查看命令所在的安装包
yum install net-tools #安装netstat命令即可

自己动手给国内外各种云重装纯净版的CentOS6.x

自己动手给国内外各种云重装纯净版的CentOS6.x
随着互联网的发展,云计算规模越来越大,越来越大的公司开始做相关的产品,为了方便客户的使用很多云公司会优化使用的系统,(阿里云云服务器ECS、百度云服务器BCC、京东云服务器,腾讯云服务器CVM,青云QingCloud,景安云服务器和景安vps,快云服务器和快云vps)添加一些不必要的组件
为此需要自己动手给国内外各种云重装纯净版的CentOS6.9或者其他Linux系统

1、国内
wget -O /boot/vmlinuz.centos.pxe http://mirrors.aliyun.com/centos/6/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe http://mirrors.aliyun.com/centos/6/os/x86_64/images/pxeboot/initrd.img

国外
wget -O /boot/vmlinuz.centos.pxe http://repos-lax.psychz.net/centos/6/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe http://repos-lax.psychz.net/centos/6/os/x86_64/images/pxeboot/initrd.img

2、yum install grub -y
vi /boot/grub/menu.lst

修改default=0
把下面这段插入在hiddenmenu后面

title CentOS 6.9 www.zhangfangzhou.cn
root (hd0,0)
kernel /boot/vmlinuz.centos.pxe headless ip=23.225.182.142 noipv6 netmask=255.255.255.0 gateway=23.225.182.1 dns=8.8.8.8 ksdevice=eth0 method=http://repos-lax.psychz.net/centos/6/os/x86_64/ lang=en_US keymap=us
initrd /boot/initrd.img.centos.pxe

上面的IP、掩码、网关、修改为你机器的就可以

root (hd0,0)
kernel /boot/vmlinuz.centos.pxe
initrd /boot/initrd.img.centos.pxe
这三项信息需要查看/etc/grub.conf具体来设置

ls -l /etc/grub.conf
lrwxrwxrwx. 1 root root 22 Oct 18 08:53 /etc/grub.conf -> ../boot/grub/grub.conf

3、reboot
打开vnc连接就可以重装了

如果IP信息是通过DHCP的方式获取的,那么需要修改成下面的
title CentOS 6.9 www.zhangfangzhou.cn
root (hd0,0)
kernel /boot/vmlinuz.centos.pxe headless ip=dhcp dns=8.8.8.8 ksdevice=eth0 method=http://mirrors.aliyun.com/centos/6/os/x86_64/ lang=en_US keymap=us
initrd /boot/initrd.img.centos.pxe



CentOS源码编译安装Apache 2.4.26 和 Apache Subversion 1.9.6 并配置基于Apache的SVN多项目库

CentOS源码编译安装Apache 2.4.26 和 Apache Subversion 1.9.6 并配置基于Apache的SVN多项目库

#!/bin/bash
a=$(cat /proc/cpuinfo | grep 'model name'| wc -l)
apstable=2.4.26
yum -y install gcc make epel-release pcre-devel zlib-devel lynx openssl openssl-devel
cd ~
wget http://archive.apache.org/dist//httpd/httpd-$apstable.tar.gz
tar -zxvf httpd-$apstable.tar.gz;
cd ~
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
tar zxf apr-1.5.2.tar.gz && cp -fr ./apr-1.5.2 ./httpd-$apstable/srclib/apr
tar zxf apr-util-1.5.4.tar.gz && cp -fr ./apr-util-1.5.4 ./httpd-$apstable/srclib/apr-util
cd ~
cd httpd-$apstable;
./configure \
--prefix=/usr/local/apache \
--with-mpm=prefork \
--with-included-apr \
--with-ssl \
--with-pcre \
--enable-mime-magic \
--enable-proxy \
--enable-ssl=shared \
--enable-so \
--enable-dav \
--enable-deflate=shared \
--enable-ssl=shared \
--enable-expires=shared \
--enable-headers=shared \
--enable-rewrite=shared \
--enable-static-support \
--disable-userdir \
--enable-modules=all \
--enable-mods-shared=all
make -j$a
make install
......
......

yum -y install gcc gcc-c++ unzip
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
tar -zxvf apr-1.5.2.tar.gz;cd apr-1.5.2
cd apr-1.5.2
./configure --prefix=/usr/local/apr && make && make install

wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz;cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install

wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz;cd zlib-1.2.11
./configure --prefix=/usr/local/zlib && make && make install

wget http://apache.cs.utah.edu/subversion/subversion-1.9.6.tar.gz
tar -zxvf subversion-1.9.6.tar.gz;cd subversion-1.9.6
./get-deps.sh

单独使用
./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-zlib=/usr/local/zlib && make && make install

配合apache使用
./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-zlib=/usr/local/zlib -enable-mod-activation --with-apache-libexecdir=/usr/local/apache/modules --with-apxs=/usr/local/apache/bin/apxs --without-berkeley-db && make && make install

多项目配置
mkdir -p /var/www/svn #创建SVN目录
/usr/local/svn/bin/svnadmin create /var/www/svn/repos #创建repos版本库
/usr/local/svn/bin/svnadmin create /var/www/svn/android #创建android版本库
/usr/local/svn/bin/svnadmin create /var/www/svn/web #创建web版本库

/usr/local/apache/bin/htpasswd -c -b /var/www/svn/passwd admin 123456 #第一次创建文件和创建用户
/usr/local/apache/bin/htpasswd -b /var/www/svn/passwd admin2 123456 #添加用户
www.zhangfangzhou.cn

vi /var/www/svn/authz
[groups]
all = admin,rouser
[/]
admin2 = rw
@all = r

vi /usr/local/apache/conf/httpd.conf 默认 Subrsion 安装成功后会自动加上
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

DAV svn
SVNListParentPath on
SVNParentPath /var/www/svn
AuthzSVNAccessFile /var/www/svn/authz
AuthType Basic
AuthName "www.zhangfangzhou.cn SVN"
AuthUserFile /var/www/svn/passwd
Require valid-user

赋予权限
chown -R apache.apache /var/www/svn
chown -R apache.apache /usr/local/apache
重启服务
service httpd restart

/usr/local/apache/conf/httpd.conf: Cannot load modules/mod_dav_svn.so into server:
出现这个原因是因为没有加载#LoadModule dav_module modules/mod_dav.so

CentOS6.x YUM安装配置使用基于Apache的SVN多项目库

CentOS6.x YUM安装配置使用基于Apache的SVN多项目库

1、安装apache和svn
yum install httpd subversion mod_dav_svn -y
2、服务初始化配置
sed -i 's/^#ServerName www.example.com:80/ServerName localhost:80/' /etc/httpd/conf/httpd.conf
sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
service httpd start;chkconfig httpd on
chkconfig iptables off;service iptables stop

3、创建目录和项目目录
mkdir -p /var/www/svn #创建SVN目录
svnadmin create /var/www/svn/repos #创建repos版本库

单项目配置
cd /var/www/svn/repos/conf
htpasswd -c -b /var/www/svn/repos/conf/passwd admin 123456 第一次创建文件和创建用户
htpasswd -b /var/www/svn/repos/conf/passwd admin2 123456 添加用户

cat /var/www/svn/repos/conf/authz

[groups] #定义用户组,方便统一管理
all = admin,rouser #定义一个组叫做“all”,包含“admin”和“rouser”
[/] #定义svn版本库根目录权限(子目录继承根目录权限)
@all = r #用户组“all”中的所有用户有读权限
admin = rw #admin用户有读权限和写权限
rouser = r       #rouser有读权限

[groups]
all = admin,rouser
[repos:/]
admin2 = rw
@all = r

vi /var/www/svn/repos/conf/svnserve.conf
[general]
anon-access = none
auth-access = write
pasword-db = passwd
authz-db - authz

配置apache
cat /etc/httpd/conf.d/subversion.conf

DAV svn
SVNPath /var/www/svn/repos
AuthzSVNAccessFile /var/www/svn/repos/conf/authz
AuthType Basic
AuthName "www.zhangfangzhou.cn SVN"
AuthUserFile /var/www/svn/repos/conf/passwd
Require valid-user

赋予权限
chown -R apache.apache /var/www/svn
重启服务
service httpd restart

多项目配置
mkdir -p /var/www/svn #创建SVN目录
svnadmin create /var/www/svn/repos #创建repos版本库
svnadmin create /var/www/svn/android #创建android版本库
svnadmin create /var/www/svn/web #创建web版本库

htpasswd -c -b /var/www/svn/passwd admin 123456 #第一次创建文件和创建用户
htpasswd -b /var/www/svn/passwd admin2 123456 #添加用户

vi /var/www/svn/authz
[groups]
all = admin,rouser
[/]
admin2 = rw
@all = r

vi /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
#上面这两条一般默认存在

DAV svn
SVNListParentPath on
SVNParentPath /var/www/svn
AuthzSVNAccessFile /var/www/svn/authz
AuthType Basic
AuthName "www.zhangfangzhou.cn SVN"
AuthUserFile /var/www/svn/passwd
Require valid-user

赋予权限
chown -R apache.apache /var/www/svn
重启服务
service httpd restart

#如果开启安全上下文,那么需要同步安全上下文
chcon -R -t httpd_sys_content_t /var/www/html/svn

配置中有 SVNPath 与 SVNParentPath 两个选项.
SVNPath用于只有一个项目的情况,此时如果在主目录下面再建新项目,则不能访问.提示没有权限.
如果有多个项目的话,此时应该使用SVNParentPath来设置父目录来设置项目的父目录,这样子目录里面可以有多个项目了。然后auth文件里面可以定义子目录的权限。
apache的/etc/httpd/conf.d/subversion.conf 配置文件里面设置一个location就可以了

CentOS 6、CentOS 7 ,使用crontab和logrotate实现Nginx日志轮询(转存)

CentOS 6、CentOS 7 ,使用crontab和logrotate实现Nginx日志轮询(转存)

1、安装crontab
2、安装logrotate日志文件管理工具
3、分析cron.daily
4、Nginx日志轮询(转存)配置,Apache的类似
5、为什么日志轮询(转存)生成日志的时间是凌晨三四点
6、立即执行logratate
7、logratate常用配置参数

1、安装crontab
if ! which crond >/dev/null 2>&1;then yum install cronie -y; fi
systemctl enable crond

2、 安装logrotate日志文件管理工具
yum -y install logrotate
查看logrotate的软件包的信息
rpm -ql logrotate
/etc/cron.daily/logrotate
/etc/logrotate.conf
/etc/logrotate.d
.....
.....

3、分析cron.daily
cd /etc/cron.daily
[root@www.zhangfangzhou.cn cron.daily]# ls
logrotate makewhatis.cron
[root@www.zhangfangzhou.cn cron.daily]# tail logrotate
#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

4、Nginx日志轮询(转存)配置,Apache日志轮询(转存)类似。
/home/wwwlogs/ 网站日志目录

cat > /etc/logrotate.d/nginx << EOF
/home/wwwlogs/*log {
daily
rotate 5
missingok
dateext
compress
notifempty
sharedscripts
postrotate
    [ -e /usr/local/nginx/logs/nginx.pid ] && kill -USR1 \`cat /usr/local/nginx/logs/nginx.pid\`
endscript
}
EOF

5、为什么日志轮询(转存)生成日志的时间是凌晨三四点?
Logrotate是基于CRON运行的,所以这个时间是由CRON控制的,具体可以查询CRON的配置文件「/etc/crontab」
anacron 正在运行过去 crontab 未进行的各项工作排程

cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45 #最大延迟时间
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22 #只在03到22点之间执行

#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly

每天都执行/etc/cront.daily/目录下的脚本文件,
真实的延迟RANDOM_DELAY+delay。这里的延迟是5分钟,加上上面的RANDOM_DELAY,所以实际的延迟时间是5-50之间,开始时间为03-22点,
如果机器没关,那么一般就是在03:05-03:50之间执行。nice命令将该进程设置为nice=10,默认为0,即低优先级进程。
如果RANDOM_DELAY=0,那么表示准确延迟5min,即03:05执行cron.daily

6、立即执行logratate
ldconfig #执行
或者
/etc/cron.daily
logrotate
或者
执行下面
/usr/sbin/logrotate -f /etc/logrotate.d/nginx

由于logratate已经加到cron.daily(/etc/cron.daily/logrotate),不再需要加到计划任务中

7、logratate常用配置参数
/home/wwwlogs/*log:需要轮询日志路径
daily:每天轮询
rotate 5:保留最多5次滚动的日志
missingok:如果日志丢失,不报错继续滚动下一个日志
dateext:使用日期作为命名格式
compress:通过gzip压缩转储以后的日志
notifempty:当日志为空时不进行滚动
/usr/local/nginx/logs/nginx.pid: nginx pid位置,请查看nginx.conf
postrotate/endscript:在截断转储以后需要执行的命令

CentOS 7 可能出现如下问题
error: skipping "/home/wwwlogs/access_nginx.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
解决方案
vi /etc/logrotate.d/nginx
su $http_user $http_group
su www www