This script example requires the following:
The source code installs lamp environment, request executes the script under the character terminal (Ls-l/usr/src display is different)
The required tar packets have been copied to the/USR/SRC directory
#!/bin/bash
Rpm-q httpd &>/dev/null
If [$?-eq 0];then
Yum-y Remove httpd &>/dev/null
Fi
Ls-l/usr/local/| grep httpd &>/dev/null
If [$?-ne 0];then
Httpball= ' ls/usr/src/httpd*.gz '
Tar zxf $httpball-C/usr/src &>/dev/null
Dir= ' Ls-l/usr/src | grep ^d | grep httpd | awk ' {print $} '
cd/usr/src/$dir
./configure--prefix=/usr/local/httpd--enable-so--enable-rewrite--enable-charset-lite--enable-cgi && make && make Install
Ln-s/usr/local/httpd/bin/*/usr/local/bin
Cp/usr/local/httpd/bin/apachectl/etc/init.d/httpd
Sed-i ' 1a #chkconfig: 35 85 15 \
#description: httpd server '/etc/init.d/httpd
Chkconfig--add httpd
Chkconfig httpd on
Service httpd Start
Fi
Rpm-q Mysql-server &>/dev/null
If [$?-eq 0];then
Yum-y mysql-server MySQL &>/dev/null
Fi
Ls-l/usr/local | grep MySQL &>/dev/null
If [$?-ne 0];then
grep mysql/etc/passwd &>/dev/null
If [$?-ne 0]; Then
Useradd-m-u 49-s/sbin/nologin mysql
Fi
Mysqlball= ' ls/usr/src/mysql*.gz '
Tar zxf $mysqlball-C/usr/src &>/dev/null
Dir= ' Ls-l/usr/src | grep ^d | grep MySQL | awk ' {print $} '
cd/usr/src/$dir
./configure--prefix=/usr/local/mysql--with-charset=utf8--with-collation=utf8_general_ci--with-extra-charset= gbk,gb2312 && make && make install