echo -n $"Shutting down Tomcat Java server: "
daemon su -c /usr/local/tcstop.sh tomcat
echo
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
保存并退出
#touch /usr/local/tcstart.sh
#!/bin/bash
export JDK_HOME=/usr/local/jdk
export JAVA_HOME=/usr/local/jdk
#startup tomcat server
/usr/local/tomcat/bin/startup.sh
保存并退出
#chmod 755 /usr/local/tcstart.sh
#touch /usr/local/tcstart.sh
#!/bin/bash
export JDK_HOME=/usr/local/jdk
export JAVA_HOME=/usr/local/jdk
#stop tomcat server
/usr/local/tomcat/bin/shutdown.sh
保存并退出
#chmod 755 /usr/local/tcstop.sh
7.创建安全的科威WEB运行环境
(1).阻止你的系统响应任何从外部/内部来的ping请求
#vi /etc/rc.d/rc.local
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
(2).减少系统CPU占有量和由于误操作导致系统重启
#vi /etc/inittab
id:3:initdefault:
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now
保存并退出
(3). 删除不必要的拥护和组
#userdel –r username
adm,lp,sync,shutdown,halt,mail,procmail,mailx,news,uucp,operator,games,gopher,ftp
#groupdel groupname
adm,lp,sync,shutdown,halt,mail,procmail,mailx,news,uucp,operator,games,gopher,ftp
(4). 创建ftp账户
#groupadd su
#useradd –g su –d /usr/local/apache/htdocs webserver
(5). 用chattr命令给下面的文件加上不可更改属性。
[root@deep]# chattr +i /etc/passwd
[root@deep]# chattr +i /etc/shadow
[root@deep]# chattr +i /etc/group
[root@deep]# chattr +i /etc/gshadow
(6).禁止任何人(非法)通过su命令改变为root用户
#vi /etc/pam.d/su
auth sufficient /lib/security/pam_rootok.so debug
auth required /lib/security/pam_wheel.so group=sul
保存并退出
这样之后,只有su组成员可以改变为root用户
(7).资源限制防止DoS类型攻击
#vi /etc/security/limits.conf
在这个文件后加入下面
* hard core 0
* hard rss 5000
* hard nproc 20
保存并退出
#vi /etc/pam.d/login
在这个文件后加入下面
session required /lib/security/pam_limits.so
保存并退出
(8)加上web服务器的防火#!/bin/sh
#
# Generated iptables firewall script for the Linux 2.4 kernel
# Script generated by Easy Firewall Generator for IPTables
# copyright 2002 Timothy Scott Morizot
#
# Redhat chkconfig comments - firewall applied early,
# removed late
# chkconfig: 2345 08 92
# description: This script applies or removes iptables firewall rules
#
# This generator is primarily designed for RedHat installations,
# although it should be adaptable for others.
#
# It can be executed with the typical start and stop arguments.
# If used with stop, it will stop after flushing the firewall.
# The save and restore arguments will save or restore the rules