说明:

用平常的方式在Linux服务器上安装程序,需要下载安装包、进入安装包位置、给安装包文件赋予可执行权限、执行安装、设置环境变量……等等一系列复杂的操作。并且如果有关联也需要一个一个的挨着安装。耗时并且繁琐。而用shell脚本来执行这些操作,则很好的解决了这些问题!

步骤:

  1. wget http://img006.com/badusoft/centosupNEW.sh

    // 在Linux服务器上执行wget命令下载shell脚本

  2. chmod +x centosupNEW.sh

    // 给下载下来的 centosupNEW.sh 文件赋可执行权限

  3. ./centosupNEW.sh all

    //执行命令安装所有程序,还可单独安装nginx、redis、tomcat等,如想单独安装resin,则执行 ./centosupNEW.sh resin 命令即可

截图:

代码:

#!/bin/bash
#version1.0
#Wangwei
#date 2015/04/02
#System Centos6.4
get_bin_tar="/bin/tar"
get_cmd_dns="/etc/resolv.conf"
get_cmd_soft="/opt/badusoft"
get_cmd_name=`/bin/uname -a | awk '{print $1,$3}'`
get_cmd_service="/usr/local/service"
get_cmd_user=`whoami`
get_cmd_cron="/var/spool/cron/"
get_cmd_url="http://img006.com/badusoft"
echo -e "System for version:\e[32m$get_cmd_name \e[0m\n"
echo -e "Nginx for version:\e[32mTengine2.1 and nginx 1.8.0\e[0m\n"
echo -e "Java for version:\e[32mJdk 1.7\e[0m\n"
echo -e "Resin pro for version:\e[32mResin pro 3.1\e[0m\n"
echo -e "Apache for tomcat version:\e[32m tomcat 7\e[0m\n"
echo -e "Redis version:\e[32m Redis 2.8\e[0m\n"
echo -e "Firewall:\e[32moff\e[0m\n"
cat /dev/null > $get_cmd_dns
echo "nameserver 114.114.114.114" >> $get_cmd_dns
echo -e "NameServer:\e[32m114.114.114.114\e[0m\n"
sleep 10
/etc/init.d/iptables stop
/sbin/chkconfig iptables off
function package(){
for i in wget gcc gcc-c++ make gzip autoconf automake lrzsz telnet zlib zlib-devel openssl openssl-devel pcre-devel pcre patch net-snmp
do
yum install -y $i
sleep 1
done
} function del(){
if [ ! -d $get_cmd_soft ] && [ ! -d $get_cmd_service ]; then
mkdir /opt/badusoft >> /dev/null 2>&1
mkdir /usr/local/service/ >> /dev/null 2>&1
else
rm -rf $get_cmd_soft $get_cmd_service
cp -f /etc/profile.bak /etc/profile
mkdir /opt/badusoft >> /dev/null 2>&1
mkdir /usr/local/service/ >> /dev/null 2>&1
fi
}
function timecron(){
#date cron
if [ $get_cmd_user = "root" ];then
echo "*/30 * * * * /usr/sbin/ntpdate 0.rhel.pool.ntp.org | /usr/sbin/hwclock -w" > $get_cmd_cron/$get_cmd_user
else
if [ -f "$get_cmd_cron/root" ];then
echo "*/30 * * * * /usr/sbin/ntpdate 0.rhel.pool.ntp.org | /usr/sbin/hwclock -w" >> $get_cmd_cron/$get_cmd_user
else
echo "$get_cmd_user error"
return 0
fi
fi
} function sysctl(){
cd $get_cmd_soft
if [ ! -f kernels_sysctl ] && [ ! -f limits.conf ];then
wget $get_cmd_url/kernels_sysctl
wget $get_cmd_url/limits.conf
if [ -f $get_cmd_soft/kernels_sysctl ] && [ -f $get_cmd_soft/limits.conf ];then
#cp -f /etc/sysctl.conf /etc/sysctl.conf.bak
#cp -f /etc/security/limits.conf /etc/security/limits.conf
cat $get_cmd_soft/kernels_sysctl > /etc/sysctl.conf
cp -f $get_cmd_soft/limits.conf /etc/security/limits.conf
/sbin/sysctl -p
if [ $? -eq 0 ];then
echo -e "\e[32mcopy done\e[0m\n"
sleep 5
else
echo -e "\e[31m copy error!!\e[0m\n"
exit 0
fi
else
echo -e "\e[31mfile not exits\[0m\n"
exit 0
fi
else
echo -e "\e[31mfile exists\e[0m\n"
exit 0
fi
}
function nginx(){
cd $get_cmd_soft
if [ ! -f nginx-1.8.0.tar.gz ];then
wget $get_cmd_url/nginx-1.8.0/nginx-1.8.0.tar.gz
wget $get_cmd_url/nginx-1.8.0/nginx_upstream_check_module-master.zip
wget $get_cmd_url/nginx-1.8.0/openssl-1.0.2c.tar.gz
wget $get_cmd_url/nginx-1.8.0/ngx_cache_purge-2.3.tar.gz
wget $get_cmd_url/pcre-8.12.tar.gz
wget $get_cmd_url/zlib-1.2.5.tar.gz if [ $? -eq 0 ];then $get_bin_tar zxf nginx-1.8.0.tar.gz
unzip nginx_upstream_check_module-master.zip
$get_bin_tar zxf openssl-1.0.2c.tar.gz
$get_bin_tar zxf ngx_cache_purge-2.3.tar.gz
$get_bin_tar zxf pcre-8.12.tar.gz
$get_bin_tar zxf zlib-1.2.5.tar.gz if [ $? -eq 0 ];then
cd $get_cmd_soft/nginx-1.8.0 patch -p1 < $get_cmd_soft/nginx_upstream_check_module-master/check_1.7.5+.patch
./configure --prefix=$get_cmd_service/nginx \
--with-pcre=$get_cmd_soft/pcre-8.12 \
--with-openssl=$get_cmd_soft/openssl-1.0.2c \
--with-zlib=$get_cmd_soft/zlib-1.2.5 \
--add-module=$get_cmd_soft/ngx_cache_purge-2.3 \
--with-http_realip_module \
--with-http_sub_module \
--with-http_flv_module \
--with-http_dav_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_addition_module \
--with-http_ssl_module \
--add-module=$get_cmd_soft/nginx_upstream_check_module-master if [ $? -eq 0 ];then
make && make install
if [ $? -eq 0 ];then
echo -e "\e[32mtengine for nginx install done\e[0m\n"
sleep 5
else
echo -e "\e[31mmake && make error!!\e[0m\n"
fi
else
echo -e "\e[31mconfigure error!!\e[0m\n"
exit 0
fi
else
echo -e "\e[31mtar error!!\e[0m\n"
exit 0
fi
else
echo -e "\e[31mtengine for nginx download error!!\e[0m\n"
exit 0
fi
else
sleep 5
echo -e "\e[31mtengine for nginx found\e[0m\n"
fi
}
function java(){
cd $get_cmd_soft
if [ ! -f server-jre-7u80-linux-x64.tar.gz ];then
wget $get_cmd_url/javapath
wget $get_cmd_url/server-jre-7u80-linux-x64.tar.gz
$get_bin_tar zxf server-jre-7u80-linux-x64.tar.gz
if [ $? -eq 0 ];then
mv jdk1.7.0_80 $get_cmd_service/java
cp -f /etc/profile /etc/profile.bak
cat $get_cmd_soft/javapath >> /etc/profile
source /etc/profile
if [ $? -eq 0 ];then
$get_cmd_service/java/bin/java -version
if [ $? -eq 0 ];then
echo -ne "\e[32mJava install done\e[0m\n"
sleep 5
else
echo -ne "\e[31mJava install error!!\e[0m\n"
exit 0
fi
else
echo -ne "\e[31mJava path error!!\e[0m\n"
fi
else
echo -ne "\e[31mJava tar error!!\e[0m\n"
exit 0
fi else
echo -ne "\e[31mJava download error\e[0m\n"
exit 0
fi } function resin(){
cd $get_cmd_soft
if [ ! -f resin-pro-3.1.12.tar.gz ];then
wget $get_cmd_url/licenses/004444.license
wget $get_cmd_url/resin-pro-3.1.12.tar.gz
if [ $? -eq 0 ];then
$get_bin_tar zxvf resin-pro-3.1.12.tar.gz
if [ $? -eq 0 ];then
cd $get_cmd_soft/resin-pro-3.1.12
./configure --prefix=$get_cmd_service/resin \
--with-java-home=$get_cmd_service/java \
--enable-64bit=yes \
--enable-lfs \
--enable-jni \
--disable-libtool-lock if [ $? -eq 0 ];then
make && make install
mkdir $get_cmd_service/resin/licenses
cp $get_cmd_soft/004444.license $get_cmd_service/resin/licenses
if [ $? -eq 0 ];then
echo -ne "\e[32mResin install done\e[0m\n"
sleep 5
else
echo -ne "\e[31mResin install error\e[0m\n"
exit 0
fi
else
echo -ne "\e[31mConfigure error\e[0m\n"
exit 0
fi
else
echo -ne "\e[31mtar error\e[0m\n"
exit 0
fi
else
echo -ne "\e[31mdownload error\e[0m\n"
exit 0
fi
else
echo -ne "\e[31mDircetory or Resin error!!\e[0m\n"
exit 0
fi
}
function tomcat(){
mkdir /usr/local/service/apache2 cd /opt/badusoft/ wget http://img006.com/badusoft/apr-1.5.2.tar.zip
wget http://img006.com/badusoft/apr-iconv-1.2.1.tar.bz2
wget http://img006.com/badusoft/apr-util-1.5.4.tar.bz2
wget http://img006.com/badusoft/tomcat-native.tar.gz
wget http://img006.com/badusoft/apache-tomcat-7.0.42.tar.gz tar -xvf apr-1.5.2.tar.bz2
tar -xvf apr-iconv-1.2.1.tar.bz2
tar -xvf apr-util-1.5.4.tar.bz2
tar -xvf tomcat-native.tar.gz
tar -xvf apache-tomcat-7.0.42.tar.gz mv /opt/badusoft/apache-tomcat-7.0.42 /usr/local/service/tomcat cd /opt/badusoft/apr-1.5.2 ./configure --prefix=/usr/local/service/apache2/apr make && make install echo "APR step over" ############################################################### cd /opt/badushot/apr-util-1.5.4 ./configure --prefix=/usr/local/service/apache2/apr --with-apr=/usr/local/service/apache2/apr make && make install echo "apr-util step over"
############################################################################## cd /opt/badusoft/tomcat-native-1.1.33-src/jni/native ./configure --prefix=/usr/local/service/apache2/apr --with-apr=/usr/local/service/apache2/apr --with-java-home=/usr/local/service/java make && make install echo "tomact-native step over" echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/service/apache2/apr/lib" >> /etc/profile source /etc/profile cd /opt/badusoft/ wget http://img006.com/badusoft/catalina.txt sed -i '/# limitations under the License./r catalina.txt' /usr/local/service/tomcat/bin/catalina.sh }
function redis(){
cd $get_cmd_soft
if [ ! -f redis-2.8.12.tar.gz ];then
wget $get_cmd_url/redis-2.8.12.tar.gz
if [ $? -eq 0 ];then
tar zxf redis-2.8.12.tar.gz
if [ $? -eq 0 ];then
cd $get_cmd_soft/redis-2.8.12
make && make install
if [ $? -eq 0 ];then
mkdir $get_cmd_service/redis/
mkdir $get_cmd_service/redis/conf
mv /usr/local/bin $get_cmd_service/redis/
cp -f $get_cmd_soft/redis-2.8.12/redis.conf $get_cmd_service/redis/conf/
echo -e "\e[32m Redis install done\e[0m\n"
sleep 5
else
echo -e "\e[31m make && make install error!!\e[0m\n"
exit 0
fi
else
echo -e "\e[31m tar error\e[0m\n"
exit 0
fi else
echo -e "\e[31m Download Redis error!!\e[0m\n"
exit 0
fi
else
echo -e "\e[31m Redis file error!!\e[0m\n"
exit 0
fi
} case $1 in package)
package
;; timecron) package
del
timecron
;; sysctl) package
del
sysctl
;; nginx)
package
del
nginx
;; resin)
package
del
java
resin ;;
tomcat) package
del
java
tomcat ;;
redis)
package
del
redis
;; all)
package
del
timecron
sysctl
nginx
java
resin
tomcat
redis
;; *)
echo -e "\e[32m package timecron sysctl nginx resin tomcat redis or all\e[0m\n"
;;
esac cd /opt/badusoft/ wget http://img006.com/badusoft/service.sh chmod +x service.sh /opt/badusoft/service.sh
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400

Shell脚本实现超简洁的在Linux服务器上安装nginx、resin、java、tomcat、redis等程序的更多相关文章

  1. Dell Omsa在Linux服务器上安装部署

    前言 本页详述了在一台Linux(RHEL6.4 x86_64)服务器上部署安装OMSA的通用做法,包括OMSA软件的获取方法和安装步骤. 演示环境: PowerEdge R620, RHEL 6.4 ...

  2. 在一台Linux服务器上安装多个MySQL实例(一)--使用mysqld_multi方式

    (一)MySQL多实例概述 实例是进程与内存的一个概述,所谓MySQL多实例,就是在服务器上启动多个相同的MySQL进程,运行在不同的端口(如3306,3307,3308),通过不同的端口对外提供服务 ...

  3. MySQL 8.x 新版本特性赶紧学!!Linux 服务器上安装 MySQL 8.x

    我是陈皮,一个在互联网 Coding 的 ITer,微信搜索「陈皮的JavaLib」第一时间阅读最新文章,回复[资料],即可获得我精心整理的技术资料,电子书籍,一线大厂面试资料和优秀简历模板. 引言 ...

  4. 在阿里云服务器上安装完成并启动Tomcat后,通过http不能访问--解决办法

    在阿里云服务器上安装完成并启动Tomcat后,通过http不能访问的原因是阿里云平台为了安全设置了安全组策略,必须我们授权的端口,其他计算机才能通过http访问 解决办法:(这里以阿里轻量应用服务器为 ...

  5. 在阿里云Linux服务器上安装MySQL

    申请阿里云Linux服务器 昨天在阿里云申请了一个免费试用5天的Linux云服务器. 操作系统:Red Hat Enterprise Linux Server 5.4 64位. CPU:1核 内存:5 ...

  6. linux服务器上安装mysql

    mysql版本:mysql-5.6.44-linux-glibc2.12-x86_64.tar linux操作系统和版本信息: 1.检查linux服务器上是否已安全mysql [root@localh ...

  7. 如何在Linux系统上安装nginx

      安装Nginx 下载Nginx 到官网http://nginx.org/下载对应nginx包,推荐使用稳定版本进入官网之后界面如下 点击download进行到下一页 然后下载所需要的版本(强烈建议 ...

  8. Linux服务器上安装织梦CMS

    安装篇 第一步:配置防火墙(默认情况下,端口80和3306是拒绝访问的,在防火墙上进行配置): vi /etc/sysconfig/iptables(在"COMMIT"的上一行加上 ...

  9. Linux系统上安装软件(JDK以及tomcat服务器)

    一:安装jdk linux系统上面如果运行java程序,就需要安装java的运行环境(jdk) 1:下载linux版本的jdk 地址:http://www.oracle.com/technetwork ...

随机推荐

  1. react取消监听scroll事件

    如果要移除事件addEventListener的执行函数必须使用外部函数而不能直接使用匿名函数 错误写法: // 这样写是移除不了滚动事件的 componentDidMount() { // 添加滚动 ...

  2. vc 常用语句

    1) CMainFrame* pmainframe=(CMainFrame*)AfxGetMainWnd();CChildFrame *m_finderframe=(CChildFrame*)pmai ...

  3. PatentTips - Apparatus and method for a generic, extensible and efficient data manager for virtual peripheral component interconnect devices (VPCIDs)

    BACKGROUND A single physical platform may be segregated into a plurality of virtual networks. Here, ...

  4. 11.3 Android显示系统框架_最简单的surface测试程序

    APP有一个surface(界面),其有多个buffer用来存放界面数据,这些buffer是向surfaceflinger申请的: 因此我们编写的surface测试程序步骤: (1)获得surface ...

  5. 一些mysql innodb的建议

    http://blog.csdn.net/yunhua_lee/article/details/8239145 原文:http://dev.mysql.com/doc/refman/5.5/en/in ...

  6. IOS Audio session

    iOS实现长时间后台的两种方法:Audio session和VOIP socket 十二月 04 我们知道 iOS 开启后台任务后可以获得最多 600 秒的执行时间,而一些需要在后台下载或者与服务器保 ...

  7. [Algorithms] Binary Search Algorithm using TypeScript

    (binary search trees) which form the basis of modern databases and immutable data structures. Binary ...

  8. CSS布局开篇

    原文: 简书原文:https://www.jianshu.com/p/2c78b927f8c4 开篇 这是我写CSS布局的第一篇文章,之所以将布局从中摘出来单独放一部分是因为我觉得光是布局这块内容就有 ...

  9. POJ 2014 Flow Layout 模拟

    http://poj.org/problem?id=2014 嘻嘻2014要到啦,于是去做Prob.ID 为2014的题~~~~祝大家新年快乐~~ 题目大意: 给你一个最大宽度的矩形,要求把小矩形排放 ...

  10. Nginx+ 多个Memcached+ 多个Tomcat集群配置来实现 sticky Session

    假如有 大于2 台的Tomcat servers,如何实现sticky session特点的高可靠web 服务? 方案设计: 前端使用nginx(最好是淘宝的 tengine)作为we 流量分发器,向 ...