AutoInstallRedis.sh
#!/bin/bash
echo
"##########################################"
echo
"Auto Install Redis ##"
echo
"Press Ctrl + C to cancel ##"
echo
"Any key to continue ##"
echo
"##########################################"
read
-n 1
/etc/init
.d
/iptables
stop
sed
-i
"s/SELINUX=enforcing/SELINUX=disabled/"
/etc/selinux/config
if
[ -d
/tools
];
then
cd
/tools
else
mkdir
/tools
&&
cd
/tools
fi
yum -y
install
wget
wget -c -O
/tools/redis
http:
//download
.redis.io
/releases/redis-3
.0.2.
tar
.gz
tar
-zxvf redis
cd
redis-3.0.2
make
cd
src/
make
test
make
install
cp
redis.conf
/etc/
cat
>>
/etc/init
.d
/redis
<< EOF
#!/bin/bash
source
/etc/init
.d
/functions
BIN=
"/usr/local/bin"
CONFIG=
"/etc/redis.conf"
PIDFILE=
"/var/run/redis.pid"
[ -r
"$SYSCONFIG"
] &&
source
"$SYSCONFIG"
RETVAL=0
prog=
"redis-server"
desc=
"Redis Server"
start() {
if
[ -e $PIDFILE ];
then
echo
"$desc already running...."
exit
1
fi
echo
-n $
"Starting $desc: "
daemon $BIN/$prog $CONFIG
RETVAL=$?
echo
[ $RETVAL -
eq
0 ] &&
touch
/var/lock/subsys/
$prog
return
$RETVAL
}
stop() {
echo
-n $
"Stop $desc: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -
eq
0 ] &&
rm
-f
/var/lock/subsys/
$prog $PIDFILE
return
$RETVAL
}
restart() {
stop
start
}
case
"$1"
in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -e
/var/lock/subsys/
$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo
$
"Usage: $0 {startstoprestartcondrestartstatus}"
RETVAL=1
esac
exit
$RETVAL
EOF
chmod
755
/etc/init
.d
/redis
sed
-i
"s/daemonize no/daemonize yes/g"
/etc/redis
.conf
chkconfig redis on
service redis start
echo
-e
"\033[32m Redis install success\033[0m"
netstat
-lntup |
grep
redis
5.3 AutoInstallMongodb.sh
#!/bin/bash
echo
"##########################################"
echo
"Auto Install Mongodb ##"
echo
"Press Ctrl + C to cancel ##"
echo
"Any key to continue ##"
echo
"##########################################"
read
-n 1
/etc/init
.d
/iptables
status >
/dev/null
2>&1
if
[ $? -
eq
0 ]
then
iptables -I INPUT -p tcp --dport 27017 -j ACCEPT &&
iptables -I INPUT -p tcp --dport 28017 -j ACCEPT &&
iptables-save >
/dev/null
2>&1
else
echo
-e
"\033[32m iptables is stopd\033[0m"
fi
sed
-i
"s/SELINUX=enforcing/SELINUX=disabled/"
/etc/selinux/config
setenforce 0
if
[ -d
/opt
];
then
cd
/opt
else
mkdir
/opt
&&
cd
/opt
fi
yum -y
install
wget
yum groupinstall
"Development tools"
-y
wget -c -O
/opt/mongodb
https:
//fastdl
.mongodb.org
/linux/mongodb-linux-x86_64-rhel62-3
.2.9.tgz
tar
-zxvf mongodb-linux-x86_64-rhel62-3.2.9.tgz
mv
mongodb-linux-x86_64-rhel62-3.2.9 mongodb
cd
mongodb
mkdir
log &&
mkdir
data
cd
log &&
touch
mongodb.log
cd
..
.
/bin/mongod
--httpinterface --dbpath
/opt/mongodb/data/
--logpath
/opt/mongodb/log/mongodb
.log --fork
echo
-e
"\033[32m Mongodb install success\033[0m"
netstat
-lntup |
grep
mongod
5.4 AutoInstallLighttpd.sh
echo
"##########################################"
echo
"Auto Install Lighttpd ##"
echo
"Press Ctrl + C to cancel ##"
echo
"Any key to continue ##"
echo
"##########################################"
read
-n 1
/etc/init
.d
/iptables
status >
/dev/null
2>&1
if
[ $? -
eq
0 ]
then
iptables -I INPUT -p tcp --dport 80 -j ACCEPT &&
iptables-save >
/dev/null
2>&1
else
echo
-e
"\033[32m iptables is stopd\033[0m"
fi
sed
-i
"s/SELINUX=enforcing/SELINUX=disabled/"
/etc/selinux/config
setenforce 0
if
[ -d
/tools
];
then
cd
/tools
else
mkdir
/tools
&&
cd
/tools
fi
yum -y
install
wget gcc
yum groupinstall
"Development tools"
-y
wget -c -O
/tools/lighttpd
http:
//download
.lighttpd.net
/lighttpd/releases-1
.4.x
/lighttpd-1
.4.41.
tar
.gz
yum -y
install
gcc pcre-devel zlib-devel vim
bzip2
-devel
cd
/tools/
tar
zxvf lighttpd
cd
lighttpd-1.4.41
.
/configure
--prefix=
/usr/local/lighttpd
make
&&
make
install
/etc/init
.d
/lighttpd
start
echo
-e
"\033[32m Lighttp install success\033[0m"
netstat
-lntup |
grep
lighttpd
5.5 AutoInstallMemcache.sh
#!/bin/bash
echo
"##########################################"
echo
"Auto Install memcached ##"
echo
"Press Ctrl + C to cancel ##"
echo
"Any key to continue ##"
echo
"##########################################"
read
-n 1
/etc/init
.d
/iptables
status >
/dev/null
2>&1
if
[ $? -
eq
0 ]
then
iptables -I INPUT -p tcp --dport 11211 -j ACCEPT &&
iptables-save >
/dev/null
2>&1
else
echo
-e
"\033[32m iptables is stopd\033[0m"
fi
sed
-i
"s/SELINUX=enforcing/SELINUX=disabled/"
/etc/selinux/config
setenforce 0
if
[ -d
/tools
];
then
cd
/tools
else
mkdir
/tools
&&
cd
/tools
fi
yum -y
install
wget gcc libevent libevent-devel
yum groupinstall
"Development tools"
-y
wget -c -O
/tools/memcached
http:
//memcached
.org
/files/memcached-1
.4.31.
tar
.gz
tar
-zxvf memcached
cd
memcached-1.4.31
.
/configure
make
make
install
/usr/local/bin/memcached
-d -u root
echo
-e
"\033[32m Memcache install success\033[0m"
netstat
-lntup |
grep
memcached