liunx服务器安装常用软件一键脚本

释放双眼,带上耳机,听听看~!

1.docker.sh
docker安装


1
2
3
4
5
6
7
8
9
10
11
1#!/usr/bin/env bash
2yum install -y docker
3tee /etc/docker/daemon.json <<-'EOF'
4{
5  "registry-mirrors": ["https://fy707np5.mirror.aliyuncs.com"]
6}
7EOF
8sudo systemctl daemon-reload
9sudo systemctl restart docker
10
11

2.htop.sh
查看进程安装


1
2
3
4
5
6
7
8
9
10
11
12
1#!/usr/bin/env bash
2yum install ncurses-devel
3
4wget http://sourceforge.net/projects/htop/files/htop/1.0.2/htop-1.0.2.tar.gz
5tar zxvf htop-1.0.2.tar.gz
6cd htop-1.0.2
7./configure --disable-unicode --prefix=/usr/local/htop
8make
9make install
10ln -s /usr/local/htop/bin/htop /usr/local/bin/htop
11
12

3.jdk.sh
jdk1.8版本安装


1
2
3
4
5
6
7
8
9
10
11
12
1#!/usr/bin/env bash
2
3#install_jdk
4wget http://7lrxhn.com1.z0.glb.clouddn.com/jdk-8u111-linux-x64.tar.gz
5tar zxvf jdk-8u111-linux-x64.tar.gz
6rm -rf jdk-8u111-linux-x64.tar.gz
7mv jdk1.8.0_111 /usr/local/
8ln -s /usr/local/jdk1.8.0_111/bin/java /usr/bin/java
9echo -e "JAVA_HOME=/usr/local/jdk1.8.0_111;\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile
10source /etc/profile
11
12

4.mysql57.sh
mysql5.7安装


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1#!/usr/bin/env bash
2rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm --force --nodeps
3
4wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
5tar xvf mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
6rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm --force --nodeps
7rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm --force --nodeps
8rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm --force --nodeps
9rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm --force --nodeps
10
11#初始化密码
12mysqld --initialize
13cat /var/log/mysqld.log
14
15#启动
16systemctl start mysqld.service
17mysql -u root -p
18set password=password('123456');
19
20

5.nginx.sh
nginx反向代理负载均衡安装


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
1#!/usr/bin/env bash
2yum install -y zlib-devel
3wget http://nginx.org/download/nginx-1.11.7.tar.gz
4tar zxvf nginx-1.11.7.tar.gz
5cd nginx-1.11.7
6./configure --prefix=/usr/local/nginx --without-http_rewrite_module --without-http_gzip_module
7make && make install
8cd ..
9rm -rf nginx*
10echo "export PATH=\$PATH:/usr/local/nginx/sbin" >> /etc/profile
11source /etc/profile
12nginx
13
14#开机启动
15cat > /usr/lib/systemd/system/nginxd.service <<EOF
16[Unit]
17Description=nginx
18After=network.target
19
20[Service]
21Type=forking
22ExecStart=/usr/local/nginx/sbin/nginx
23ExecReload=/usr/local/nginx/sbin/nginx -s reload
24ExecStop=/usr/local/nginx/sbin/nginx -s stop
25PrivateTmp=true
26
27[Install]
28WantedBy=multi-user.target
29EOF
30systemctl enable nginxd.service
31
32

6.redis.sh
redis缓存安装


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1#!/usr/bin/env bash
2wget http://download.redis.io/releases/redis-3.2.11.tar.gz
3tar -zxvf redis-3.2.11.tar.gz
4cd redis-3.2.11
5make PREFIX=/usr/local/redis install
6cp init_server/redis.conf /usr/local/redis/
7
8#开机启动
9cat > /usr/lib/systemd/system/redis.service <<EOF
10[Unit]
11Description=redis
12After=network.target
13
14[Service]
15Type=forking
16ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
17ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown
18
19[Install]
20WantedBy=multi-user.target
21EOF
22systemctl enable redis.service
23
24

7.tomcat.sh
tomcat服务器安装


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
1#install_tomcat
2wget http://7lrxhn.com1.z0.glb.clouddn.com/apache-tomcat-8.5.14.tar.gz
3tar zxvf apache-tomcat-8.5.14.tar.gz
4rm -rf apache-tomcat-8.5.14.tar.gz
5mv apache-tomcat-8.5.14 /usr/local/tomcat
6
7#开机启动
8cat > /etc/systemd/system/tomcat.service <<EOF
9
10[Unit]
11
12Description=Apache Tomcat Web Application Container
13
14After=syslog.target network.target
15
16
17
18[Service]
19
20Type=forking
21
22
23
24Environment=JAVA_HOME=/usr/local/jdk1.8.0_101
25
26Environment=CATALINA_PID=/usr/local/tomcat/temp/tomcat.pid
27
28Environment=CATALINA_HOME=/usr/local/tomcat
29
30Environment=CATALINA_BASE=/usr/local/tomcat
31
32
33
34ExecStart=/usr/local/tomcat/bin/catalina.sh start
35
36ExecStop=/bin/kill -15 $CATALINA_PID
37
38
39
40[Install]
41
42WantedBy=multi-user.target
43EOF
44
45systemctl enable tomcat.service
46
47

8.shadowsocks.sh
翻墙工具安装


1
2
3
4
5
1    wget --no-check-certificate -O shadowsocks.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
2    chmod +x shadowsocks.sh
3    ./shadowsocks.sh 2>&1 | tee shadowsocks.log
4
5

9.sync.sh
文件共享安装


1
2
3
4
5
6
7
8
1    #安装必要的软件包
2    yum -y install wget unzip
3    #下载脚本
4    wget https://github.com/helloxz/Resilio-Sync/archive/master.zip
5    #解压并安装
6    unzip master.zip && cd Resilio-Sync-master && chmod +x mysync.sh sync.sh && ./sync.sh
7
8

10.install_seafile.sh
网盘安装


1
2
3
4
5
1    yum -y install wget
2    wget https://raw.githubusercontent.com/helloxz/seafile/master/install_seafile.sh
3    chmod +x install_seafile.sh && ./install_seafile.sh
4
5

11.oneinstack.sh
搭建网站安装


1
2
3
4
5
6
7
8
1    yum -y install wget screen curl python #for CentOS/Redhat
2    wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz
3    tar xzf oneinstack-full.tar.gz
4    cd oneinstack
5    screen -S oneinstack
6    ./install.sh
7
8

12.bbr.sh
google BBR 提高TCP传输速度


1
2
3
1wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
2
3

13.oracle.sh
oracle安装
注:如果安装Oracle_Linux,需要修改脚本中yum源的配置的公钥。


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
1#!/bin/bash
2# oracle 11g R2 for linux 安装辅助脚本
3# Redkey
4# version 1.2
5# date 2013.08.27
6#定义常量
7SYSCTL=/etc/sysctl.conf
8LIMITS=/etc/security/limits.conf
9PAM=/etc/pam.d/login
10PROFILE=/etc/profile
11BASH_PROFILE=/home/oracle/.bash_profile
12#循环变量
13i=1
14#定义显示颜色
15#颜色定义 信息(33黄色) 警示(31红色) 过程(36浅蓝)
16#判断执行用户是否root
17isroot()
18{
19    if [ $USER != "root" ];then
20        echo -e "\n\e[1;31m the user must be root,and now you user is $USER,please su to root. \e[0m"
21        exit4
22    else
23        echo -e "\n\e[1;36m check root ... OK! \e[0m"
24    fi
25}
26#挂在光盘到/mnt/cdrom目录下
27mount_cdrom()
28{
29echo -e "\n\e[1;31m please insert RHEL to CDROM,press any key ...\e[0m"
30read -n 1
31if [ -d /mnt/cdrom ];then
32     mount -t auto -o ro /dev/cdrom /mnt/cdrom
33else
34    mkdir -p /mnt/cdrom
35    mount -t auto -o ro /dev/cdrom /mnt/cdrom
36fi
37if [ $? -eq 0 ];then
38    echo -e "\n\e[1;36m CDROM mount on /mnt/cdrom ... OK! \e[0m"
39fi
40}
41#设置yum本地光盘源
42yum_repo()
43{
44    rm -rf /etc/yum.repos.d/* && cat <<EOF >> /etc/yum.repos.d/Server.repo
45[Server]
46name=MyRPM
47baseurl=file:///mnt/cdrom/Server
48enabled=1
49gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
50EOF
51if [ $? -eq 0 ];then
52echo -e "\n\e[1;36m  /etc/yum.repos.d/Server.repo  ... OK! \e[0m"
53fi
54}
55#添加oracle用户,添加oracle用户所属组oinstall及附加组dba
56ouseradd()
57{
58    if [[ `grep "oracle" /etc/passwd` != "" ]];then
59    userdel -r oracle
60    fi
61    if [[ `grep "oinstall" /etc/group` = "" ]];then
62        groupadd oinstall
63    fi
64    if [[ `grep "dba" /etc/group` = "" ]];then
65        groupadd dba
66    fi
67    useradd oracle -g oinstall -G dba && echo $1 |passwd oracle --stdin
68    if [ $? -eq 0 ];then
69        echo -e "\n\e[1;36m oracle's password updated successfully  --- OK! \e[0m"
70    else
71        echo -e "\n\e[1;31m oracle's password set faild.   --- NO!\e[0m"
72    fi
73}
74#检查oracle所需软件包并安装
75packagecheck()
76{
77for package in binutils compat-libcap1 compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat
78do
79    rpm -q $package 2> /dev/null
80    if [ $? != 0 ];then
81        yum -y install $package
82        echo  -e "\n\e[1;36m $package is already installed ... OK! \e[0m"
83    fi
84done
85}
86#安装桌面套件 X Window System / Desktop
87xdesk()
88{
89    LANG=C yum -y groupinstall "X Window System" "Desktop"
90    if [ $? -eq 0 ];then
91        echo  -e "\n\e[1;36m $package is already installed ... OK! \e[0m"
92    fi
93}
94# 设置内核参数
95kernelset()
96{
97    cp $SYSCTL{,.bak} && cat <<EOF >>$SYSCTL
98fs.aio-max-nr = 1048576
99fs.file-max = 6815744
100kernel.shmall = 2097152
101kernel.shmmax = 4294967295
102kernel.shmmni = 4096
103kernel.sem = 250 32000 100 128
104net.ipv4.ip_local_port_range = 9000 65500
105net.core.rmem_default = 262144
106net.core.rmem_max = 4194304
107net.core.wmem_default = 262144
108net.core.wmem_max = 1048575
109EOF
110    if [ $? -eq 0 ];then
111        echo -e "\n\e[1;36m kernel parameters updated successfully --- OK! \e[0m"
112    fi
113sysctl -p
114}
115#设置oracle资源限制
116oralimit()
117{
118    cp $LIMITS{,.bak} && cat <<EOF >> $LIMITS
119oracle      soft    nproc   2047
120oracle      hard    nproc   16384
121oracle      soft    nofile  1024
122oracle      hard    nofile  65536
123oracle      soft    stack   10240
124EOF
125    if [ $? -eq 0 ];then
126        echo  -e "\n\e[1;36m $LIMITS updated successfully ... OK! \e[0m"
127    fi
128}
129#设置login文件
130setlogin()
131{
132    cp $PAM{,.bak} && cat <<EOF >>$PAM
133session     required    pam_limits.so
134EOF
135    if [ $? -eq 0 ];then
136        echo -e "\n\e[1;36m  $PAM updated successfully ... OK! \e[0m"
137    fi
138}
139#设置profile文件
140setprofile()
141{
142    cp $PROFILE{,.bak} && cat <<EOF >>$PROFILE
143if [ $USER = "oracle" ];then
144    if [ $SHELL = "/bin/ksh" ];then
145        ulimit -p 16384
146        ulimit -n 65536
147    else
148        ulimit -u 16384 -n 65536
149    fi
150fi
151EOF
152    if [ $? -eq 0 ];then
153        echo -e "\n\e[1;36m  $PROFILE updated successfully ... OK! \e[0m"
154    fi
155}
156#设置oracle的profile文件
157setbash_profile()
158{
159    cp $BASH_PROFILE{,.bak} && cat <<EOF >> $BASH_PROFILE
160umask 022
161ORACLE_BASE=$1
162ORACLE_HOME=$ORACLE_BASE/oracle
163ORACLE_SID=$2
164PATH=$ORACLE_HOME/bin/:$PATH
165LANG=en_US.UTF-8
166export ORACLE_BASE ORACLE_HOME ORACLE_SID
167EOF
168    if [ $? -eq 0 ];then
169        echo -e "\n\e[1;36m $BASH_PROFILE updated successfully ... OK! \e[0m"
170    fi
171. $BASH_PROFILE
172}
173#系统环境检查
174oscheck()
175{
176#查看内存大小是否大于1G
177echo -e "\n check MEM Size ..."
178if [ `cat /proc/meminfo | grep MemTotal | awk '{print $2}'` -lt 1048576 ];then
179    echo  -e "\n\e[1;33m Memory Small \e[0m"
180    exit 1
181else
182    echo -e "\n\e[1;36m Memory checked PASS \e[0m"
183fi
184#查看tmp空间大小
185echo -e "\n check tmpfs Size ..."
186cp /etc/fstab{,.bak}
187while true;do
188if [ `df | awk '/tmpfs/ {print $2}'` -lt 1048576 ];then
189    echo -e "\n\e[1;33m tmpfs Smaill \e[0m"
190    sed -i '/tmpfs/s/defaults/defaults,size=1G/' /etc/fstab && mount -o remount /dev/shm
191    if [ $? != 0 ];then
192    i=i+1
193        if [ $i -eq 3 ];then
194            echo -e "\n\e[1;31m set tmpfs faild. \e[0m"
195            exit 3
196        fi
197    else
198        echo -e "\n\e[1;36 tmpfs updated successfully. \e[0m"
199        break
200    fi
201else
202    echo -e "\n\e[1;36m tmpfs checked PASS \e[0m"
203    break
204fi
205done
206}
207#停止防火墙IPTABLES
208service iptables stop
209chkconfig iptables off
210#关闭SELINUX
211cp /etc/selinux/config{,.bak} && sed -i '/SELINUX/s/enforcing/disabled/;/SELINUX/s/permissive/disabled/'   /etc/selinux/config
212setenforce 0
213#执行以上函数
214isroot
215oscheck
216yum_repo
217mount_cdrom
218packagecheck
219xdesk
220kernelset
221oralimit
222setlogin
223setprofile
224echo -e "\n\e[1;33m please input oracle's user passwd: \e[0m"
225read oraclepw
226ouseradd $oraclepw
227setbash_profile
228echo -e "\n\e[1;33m please input oracle install PATH(default /oracle/db) \e[0m"
229read oraclepath
230if [ -z $oraclepath ];then
231    oraclepath=/oracle/db
232fi
233echo -e "\n\e[1;33m  please input oracle_sid (default fxcx) \e[0m"
234read orasid
235if [ -z orasid ];then
236    orasid=fxcx
237fi
238setbash_profile $oraclepath $orasid
239mkdir -p $oraclepath && chown -R oracle:oinstall $oraclepath && chmod -R 755 $oraclepath
240unset i
241echo -e "\n\e[1;35m Oracle install pre-setting finish! && please run oracle installer as user oracle \e[0m"
242
243

《参考:https://gitee.com/liaoshixiong/init_server》
《参考:http://blog.51cto.com/redkey/1283792》

给TA打赏
共{{data.count}}人
人已打赏
安全技术安全运维

Windows服务器如何发现被黑

2018-5-20 12:24:31

安全技术

Bootstrap 4 Flex(弹性)布局

2021-12-21 16:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索