centos7作为web服务器优化
- - 操作系统 - ITeye博客centos7作为web服务器优化. 1、关闭firewalld:. systemctl stop firewalld.service #停止firewall. systemctl disable firewalld.service #禁止firewall开机启动. 2、安装iptables防火墙.
systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动
yum install iptables-services #安装 iptables -nvL #查看信息
ulimit -n ulimit -a vi /etc/security/limits.conf
vi /etc/security/limits.d/20-nproc.conf #加大普通用户限制 也可以改为unlimited * soft nproc 40960 root soft nproc unlimited
vi /etc/sysctl.conf
# Disable IPv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 # Determines how often to check for stale neighbor entries. net.ipv4.neigh.default.gc_stale_time=120 # Using arp_announce/arp_ignore to solve the ARP Problem net.ipv4.conf.default.arp_announce = 2 net.ipv4.conf.all.arp_announce=2 vm.swappiness = 0 net.ipv4.tcp_max_tw_buckets = 5000 net.ipv4.tcp_max_syn_backlog = 1024 net.ipv4.tcp_synack_retries = 2 net.ipv4.conf.lo.arp_announce=2 net.ipv4.tcp_keepalive_time = 1800 net.ipv4.tcp_keepalive_probes = 3 net.ipv4.tcp_keepalive_intvl = 15 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 30 执行下面命令生效 /sbin/sysctl -p
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ntpdate us.pool.ntp.org crontab -e 0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP service crond restart
groupadd test useradd -d /home/www/ -g test test1 passwd test1
vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 6666 -j ACCEPT
把 PermitRootLogin yes 改为 PermitRootLogin no
禁止 echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all 开启 echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all #永久保存 vi /etc/rc.d/rc.local echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all
bash: ifconfig: 未找到命令 yum -y install net-tools