RHEL 6 Initialize (1)
作者: reistlin
来源: http://www.reistlin.com/blog/431
更新时间: 2018.01
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要
# install RPM
yum install autoconf automake apr-util bind-utils curl gcc httpd-tools jwhois libtool libgssapi-devel lrzsz make mtr ntsysv openldap-devel openssl-devel pam-devel perl rpm-build screen sysstat tcpdump tcp_wrappers-devel tcp_wrappers-libs vim wget zlib-devel
# add user
useradd -u 500 reistlin; echo "密码" | passwd reistlin --stdin
# disable ipv6
echo "install ipv6 /bin/true" >> /etc/modprobe.d/disable-ipv6.conf echo "IPV6INIT=no" >> /etc/sysconfig/network
# disable iptables
sed -i "/SELINUX/s/enforcing/disabled/" /etc/selinux/config /etc/init.d/iptables stop iptables -P INPUT ACCEPT iptables -F chkconfig iptables off chkconfig ip6tables off
# libraries
echo "/usr/local/lib" >> /etc/ld.so.conf echo "/usr/local/lib64" >> /etc/ld.so.conf
# DNS
cat >>/etc/resolv.conf <<EOF # Google DNS nameserver 8.8.8.8 nameserver 8.8.4.4 EOF
# timezone
cp -a /etc/localtime /etc/localtime.default rm -f /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# profile
cat >>/etc/profile <<EOF # HisttimeFormat HISTFILESIZE=2048 HISTSIZE=2048 HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S " export HISTTIMEFORMAT # Editor export EDITOR=vim # LANG export LANG=zh_CN.UTF-8 EOF
# crontab
cat >>/var/spool/cron/root <<EOF # m h dom mon dow command #* * * * * /root/crontab/nginx.sh > /dev/null 2>&1 #* * * * * /root/crontab/php-fpm.sh > /dev/null 2>&1 #* * * * * /root/crontab/mysqld.sh > /dev/null 2>&1 #* * * * * /root/crontab/stunnel.sh > /dev/null 2>&1 #* * * * * /root/crontab/squid.sh > /dev/null 2>&1 #* * * * * /root/crontab/ss5.sh > /dev/null 2>&1 #* * * * * /root/crontab/kcp.ss.sh > /dev/null 2>&1 #* * * * * /root/crontab/kcp.squid.sh > /dev/null 2>&1 # NTP 59 1 * * * /usr/sbin/ntpdate 0.centos.pool.ntp.org > /dev/null 2>&1 59 2 * * * /usr/sbin/ntpdate 1.centos.pool.ntp.org > /dev/null 2>&1 59 3 * * * /usr/sbin/ntpdate 2.centos.pool.ntp.org > /dev/null 2>&1 EOF
# sshd
sed -i "s/#Port 22/Port 端口/" /etc/ssh/sshd_config sed -i "s/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/" /etc/ssh/sshd_config sed -i "s/#PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config sed -i "s/#StrictModes yes/StrictModes yes/" /etc/ssh/sshd_config
# logrotate
sed -i "s/rotate 1/rotate 6/" /etc/logrotate.conf sed -i "s/rotate 4/rotate 12/" /etc/logrotate.conf