Centos 上面用Shell脚本一键安装LAMP环境

简介:

   LAMP指的Linux(操作系统)、Apache(HTTP 服务器),MySQL(数据库软件)和PHP构建的web服务器。该网站架构是目前国际流行和通用的Web架构,LAMP跨平台、高性能等优势,是很多企业和公司搭建WEB服务的首选平台。

   1)系统环境介绍
     Centos 5.8 64位
     Apache:httpd-2.4.4.tar.gz
     PHP:   php-5.4.17.tar.gz 
     Mysql: mysql-5.6.12.tar.gz

   2)安装脚本

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
#!/bin/bash
PATH= /usr/local/sbin : /usr/local/bin : /usr/sbin : /usr/bin : /sbin : /bin
export  PATH
#INFO函数定义输出字体颜色,echo -e 表示保持字符串的特殊含义,$1表示字体颜色编号,$2表示等待程序执行时间,$3表示echo输出内容。
function  INFO()
{
      echo  -e  "\e[$1;49;1m: $3 \033[39;49;0m"
      sleep  "$2"
      echo  ""
}
#非root用户不能执行该脚本
if   "$UID"  != 0 ];
         then
           echo  " "
                 INFO 35  "0"  "Must be root ro run this script."
         exit  1
fi
#USAGE函数定义脚本用法,可反复调用,basename其实就是脚本名,\n表示换行。
function  USAGE()
{
         INFO 35  "0.1"  "Please see the script of the usage:"
         basename =$( basename  "$0" )
         INFO \
           36  "0"  \
           "$(echo -e " Usage: \n\n./$ basename  (apache|mysql|php)  install  \n./$ basename  apache (start|stop|restart) \n./$ basename  mysql (start|stop|restart)\n ")"
}
#YUM_INSTALL函数安装依赖包,可反复调用,$@表示所有参数都分别被双引号引住"$1","$2",而$*表示所有这些参数都被双引号引住"$1$2"
function  YUM_INSTALL()
{
         for  in  $@;  do
           INFO 32 1  "Install depend on the [ $a ]"
                 yum -y  install  $a ||  exit  1
           if  [ $a =  "libXpm-devel"  ];  then
                ln  -s  /usr/lib/x86_64-linux-gnu/libXpm .so  /usr/lib/libXpm .so
           #elif [ $a = "libsasl2-dev" ]; then
           #     cp /usr/lib/x86_64-linux-gnu/libldap* /usr/lib/
           fi
         done
}
#INSTALL函数定义安装程序,可一反复调用,安装apache程序的时候要先安装3个依赖包,在安装mysql的时候要用cmake编译。$1表示要安装的程序,$2表示yum安装对应的依赖包,$3表示程序解压后的目录,$4表示程序源码包。
function  INSTALL()
{
      YUM_INSTALL  "$2"  &&  cd  $SOURCE_PATH
      [ -d $3 ] &&  rm  -r $3; INFO 31 4  "Unpack the $4 installation package......"
      tar  zxvf $4;  cd  $3 ;  pwd  ; INFO 32 4  "Configure the $1......"
             if  [ $1 = apache ];
                 then
                         cp  -rf .. /apr-1 .4.8 srclib /apr
                         cp  -rf .. /apr-util-1 .5.2 srclib /apr-util
                . /configure  $5 ||  exit  1
      elif  [ $1 = mysql ];
           then
                cmake $5 ||  exit  1
      elif  [ $1 = openssl ];
           then
                . /config  $5 ||  exit  1
      elif  [ $1 = libpng ];
           then
                cp  scripts /makefile .linux makefile
      elif  [ $1 = jpegsrc.v6b. tar .gz ];
           then
                cp  /usr/share/libtool/config .guess  ./
                cp  /usr/share/libtool/config .sub ./
                . /configure  $5 ||  exit  1
                mkdir  -p   /usr/local/env/jpeg/bin
                mkdir  -p   /usr/local/env/jpeg/lib
                mkdir  -p   /usr/local/env/jpeg/include
                mkdir  -p  /usr/local/env/jpeg/man/man1
                  else
                . /configure  $5 ||  exit  1
             fi
      INFO 36 3  "Compile $1......"
             make  ||  exit  1 && INFO 34 4  "Install $1......"  make  install  && INFO 33 4  "$1 installation is successful......"
                                                                                                                                                                                                                                                                                
      if  [ $1 = mysql ];
           then
                echo  $INSTALL_PATH /mysql/lib/mysql  >>  /etc/ld .so.conf
                /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = libiconv ];
           then
                echo  "/usr/local/env/libiconv/lib"  >>  /etc/ld .so.conf
                /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = libxml2 ];
           then
                echo  "/usr/local/env/libxml2/lib"  >>  /etc/ld .so.conf
                         /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = libmcrypt ];
           then
                echo  "/usr/local/env/libmcrypt/lib"  >>  /etc/ld .so.conf
                         /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = mhash ];
           then
                echo  "/usr/local/lib"  >>  /etc/ld .so.conf
                echo  "/usr/local/lib64"  >>  /etc/ld .so.conf
                         /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = gettext ];
           then
                         echo  "/usr/local/env/gettext/lib"  >>  /etc/ld .so.conf
                         /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = gd ];
           then
                sed  -i  '27 a void (*data);'  /usr/local/env/gd/include/gd_io .h
                echo  "/usr/local/env/gd/lib"  >>  /etc/ld .so.conf
                         /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = freetype ];
           then
                echo  "/usr/local/env/freetype/lib"  >>  /etc/ld .so.conf
                         /sbin/ldconfig  && INFO 33 4  "Add $1 library file to ld.so.conf......"
      fi
      if  [ $1 = jpegsrc.v6b. tar .gz ];
                 then
                         echo  "/usr/local/env/jpeg/lib"  >>  /etc/ld .so.conf
                         /sbin/ldconfig  && INFO 33 4  "Add jpeg library file to ld.so.conf......"
      fi
}
#SERVICE函数定义程序启动,关闭,重启。
function  SERVICE()
{
      if  [ $1 = apache -a $2 = start ];  then
           $INSTALL_PATH/$1 /bin/apachectl  -k start && \
           INFO 33  "2.5"  "Apache startup success......"
           exit
      elif  [ $1 = apache -a $2 = stop ];  then
           $INSTALL_PATH/$1 /bin/apachectl  -k stop && \
           INFO 31  "2.5"  "Apache has stopped......"
           exit
      elif  [ $1 = apache -a $2 = restart ];  then
           $INSTALL_PATH/$1 /bin/apachectl  -k stop ;  sleep  2
           INFO 31  "2.5"  "Apache has stopped......"
           $INSTALL_PATH/$1 /bin/apachectl  -k start && \
           INFO 34  "2.5"  "Apache has restarted......"
           exit
      elif  [ $1 = mysql -a $2 = start ];  then
           /bin/bash  $INSTALL_PATH/$1 /bin/mysqld_safe  --defaults- file =$INSTALL_PATH/$1 /my .cnf 2>&1 >  /dev/null  &
           INFO 33  "2.5"  "Mysql startup success......"
           echo  -e  "$(netstat -ntpl|grep " /:::3306 ")"
           exit
      elif  [ $1 = mysql -a $2 = stop ];  then
           kill  $( netstat  -ntpl| awk  '/:::3306/{print $NF}' | awk  -F  '/'  '{print $1}' ) && \
           INFO 31  "2.5"  "Mysql has stopped......"
           exit
      elif  [ $1 = mysql -a $2 = restart ];  then
           kill  $( netstat  -ntpl| awk  '/:::3306/{print $NF}' | awk  -F  '/'  '{print $1}' ) && \
           INFO 31  "3"  "Mysql has stopped......"
           /bin/bash  $INSTALL_PATH/$1 /bin/mysqld_safe  --defaults- file =$INSTALL_PATH/$1 /my .cnf 2>&1 >  /dev/null  &
           INFO 34  "2.5"  "Mysql has restarted......"
           exit
      fi
}
#CONFIG_MYSQL函数用来定义mysql的配置。
function  CONFIG_MYSQL()
{
      INFO 32 3  "Configure the mysql......"
         groups  mysql || groupadd mysql &&  id  mysql ||  useradd  -g mysql mysql
         cd  $INSTALL_PATH /mysql  pwd
                 . /scripts/mysql_install_db  \
                         --user=mysql \
                         --basedir=$INSTALL_PATH /mysql/  \
                         --datadir=$INSTALL_PATH /mysql/data/  \
                         --defaults- file =$INSTALL_PATH /mysql/my .cnf
         echo  "" sleep  3
         cp  $( dirname  $SOURCE_PATH) /conf/my .cnf ./
      INFO 35 2  "Mysql configuration is complete......"
}
#CONFIG_HTTPD函数用来配置apache。
function  CONFIG_HTTPD()
{
      INFO 32 3  "Configure the apache......"
      echo  -e  "<?php\nphpinfo();\n?>"  > $INSTALL_PATH /apache/htdocs/phpinfo .php
      sed  -i  's/^\ \ \ \ AddType application\/x-gzip .gz .tgz$/&\n\ \ \ \ AddType application\/x-httpd-php .php/'  \
      $INSTALL_PATH /apache/conf/httpd .conf
      sed  -i  's/^#ServerName www.example.com:80$/&\nServerName 127.0.0.1:80/'  $INSTALL_PATH /apache/conf/httpd .conf
      INFO 35 2  "Apache configuration is complete......"
}
#CONFIG_PHP函数用来配置php。
function  CONFIG_PHP()
{
      INFO 32 3  "Configure the php......"
      cp  $SOURCE_PATH/$1 /php .ini-development $INSTALL_PATH /php5/etc/php .ini
      INFO 35 2  "Php configuration is complete......"
}
#INSTALL_BRANCH函数定义程序安装,${TAR_NAME[@]}是shell脚本中数组写法,即取全部元素,即TAR_NAME里面的所有包,SERVER_NAME表示包的名称,COMPILE_DIR表示包名+版本后,即解压后的目录名。
function  INSTALL_BRANCH()
{
      for  in  ${TAR_NAME[@]};  do
              SERVER_NAME=$( echo  $i| awk  -F  "-[0-9]"  '{print $1}' )
              COMPILE_DIR=$( echo  $i| awk  -F  ".tar.gz"  '{print $1}' )
           if  [ $1 = $SERVER_NAME -a $1 = apr ];  then
                INSTALL apr  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/apr"
           elif  [ $1 = $SERVER_NAME -a $1 = apr-util ]; then
                INSTALL apr-util  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/apr-util --with-apr=/usr/local/env/apr"
           elif  [ $1 = $SERVER_NAME -a $1 = pcre ];  then
                INSTALL pcre  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/pcre"
           elif  [ $1 = $SERVER_NAME -a $1 = httpd ];  then
                INSTALL apache  "$HTTP_YUM"  "$COMPILE_DIR"  "$i"  "$HTTP_PARAMETERS"
                CONFIG_HTTPD
           elif  [ $1 = $SERVER_NAME -a $1 = mysql ];  then
                INSTALL mysql  "$MYSQL_YUM"  "$COMPILE_DIR"  "$i"  "$MYSQL_PARAMETERS"
                CONFIG_MYSQL
           elif  [ $1 = $SERVER_NAME -a $1 = libiconv ];  then
                INSTALL libiconv  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/libiconv"
           elif   [ $1 = $SERVER_NAME -a $1 = libxml2 ];  then
                INSTALL libxml2  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/libxml2 --with-iconv=/usr/local/env/libiconv"
           elif   [ $1 = $SERVER_NAME -a $1 = curl ];  then       
                INSTALL curl  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/curl --enable-utf8"
           elif   [ $1 = $SERVER_NAME -a $1 = libmcrypt ];  then                                  
                INSTALL libmcrypt  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/libmcrypt"
           elif   [ $1 = $SERVER_NAME -a $1 = mhash ];  then
                INSTALL mhash  " "  "$COMPILE_DIR"  "$i"  " "
           elif   [ $1 = $SERVER_NAME -a $1 = mcrypt ];  then
                INSTALL mcrypt  " "  "$COMPILE_DIR"  "$i"  "--prefix= /usr/local/env/mcrypt  \
                --with-libmcrypt-prefix= /usr/local/env/libmcrypt  \
                --with-libiconv-prefix= /usr/local/env/libiconv "
           elif    [ $1 = $SERVER_NAME -a $1 = gettext ];  then
                         INSTALL gettext  " "  "$COMPILE_DIR"  "$i"  "--prefix= /usr/local/env/gettext  \
                         --with-libiconv-prefix= /usr/local/env/libiconv  \
                --with-libxml2-prefix= /usr/local/env/libxml2 "
           elif   [ $1 = $SERVER_NAME -a $1 = freetype ];  then
                         INSTALL freetype  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/freetype"
           elif   [ $1 = $SERVER_NAME -a $1 = jpegsrc.v6b. tar .gz ];  then
                COMPILE_DIR= "jpeg-6b"
                         INSTALL jpegsrc.v6b. tar .gz  " "  "$COMPILE_DIR"  "$i"  "--prefix=/usr/local/env/jpeg --enable-shared --enable-static"
           elif   [ $1 = $SERVER_NAME -a $1 = libpng ];  then
                         INSTALL libpng  " "  "$COMPILE_DIR"  "$i"  " "
           elif   [ $1 = $SERVER_NAME -a $1 = gd ];  then
                INSTALL gd  " "  "$COMPILE_DIR"  "$i"  "--prefix= /usr/local/env/gd  --with-png= /usr  \
                --with-freetype= /usr/local/env/freetype  \
                --with-jpeg= /usr/local/env/jpeg   --with-fontconfig= /usr  --with-xpm= /usr "
           elif   [ $1 = $SERVER_NAME -a $1 = openssl ];  then
                INSTALL openssl  " "  "$COMPILE_DIR"  "$i"  "-fPIC --prefix=/usr/local/env/openssl shared"
           elif   [ $1 = $SERVER_NAME -a $1 = php ];  then
                INSTALL php5  "$PHP5_YUM"  "$COMPILE_DIR"  "$i"  "$PHP5_PARAMETERS"
                CONFIG_PHP  "$COMPILE_DIR"
                break
           else
                continue
           fi
      done
}
#MOD_CASE函数用KASE定义选择安装程序。
function  MOD_CASE()
{
      if  [[ $1 =~ apache|mysql|php ]] && [[ $2 =~  install |start|stop|restart ]];  then
           INFO 32  "1.5"  "Input the correct,according to the option to perform related operations......"
           echo  ""
           if  [ $2 =  install  ];  then
                case  "$1 $2"  in
                     "apache install" )
                          INFO 35  "2.5"  "Start to $1 the $2......"
                          INSTALL_BRANCH apr
                          INSTALL_BRANCH apr-util
                          INSTALL_BRANCH pcre
                          INSTALL_BRANCH httpd
                          ;;
                     "mysql install" )
                          INFO 35  "2.5"  "Start to $1 the $2......"
                          INSTALL_BRANCH mysql
                          ;;
                     "php install" )
                          INFO 35  "2.5"  "Start to $1 the $2......"
                          export  LD_LIBRARY_PATH= /lib/ : /usr/lib/ : /usr/local/lib : /usr/local/lamp/mysql/lib
                          INSTALL_BRANCH libiconv
                          INSTALL_BRANCH libxml2
                          INSTALL_BRANCH curl
                          INSTALL_BRANCH libmcrypt
                          INSTALL_BRANCH mhash
                          INSTALL_BRANCH mcrypt
                          INSTALL_BRANCH gettext
                          INSTALL_BRANCH freetype
                          INSTALL_BRANCH jpegsrc.v6b. tar .gz
                          INSTALL_BRANCH libpng
                          INSTALL_BRANCH gd
                          INSTALL_BRANCH openssl
                          #INSTALL_BRANCH httpd && INSTALL_BRANCH mysql && INSTALL_BRANCH php
                          INSTALL_BRANCH php
                          ;;
                esac
           else
                SERVICE $1 $2
           fi
      else
                INFO 31 1  "Input error, please try again!"
                INPUT
      fi
}
#LAMP程序安装的目录
INSTALL_PATH= "/usr/local/lamp"
#源码包存放目录
SOURCE_PATH= "$(cd $(dirname $0); pwd)/install_tar"
#源码包列表
TAR_NAME=(httpd-2.4.4. tar .gz mysql-5.6.12. tar .gz php-5.4.17. tar .gz apr-1.4.8. tar .gz apr-util-1.5.2. tar .gz pcre-8.10. tar .gz freetype-2.4.0. tar .gz jpegsrc.v6b. tar .gz libxml2-2.7.2. tar .gz mhash-0.9.9.9. tar .gz mcrypt-2.6.8. tar .gz gd-2.0.35. tar .gz libiconv-1.14. tar .gz gettext-0.18. tar .gz libmcrypt-2.5.8. tar .gz openssl-0.9.8p. tar .gz curl-7.32.0. tar .gz libpng-1.2.33. tar .gz)
#Apache,Mysql,PHP yum安装依赖包
HTTP_YUM= "build-essential libapr1 libapr1-dev libaprutil1 libaprutil1-dev gettext gettext-devel"
MYSQL_YUM= "cmake libncurses5 libncurses5-dev bison"
PHP5_YUM= "libxml2 libxml2-devel openssl libjpeg-devel bzip2 libXpm-devel libmcrypt-devel"
#Apache编译参数
HTTP_PARAMETERS="\
--prefix=$INSTALL_PATH /apache  \
-- enable -module=so \
-- enable -module=rewrite \
-- enable -shard=rewrite \
-- enable -shared=max \
--with-apr= /usr/local/env/apr  \
--with-apr-util= /usr/local/env/apr-util  \
--with-pcre= /usr/local/env/pcre  \
--with-included-apr \
"
#mysql编译参数
MYSQL_PARAMETERS="\
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH /mysql  \
-DYSQL_TCP_PORT=3306 \
-DMYSQL_DATADIR=$INSTALL_PATH /mysql/data  \
-DMYSQL_UNIX_ADDR=$INSTALL_PAHT /mysql/mysql .sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_DEBUG=0 \
"
#PHP编译参数
PHP5_PARAMETERS="\
--prefix=$INSTALL_PATH /php5  \
--with-config- file -path=$INSTALL_PATH /php5/etc  \
--with-mysql=$INSTALL_PATH /mysql  \
--with-apxs2=$INSTALL_PATH /apache/bin/apxs  \
--with-mysqli=$INSTALL_PATH /mysql/bin/mysql_config  \
--with-iconv= /usr/local/env/libiconv  \
--with-jpeg- dir = /usr/local/env/jpeg   \
--with-png- dir = /usr  \
--with-libxml- dir = /usr/local/env/libxml2   \
--with-pdo-mysql \
--with-zlib \
--with-curl= /usr/local/env/curl  \
--with-curlwrappers \
--with-mcrypt= /usr/local/env/libmcrypt  \
--with-gd= /usr/local/env/gd   \
--with-openssl= /usr/local/env/openssl  \
--with-mhash= /usr  \
--with-xmlrpc \
--with-xpm- dir  \
--with-freetype- dir = /usr/local/env/freetype  \
--with-zlib- dir  \
--with-ldap \
--with-ldap-sasl \
--with-pcre-regex \
--with-gettext= /usr/local/env/gettext  \
--with-ncurses \
-- enable -shared \
-- enable -xml \
-- enable -safe-mode \
-- enable -track-vars \
-- enable -magic-quotes \
-- enable -bcmath \
-- enable -sysvsem \
-- enable -sysshm \
-- enable -inline-optimization \
-- enable -mbregex \
-- enable -mbstring \
-- enable -gd-native-ttf \
-- enable -pcntl \
-- enable -sockets \
-- enable -zip \
-- enable -soap \
-- enable -discard-path \
-- enable -force-cgi-redirect \
-- enable -pdo \
-- enable -calendar \
-- enable -exif \
-- enable -zend-multibyte \
"
#--disable-rpath
#脚本调用帮助程序
if  [ $ # = 2 ]
      then
           INFO 33  "1.5"  "please wait......"
           echo  ""
           MOD_CASE  "$1"  "$2"
      else
           USAGE
           exit  1
fi

   3)脚本的用法

1
2
3
4
5
6
7
8
9
10
11
12
#下载安装脚本和源码包
wget https: //sourceforge .net /projects/opensourcefile/files/
Install_Centos_LAMP_v.0.1.zip /download  --no-check-certificate
unzip Install_Centos_LAMP_v.0.1.zip
chmod  +x Install_Centos_LAMP_v.0.1.sh
#查看脚本的用法,可通过该脚本安装apache,mysql,php,启动,关闭和重启apache和mysql。
. /Install_Centos_LAMP_v .0.1.sh
: Please see the script of the usage:
: Usage:
. /Install_Centos_LAMP_v .0.1.sh (apache|mysql|php)  install
. /Install_Centos_LAMP_v .0.1.sh apache (start|stop|restart)
. /Install_Centos_LAMP_v .0.1.sh mysql (start|stop|restart)


    本脚本应用了Shell编程里面的函数,数组,流程控制,变量,字体的加亮等功能,希望对学习WEB和Shell编程的同学有所帮助,最后非常感谢我的同学宝宝的支持。










本文转自 sfzhang 51CTO博客,原文链接:http://blog.51cto.com/sfzhang88/1281640,如需转载请自行联系原作者

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
目录
相关文章
|
10月前
|
存储 安全 Unix
七、Linux Shell 与脚本基础
别再一遍遍地敲重复的命令了,把它们写进Shell脚本,就能一键搞定。脚本本质上就是个存着一堆命令的文本文件,但要让它“活”起来,有几个关键点:文件开头最好用#!/usr/bin/env bash来指定解释器,并用chmod +x给它执行权限。执行时也有讲究:./script.sh是在一个新“房间”(子Shell)里跑,不影响你;而source script.sh是在当前“房间”里跑,适合用来加载环境变量和配置文件。
875 9
|
关系型数据库 MySQL Shell
MySQL 备份 Shell 脚本:支持远程同步与阿里云 OSS 备份
一款自动化 MySQL 备份 Shell 脚本,支持本地存储、远程服务器同步(SSH+rsync)、阿里云 OSS 备份,并自动清理过期备份。适用于数据库管理员和开发者,帮助确保数据安全。
|
10月前
|
存储 Shell Linux
八、Linux Shell 脚本:变量与字符串
Shell脚本里的变量就像一个个贴着标签的“箱子”。装东西(赋值)时,=两边千万不能有空格。用单引号''装进去的东西会原封不动,用双引号""则会让里面的$变量先“变身”再装箱。默认箱子只能在当前“房间”(Shell进程)用,想让隔壁房间(子进程)也能看到,就得给箱子盖个export的“出口”戳。此外,Shell还自带了$?(上条命令的成绩单)和$1(别人递进来的第一个包裹)等许多特殊箱子,非常有用。
951 2
|
Shell
Shell脚本循环控制:shift、continue、break、exit指令
使用这些命令可以让你的Shell脚本像有生命一样动起来。正确使用它们,你的脚本就能像一场精心编排的舞蹈剧目,既有旋律的起伏,也有节奏的跳跃,最终以一场惊艳的表演结束。每一个动作、每一个转折点,都准确、优雅地完成所需要表达的逻辑。如此,你的脚本不只是冰冷的代码,它透过终端的界面,跳着有节奏的舞蹈,走进观众——使用者的心中。
422 60
|
Linux 编译器 开发工具
在CentOS环境下升级GCC编译器的指南
总结:本文提供了一种方法来升级CentOS的GCC编译器,通过使用CentOS的软件集合和开发者工具集工具,可以比较平滑地进行升级。在整个过程中无需从源代码编译,这样既省去了复杂的编译过程,也避免了可能出现的与系统库不兼容的风险。请注意,使用第三方仓库可能会带来系统稳定性和安全性上的潜在影响。所有操作都应谨慎进行,并确保有相应的数据备份。
1424 19
|
10月前
|
数据采集 监控 Shell
无需Python:Shell脚本如何成为你的自动化爬虫引擎?
Shell脚本利用curl/wget发起请求,结合文本处理工具构建轻量级爬虫,支持并行加速、定时任务、增量抓取及分布式部署。通过随机UA、异常重试等优化提升稳定性,适用于日志监控、价格追踪等场景。相比Python,具备启动快、资源占用低的优势,适合嵌入式或老旧服务器环境,复杂任务可结合Python实现混合编程。
|
Web App开发 缓存 安全
Linux一键清理系统垃圾:释放30GB空间的Shell脚本实战​
这篇博客介绍了一个实用的Linux系统盘清理脚本,主要功能包括: 安全权限检查和旧内核清理,保留当前使用内核 7天以上日志文件清理和系统日志压缩 浏览器缓存(Chrome/Firefox)、APT缓存、临时文件清理 智能清理Snap旧版本和Docker无用数据 提供磁盘空间使用前后对比和大文件查找功能 脚本采用交互式设计确保安全性,适合定期维护开发环境、服务器和个人电脑。文章详细解析了脚本的关键功能代码,并给出了使用建议。完整脚本已开源,用户可根据需求自定义调整清理策略。
1277 1
|
存储 Unix Shell
确定Shell脚本在操作系统中的具体位置方法。
这对于掌握Linux的文件系统组织结构和路径方面的理解很有帮助,是我们日常工作和学习中都可能使用到的知识。以上讲解详细清晰,应用简便,是每一个想要精通操作系统的计算机爱好者必备的实用技能。
718 17
|
Linux Shell
在Linux、CentOS7中设置shell脚本开机自启动服务
以上就是在CentOS 7中设置shell脚本开机自启动服务的全部步骤。希望这个指南能帮助你更好地管理你的Linux系统。
2292 25
|
Linux Shell
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
416 4