today, yesterday's script was optimized, the script feature can be installed according to the options, although not as easy as one-click installation script, but added the option variable, in other scenarios will be used frequently. The output process is also hidden, making it easier to see the installation process. (due to different circumstances, for reference only)
in the same way, first:
650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/f39a7714-750a-439a-aa43-b6191692ec2b/ 8g2i8rggjllszgyl6ivbyj.a6vppbyhtgqbjmz6*nfg!/o/da8aaaaaaaaa&ek=1&kp=1&pt=0&bo=rqlaakuc2gidacu! &su=1137285057&sce=0-12-12&rf=2-9 "style=" Margin:0px;padding:0px;border-width:0px;border-style:none ; vertical-align:top;width:581px;height:730px; "/>
Script content:
#!/bin/bash
#Auto LAMP Install
#by Liupengfang----2015-07-24-----
If [-Z "$"];then
Echo-e "\033[35m--Welcome to use lamp Automatic installation script--\033[0m"
Echo-e ' \033[32m----------------------------\033[0m '
ECHO-E "\033[35m-----Please follow the options to install-----\033[0m"
Echo-e "\033[32m1) compile and install Apache server \033[0m"
Echo-e "\033[32m2) compile and install MySQL server \033[0m"
Echo-e "\033[32m3) compile and install PHP server \033[0m"
Echo-e "\033[32m4) apache+php integration \033[0m"
Echo-e "\033[32M5) MySQL service configuration \033[0m"
Echo-e "\033[31m Please enter: {/bin/sh $1|2|3|4|5}\033[0m"
Exit
Fi
if [["$"-eq "1"]];then
Echo-e "\033[35m--apache Installation--\033[0m"
Echo-e "\033[35m start extracting ... \033[0m"
Tar vxf httpd-2.2.29.tar.bz2 &>/dev/null
Echo-e "\033[35m file extract complete! Start precompilation ... \033[0m "
cd/lamp/httpd-2.2.29
Else
Echo-e "\033[35m precompiled failed! \033[0m "
Exit 0
Fi
Echo-e "\033[35mapache is installing ... \033[0m"
Make &>/dev/null && make install &>/dev/null
If [$?-eq 0];then
ECHO-E "\033[35mapache installed successfully! \033[0m "
Else
Echo-e "\033[35mapache installation failed! \033[0m "
Exit 0
Fi
Fi
if [["$"-eq "2"]];then
Echo-e "\033[35m--mysql Installation--\033[0m"
Echo-e "\033[35m start extracting ... \033[0m"
cd/lamp/; Tar vxf mysql-5.1.63.tar.gz &>/dev/null
Echo-e "\033[35m decompression done! Start precompilation ... \033[0m "
Else
Echo-e "\033[35m precompiled failed! \033[0m "
Exit 0
Fi
Echo-e "\033[35m Start installing mysql......\033[0m"
Make &>/dev/null && make install &>/dev/null
If [$?-eq 0];then
ECHO-E "\033[35mmysql installed successfully! \033[0m "
Else
Echo-e "\033[35mmysql installation failed! \033[0m "
Exit 0
Fi
Fi
if [["$"-eq "3"]];then
Echo-e "\033[35m--php Installation--\033[0m"
Yum Install libxml2 libxml2-devel-y &>/dev/null
Echo-e "\033[35m start extracting ... \033[0m"
cd/lamp/; Tar vxf php-5.3.29.tar.bz2 &>/dev/null
Echo-e "\033[35m decompression done! Start precompilation ... \033[0m "
cd/lamp/php-5.3.29
Else
Echo-e "\033[35m precompiled failed! \033[0m "
Exit 0
Fi
Echo-e "\033[35m Start installing php......\033[0m"
Make &>/dev/null && make install &>/dev/null
If [$?-eq 0];then
ECHO-E "\033[35mphp installed successfully! \033[0m "
Else
Echo-e "\033[35mphp installation failed! \033[0m "
Exit 0
Fi
Fi
if [["$"-eq "4"]];then
ECHO-E "\033[35m----apache+php integration ...-----\033[0m"
Addtype=/usr/local/apache2/conf/httpd.conf
Sed-i ' S/addtype application\/x-gzip. gz .tgz/& \ n AddType applicati
on\/x-httpd-php. php/' $ADDTYPE
Sed-i ' S/directoryindex index.html/directoryindex index.php index.html/
' $ADDTYPE
ECHO-E "\033[35m----writing PHP test page ...-----\033[0m"
Sleep 2
cd/usr/local/apache2/htdocs/
Echo ' <?php ' >> index.php
Echo ' phpinfo (); ' >> index.php
Echo '?> ' >> index.php
ECHO-E "\033[35m----please visit the PHP test page index.php-----\033[0m"
Fi
if [["$"-eq "5"]];then
ECHO-E "\033[35m----mysql configuration-----\033[0m"
Sleep 2
Useradd MySQL
Rm-rf/etc/my.cnf
Cp/lamp/mysql-5.1.63/support-files/my-medium.cnf/etc/my.cnf
Cp/usr/local/mysql/share/mysql/mysql.server/etc/rc.d/init.d/mysqld
Chkconfig--add mysqld
Chkconfig--level mysqld on
Mkdir/usr/local/mysql/data
Chown-r Mysql.mysql/usr/local/mysql
My_cnf=/etc/my.cnf
Sed-i ' s/myisam_sort_buffer_size = 8m/& \ndatadir = \/usr\/local\/mysql
\/data\//' $MY _cnf
ECHO-E "\033[35mmysql initialization ... \033[0m"
/usr/local/mysql/bin/mysql_install_db--user=mysql--datadir=/usr/local/
mysql/data/&>/dev/null
ECHO-E "\033[35m shut down the firewall ... \033[0m"
Service Iptables Stop &>/dev/null
Echo-e "\033[35m off selinux......\033[0m"
Setenforce 0 &>/dev/null
/usr/local/apache2/bin/apachectl Start &>/dev/null
Service mysqld Start &>/dev/null
ECHO-E "\033[35m----mysql configuration complete-----\033[0m"
Fi
if [["$"-gt "5"]];then
Echo-e "\033[35m Please enter the correct option! \033[0m "
Fi
This article is from the IT Network blog, so be sure to keep this source http://liupengfang1015.blog.51cto.com/6627801/1677784
Lamp Auto-build script installed by option