- 浏览: 27343 次
- 性别:
- 来自: 北京
文章分类
最新评论
#!/bin/bash
#作者:duanyunxi
#版本:v2.0
touch /var/installserver.tmp
##开始准备工作##
echo "##开始准备工作!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`grep 'ready' /var/installserver.tmp`
if [ "$RETVAL" == "" ]; then
echo "##确认server_2.0的路径!##"
echo "请输入server_2.0所在的位置,例如:/home/server_2.0.tar.gz"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read SERVERPATH
echo "您输入server_2.0所在的位置是:$SERVERPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认server_2.0所在的位置后,重新输入:"
else
echo "server_2.0所在的位置为:$SERVERPATH"
fi
done
echo "##解压server_2.0!##"
cd /home
cp $SERVERPATH /home/server_2.0.tar.gz
tar xzf server_2.0.tar.gz
chmod 755 -R server_2.0
echo "ready ok!" >> /var/installserver.tmp
echo "准备工作已经完成!"
sleep 10
else
echo "准备工作已经做过!"
fi
fi
##开始安装JDK##
echo "##开始安装JDK!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'jdk'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
chmod u+x ./jdk-6u19-linux-i586.bin
./jdk-6u19-linux-i586.bin
mv jdk1.6.0_19 /usr/local/jdk
ln -s /usr/local/jdk/bin/java /usr/bin/java
ln -s /usr/local/jdk/bin/javac /usr/bin/javac
ln -s /usr/local/jdk/jre /usr/local/jre
echo "jdk has installed successfully!" >> /var/installserver.tmp
echo "JDK安装完成!"
sleep 10
else
echo "JDK已经安装过了!"
fi
fi
##开始配置JDK环境变量##
echo "##开始配置JDK环境变量!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /etc/profile|grep 'JAVA_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'JRE_HOME=/usr/local/jre' >> /etc/profile
echo 'PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' >> /etc/profile
echo 'CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:' >> /etc/profile
echo 'export JAVA_HOME JRE_HOME PATH CLASSPATH' >> /etc/profile
source /etc/profile
echo "JDK环境变量配置完成!"
else
echo "JDK环境变量已经配置过了!"
fi
java -version
fi
##开始安装resin##
echo "##开始安装resin!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'resin'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入resin的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "RESIN_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
cd /home/server_2.0
tar -zxvf resin-pro-3.1.10.tar.gz
cd resin-pro-3.1.10
./configure --prefix=/usr/local/resin --enable-jni
sleep 10
make
sleep 10
make install
sleep 10
RETVAL=`cat /etc/profile|grep 'RESIN_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'RESIN_HOME=/usr/local/resin' >> /etc/profile
echo 'export RESIN_HOME ' >> /etc/profile
source /etc/profile
echo "resin环境变量配置完成!"
fi
##duanyunxi
sed -i -e "s@8080@$PORT@" /usr/local/resin/conf/resin.conf
cp /home/server_2.0/resin.init /etc/init.d/resin
chmod +x /etc/init.d/resin
chkconfig --del resin && chkconfig --add resin
chkconfig resin on
echo "resin has installed successfully!" >> /var/installserver.tmp
echo "resin安装完成!"
sleep 10
else
echo "resin已经安装过了!"
fi
fi
##开始安装nginx##
echo "##开始安装nginx!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'nginx'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
tar -zxvf pcre-7.8.tar.gz
tar -zxvf zlib-1.2.2.tar.gz
tar zxvf openssl-0.9.8k.tar.gz
tar zxvf nginx-0.8.38.tar.gz
cd nginx-0.8.38/
./configure --prefix=/usr/local/nginx --with-pcre=/home/server_2.0/pcre-7.8 --with-zlib=/home/server_2.0/zlib-1.2.2 --with-openssl=/home/server_2.0/openssl-0.9.8k \
--with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module
sleep 10
make
sleep 10
make install
sleep 10
cp /home/server_2.0/nginx.init /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --del nginx && chkconfig --add nginx
chkconfig nginx on
echo "nginx has installed successfully!" >> /var/installserver.tmp
echo "nginx安装完成!"
else
echo "nginx已经安装过了!"
sleep 10
fi
fi
##开始安装mysql##
echo "##开始安装mysql!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'mysql'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
ENCODE=""
echo "请选择mysql的编码(g:gbk|u:utf8)?"
read ENCODE
if [ "$ENCODE" == "G" ] || [ "$ENCODE" == "g" ]; then
echo "您选择的编码是gbk,请确认(y|n)?"
ENCODE="gbk"
elif [ "$ENCODE" == "U" ] || [ "$ENCODE" == "u" ]; then
echo "您选择的编码是utf8,请确认(y|n)?"
ENCODE="utf8"
fi
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认后,重新输入:"
else
echo "MYSQL_ENCODE=$ENCODE" >> /var/installserver.tmp
echo "mysql的编码为:$ENCODE"
fi
done
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入mysql的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "MYSQL_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
DATAPATH=""
echo "请输入数据存放位置,例如:/var/data"
read DATAPATH
echo "您输入数据存放位置是:$DATAPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认数据存放位置后,重新输入:"
else
echo "DATA_PATH=$DATAPATH" >> /var/installserver.tmp
echo "数据存放位置为:$DATAPATH"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PASSWORD=""
echo "请输入mysql管理员用户root的密码?"
read PASSWORD
echo "您输入密码是:$PASSWORD,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认密码后,重新输入:"
else
echo "密码为:$PASSWORD"
fi
done
rm -rf /etc/my.cnf
groupadd mysql
useradd -g mysql mysql
cd /home/server_2.0
tar -zxvf mysql-5.1.45.tar.gz
cd mysql-5.1.45
./configure --prefix=/usr/local/mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-assembler --with-extra-charsets=gb2312,big5,utf8,binary,ascii --enable-thread-safe-client --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
sleep 10
make
sleep 10
make install
sleep 10
cp support-files/my-medium.cnf /etc/my.cnf
RETVAL=`cat /etc/my.cnf|grep 'default-character-set'`
if [ "$RETVAL" == "" ]; then
sed -i -e "s@\[client\]@\[client\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
sed -i -e "s@\[mysqld\]@\[mysqld\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
fi
##duanyunxi
sed -i -e "s@3306@$PORT@" /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
###duanyunxi
sed -i -e "40,50s@basedir=@basedir=/usr/local/mysql@" /etc/init.d/mysql
sed -i -e "40,50s@datadir=@datadir=$DATAPATH@" /etc/init.d/mysql
chkconfig --del mysql && chkconfig --add mysql
chkconfig mysql on
cd /usr/local/mysql
bin/mysql_install_db --user=mysql --datadir=$DATAPATH
chown -R root .
chown -R mysql var
chgrp -R mysql .
service mysql start
rm -rf /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
####duanyunxi
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
mysqladmin -u root password "$PASSWORD"
mysqladmin -h localhost -u root password "$PASSWORD"
mysqladmin -uroot -p$PASSWORD version 1> /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "mysql has installed successfully!" >> /var/installserver.tmp
echo "mysql安装完成!"
fi
touch /var/mysql.sql
echo "SET NAMES utf8;" >> /var/mysql.sql
echo "USE \`mysql\`;" >> /var/mysql.sql
echo "INSERT INTO \`user\` VALUES ('%','root',PASSWORD('$PASSWORD'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','N','N','N','','','','',0,0,0,0);" >> /var/mysql.sql
mysql -uroot -p$PASSWORD mysql</var/mysql.sql
rm -rf /var/mysql.sql
service mysql stop
sleep 10
else
echo "mysql已经安装过了!"
fi
fi
# ##设置防火墙##
# echo "##设置防火墙!##"
# if [ -f /var/installserver.tmp ]; then
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_TCP'|grep '80 8080 443 3306'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_TCP=\"\"@FW_SERVICES_EXT_TCP=\"80 8080 443 3306\"@" /etc/sysconfig/SuSEfirewall2
# fi
#
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_UDP'|grep '177'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
# fi
# rcSuSEfirewall2 restart
# echo "防火墙设置完成!"
# fi
######duanyunxi
##设置防火墙##
echo "##设置防火墙!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'SuSEfirewall2'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORTS=""
echo "请输入开放resin,mysql的端口号?(*空格隔开)"
read PORTS
echo "您输入端口号是:$PORTS,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认开放端口后,重新输入:"
else
echo "SuSEfirewall2_PORTS=$PORTS" >> /var/installserver.tmp
echo "SuSEfirewall2 has set successfully!" >> /var/installserver.tmp
echo "开放resin,mysql的端口有:$PORTS"
fi
sed -i -e "s@FW_SERVICES_EXT_TCP=\"@FW_SERVICES_EXT_TCP=\"$PORTS 80 22 443 @" /etc/sysconfig/SuSEfirewall2
sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
done
rcSuSEfirewall2 restart
echo "防火墙设置完成!"
fi
fi
echo "service resin (start|stop|restart)"
echo "service nginx (start|stop|restart)"
echo "service mysql (start|stop|restart|status)"
#作者:duanyunxi
#版本:v2.0
touch /var/installserver.tmp
##开始准备工作##
echo "##开始准备工作!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`grep 'ready' /var/installserver.tmp`
if [ "$RETVAL" == "" ]; then
echo "##确认server_2.0的路径!##"
echo "请输入server_2.0所在的位置,例如:/home/server_2.0.tar.gz"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read SERVERPATH
echo "您输入server_2.0所在的位置是:$SERVERPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认server_2.0所在的位置后,重新输入:"
else
echo "server_2.0所在的位置为:$SERVERPATH"
fi
done
echo "##解压server_2.0!##"
cd /home
cp $SERVERPATH /home/server_2.0.tar.gz
tar xzf server_2.0.tar.gz
chmod 755 -R server_2.0
echo "ready ok!" >> /var/installserver.tmp
echo "准备工作已经完成!"
sleep 10
else
echo "准备工作已经做过!"
fi
fi
##开始安装JDK##
echo "##开始安装JDK!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'jdk'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
chmod u+x ./jdk-6u19-linux-i586.bin
./jdk-6u19-linux-i586.bin
mv jdk1.6.0_19 /usr/local/jdk
ln -s /usr/local/jdk/bin/java /usr/bin/java
ln -s /usr/local/jdk/bin/javac /usr/bin/javac
ln -s /usr/local/jdk/jre /usr/local/jre
echo "jdk has installed successfully!" >> /var/installserver.tmp
echo "JDK安装完成!"
sleep 10
else
echo "JDK已经安装过了!"
fi
fi
##开始配置JDK环境变量##
echo "##开始配置JDK环境变量!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /etc/profile|grep 'JAVA_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'JRE_HOME=/usr/local/jre' >> /etc/profile
echo 'PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' >> /etc/profile
echo 'CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:' >> /etc/profile
echo 'export JAVA_HOME JRE_HOME PATH CLASSPATH' >> /etc/profile
source /etc/profile
echo "JDK环境变量配置完成!"
else
echo "JDK环境变量已经配置过了!"
fi
java -version
fi
##开始安装resin##
echo "##开始安装resin!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'resin'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入resin的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "RESIN_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
cd /home/server_2.0
tar -zxvf resin-pro-3.1.10.tar.gz
cd resin-pro-3.1.10
./configure --prefix=/usr/local/resin --enable-jni
sleep 10
make
sleep 10
make install
sleep 10
RETVAL=`cat /etc/profile|grep 'RESIN_HOME'`
if [ "$RETVAL" == "" ]; then
echo "" >> /etc/profile
echo 'RESIN_HOME=/usr/local/resin' >> /etc/profile
echo 'export RESIN_HOME ' >> /etc/profile
source /etc/profile
echo "resin环境变量配置完成!"
fi
##duanyunxi
sed -i -e "s@8080@$PORT@" /usr/local/resin/conf/resin.conf
cp /home/server_2.0/resin.init /etc/init.d/resin
chmod +x /etc/init.d/resin
chkconfig --del resin && chkconfig --add resin
chkconfig resin on
echo "resin has installed successfully!" >> /var/installserver.tmp
echo "resin安装完成!"
sleep 10
else
echo "resin已经安装过了!"
fi
fi
##开始安装nginx##
echo "##开始安装nginx!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'nginx'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
cd /home/server_2.0
tar -zxvf pcre-7.8.tar.gz
tar -zxvf zlib-1.2.2.tar.gz
tar zxvf openssl-0.9.8k.tar.gz
tar zxvf nginx-0.8.38.tar.gz
cd nginx-0.8.38/
./configure --prefix=/usr/local/nginx --with-pcre=/home/server_2.0/pcre-7.8 --with-zlib=/home/server_2.0/zlib-1.2.2 --with-openssl=/home/server_2.0/openssl-0.9.8k \
--with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module
sleep 10
make
sleep 10
make install
sleep 10
cp /home/server_2.0/nginx.init /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --del nginx && chkconfig --add nginx
chkconfig nginx on
echo "nginx has installed successfully!" >> /var/installserver.tmp
echo "nginx安装完成!"
else
echo "nginx已经安装过了!"
sleep 10
fi
fi
##开始安装mysql##
echo "##开始安装mysql!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'mysql'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
ENCODE=""
echo "请选择mysql的编码(g:gbk|u:utf8)?"
read ENCODE
if [ "$ENCODE" == "G" ] || [ "$ENCODE" == "g" ]; then
echo "您选择的编码是gbk,请确认(y|n)?"
ENCODE="gbk"
elif [ "$ENCODE" == "U" ] || [ "$ENCODE" == "u" ]; then
echo "您选择的编码是utf8,请确认(y|n)?"
ENCODE="utf8"
fi
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认后,重新输入:"
else
echo "MYSQL_ENCODE=$ENCODE" >> /var/installserver.tmp
echo "mysql的编码为:$ENCODE"
fi
done
#####duanyunxi-2010-10-28
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORT=""
echo "请输入mysql的端口号?(8000-8999)"
read PORT
if [ ${PORT} -lt 8000 ] || [ ${PORT} -gt 8999 ]; then
echo "您输入的端口号超出范围,重新输入:"
read PORT
fi
echo "您输入端口号是:$PORT,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认端口后,重新输入:"
else
echo "MYSQL_PORT=$PORT" >> /var/installserver.tmp
echo "端口为:$PORT"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
DATAPATH=""
echo "请输入数据存放位置,例如:/var/data"
read DATAPATH
echo "您输入数据存放位置是:$DATAPATH,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认数据存放位置后,重新输入:"
else
echo "DATA_PATH=$DATAPATH" >> /var/installserver.tmp
echo "数据存放位置为:$DATAPATH"
fi
done
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PASSWORD=""
echo "请输入mysql管理员用户root的密码?"
read PASSWORD
echo "您输入密码是:$PASSWORD,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认密码后,重新输入:"
else
echo "密码为:$PASSWORD"
fi
done
rm -rf /etc/my.cnf
groupadd mysql
useradd -g mysql mysql
cd /home/server_2.0
tar -zxvf mysql-5.1.45.tar.gz
cd mysql-5.1.45
./configure --prefix=/usr/local/mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-assembler --with-extra-charsets=gb2312,big5,utf8,binary,ascii --enable-thread-safe-client --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
sleep 10
make
sleep 10
make install
sleep 10
cp support-files/my-medium.cnf /etc/my.cnf
RETVAL=`cat /etc/my.cnf|grep 'default-character-set'`
if [ "$RETVAL" == "" ]; then
sed -i -e "s@\[client\]@\[client\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
sed -i -e "s@\[mysqld\]@\[mysqld\]\ndefault-character-set = $ENCODE@" /etc/my.cnf
fi
##duanyunxi
sed -i -e "s@3306@$PORT@" /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
###duanyunxi
sed -i -e "40,50s@basedir=@basedir=/usr/local/mysql@" /etc/init.d/mysql
sed -i -e "40,50s@datadir=@datadir=$DATAPATH@" /etc/init.d/mysql
chkconfig --del mysql && chkconfig --add mysql
chkconfig mysql on
cd /usr/local/mysql
bin/mysql_install_db --user=mysql --datadir=$DATAPATH
chown -R root .
chown -R mysql var
chgrp -R mysql .
service mysql start
rm -rf /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
####duanyunxi
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
mysqladmin -u root password "$PASSWORD"
mysqladmin -h localhost -u root password "$PASSWORD"
mysqladmin -uroot -p$PASSWORD version 1> /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "mysql has installed successfully!" >> /var/installserver.tmp
echo "mysql安装完成!"
fi
touch /var/mysql.sql
echo "SET NAMES utf8;" >> /var/mysql.sql
echo "USE \`mysql\`;" >> /var/mysql.sql
echo "INSERT INTO \`user\` VALUES ('%','root',PASSWORD('$PASSWORD'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','N','N','N','','','','',0,0,0,0);" >> /var/mysql.sql
mysql -uroot -p$PASSWORD mysql</var/mysql.sql
rm -rf /var/mysql.sql
service mysql stop
sleep 10
else
echo "mysql已经安装过了!"
fi
fi
# ##设置防火墙##
# echo "##设置防火墙!##"
# if [ -f /var/installserver.tmp ]; then
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_TCP'|grep '80 8080 443 3306'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_TCP=\"\"@FW_SERVICES_EXT_TCP=\"80 8080 443 3306\"@" /etc/sysconfig/SuSEfirewall2
# fi
#
# RETVAL=`cat /etc/sysconfig/SuSEfirewall2|grep 'FW_SERVICES_EXT_UDP'|grep '177'`
# if [ "$RETVAL" == "" ]; then
# sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
# fi
# rcSuSEfirewall2 restart
# echo "防火墙设置完成!"
# fi
######duanyunxi
##设置防火墙##
echo "##设置防火墙!##"
if [ -f /var/installserver.tmp ]; then
RETVAL=`cat /var/installserver.tmp|grep 'SuSEfirewall2'|grep 'successfully'`
if [ "$RETVAL" == "" ]; then
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
PORTS=""
echo "请输入开放resin,mysql的端口号?(*空格隔开)"
read PORTS
echo "您输入端口号是:$PORTS,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认开放端口后,重新输入:"
else
echo "SuSEfirewall2_PORTS=$PORTS" >> /var/installserver.tmp
echo "SuSEfirewall2 has set successfully!" >> /var/installserver.tmp
echo "开放resin,mysql的端口有:$PORTS"
fi
sed -i -e "s@FW_SERVICES_EXT_TCP=\"@FW_SERVICES_EXT_TCP=\"$PORTS 80 22 443 @" /etc/sysconfig/SuSEfirewall2
sed -i -e "s@FW_SERVICES_EXT_UDP=\"\"@FW_SERVICES_EXT_UDP=\"177\"@" /etc/sysconfig/SuSEfirewall2
done
rcSuSEfirewall2 restart
echo "防火墙设置完成!"
fi
fi
echo "service resin (start|stop|restart)"
echo "service nginx (start|stop|restart)"
echo "service mysql (start|stop|restart|status)"
发表评论
-
linux密码破解
2011-02-14 10:39 1229opsensuse-linux密码破解( ... -
名人博客
2011-01-05 15:28 649http://www.ha97.com/ http://don ... -
linux单网卡绑定多ip
2010-12-13 15:09 1465Linux给一个网卡绑定多个IP方法 1.Redhat系列( ... -
suse-linux定时备份数据库和文件shell脚本
2010-11-09 17:34 2670#!/bin/bash #2009-11-8 第一次编写 #作 ... -
crontab详解
2010-11-08 15:46 827crontab日志记录:/var/spool/mail/roo ... -
open-suse网络配置
2010-10-22 15:27 14911.ip配置 修改/etc/sysconfig/network ... -
Shell基本语法
2010-07-08 16:09 889一、Shell语法 1.1、变量 ...
相关推荐
centos7安装+tomcat+mysql+jdk+nginx配置步骤,按着步骤走傻子都能做出来,非常详细
【标题】"JDK+Tomcat+Mysql+Nginx后台软件"中涉及的主要知识点是构建Web服务环境的关键组件,包括Java开发环境JDK、Java应用服务器Tomcat、关系型数据库MySQL以及反向代理服务器Nginx。这些技术在现代Web开发中扮演...
标题和描述提到的“tomcat+mysql+jdk脚本安装”表明这是一个自动化安装过程,通过脚本来一次性设置这些组件,便于快速搭建开发或生产环境。下面将详细解释这三个组件以及它们的相互作用。 1. JDK(Java Development...
本篇将深入探讨如何将Java环境(JDK)、MySQL数据库、Tomcat应用服务器以及Web项目整合打包成一个RPM软件包,以便实现一键安装。 首先,让我们理解RPM的基本概念。RPM是一种用于安装、升级、查询、验证和卸载软件的...
总结,本指南详细介绍了JDK、Tomcat和MySQL的安装过程,以及如何配置相应的环境变量。这些是搭建Java Web开发环境的基础,对于后续的JEECMS或其他Java Web应用的开发和部署至关重要。每个步骤都需要仔细操作,确保每...
"JDK + Tomcat + MySQL环境集成工具"是一个组合了三个核心组件的解决方案,它们分别是Java Development Kit(JDK)、Apache Tomcat服务器和MySQL数据库。这个集成工具旨在简化开发和部署过程,帮助开发者快速建立一...
本文将详细介绍如何在CentOS上一键安装Java Development Kit (JDK)、MySQL数据库、Nginx web服务器、Tomcat应用服务器以及PHP编程环境。这些组件是构建高效、稳定的Web服务的基础。 ### 安装JDK 首先,我们需要安装...
本文档将详细介绍在 Linux 操作系统中如何安装配置 Java Development Kit (JDK)、MySQL 数据库服务器、Apache Tomcat 服务器以及 Nginx 负载均衡器,并进一步讲解如何构建一个简易的集群环境来支持高可用性和负载...
这个压缩包包含了"keepalived+nginx+tomcat+redis+mysql"所需的基础组件,特别是Java Development Kit(JDK)。下面我们将详细探讨这些组件及其在IT领域的应用。 首先,JDK是Java编程语言的基石,它提供了编译、...
JDK1.8+Tomcat8.5+Maven3.3.9+MySQL5.7,都是在Linux系统下搭建环境所需要的压缩包,需要的可以自行下载,配置详情,可以参看https://blog.csdn.net/weixin_40460171/article/details/106758629
### CentOS 6.5 + JDK 1.7 + MySQL 5.5 + Tomcat 7 + Nginx 1.7 安装手册 #### 一、JDK 1.7 安装 ##### 1.1 下载JDK 1.7 - 访问Oracle官方下载页面:...
Linux配置JDK+Tomcat+mysql的linux命令,首先先去官网下载
标题中的"一键安装jdk+mysql+hadoop+hive+zeppelin.rar"表明这是一个包含Java开发环境(JDK)、MySQL数据库、Hadoop分布式计算框架、Hive数据仓库工具以及Zeppelin交互式数据分析平台的一键安装包。这个压缩包为用户...
"JDK+TOMCAT+MYSQL+MyEclipse图文安装教程" 本文将对 JDK、Tomcat、MySQL 和 MyEclipse 的安装进行详细的讲解,旨在帮助读者快速安装和配置这些软件。 JDK 安装 JDK 是 Java 开发环境的核心组件,安装 JDK 是 ...
Linux 环境下 JDK、MySQL、Redis、Nginx 等应用部署 在 Linux 环境中部署 JDK、MySQL、Redis、Nginx 等...在 Linux 环境中部署 JDK、MySQL、Redis、Nginx 等应用需要遵循相应的步骤,确保每个应用的正确安装和配置。
JDK1.8安装与配置 准备工作: 我安装的ContOS8(版本:CentOS-Stream-8-x86_64-20191219-dvd1)没有默认安装 检查是否预装jdk,如果有请先卸载: yum -y remove java 确认安装版本: 注意jdk版本,不要安装错了,...
Linux服务器JavaEE开发环境搭建,包括(jdk+mysql+Tomcat)完整教程