If condition integrated shell one button installation lamp

Source: Internet
Author: User
Tags install php php server php define

Write operations scripts through if statements and variables,

A key to install the lamp environment of the script;

A key source installation lamp script, the first decomposition of the various functions of the script;


Print Menu:

1) Install Apache Web server

2) Install MySQL DB server

3) Install the PHP server

4) Integrate lamp architecture and start service


1, Apache Server installation deployment.

Download httpd-2.2.27.tar.gz version, download URL, unzip, go to installation directory, Configure;make;make install


2. Installation of MySQL server

Download mysql-5.5.20.tar.bz2 version, download URL, unzip, go to installation directory, Configure;makeinstall


3. PHP Server Installation

Download php-5.3.8.tar.bz2 version, download URL, unzip, go to installation directory, Configure;make;make install


4LAMP Architecture Consolidation and service start-up

/usr/local/apache2/bin/apachectl start


VI htdocs/index.php

<?php

Phppinfo ();

?>

Script page

#! Bin/bash

#auto Install LAMP

#by Lirp 2015-7


#Httpd Define PATH variable

h_files=httpd-2.2.27.bar.bz2

h_files_dir=httpd-2.2.27

h_url=http://mirrors.cnnic.cn/apache/httpd/

h_prefix=/usr/local/apache2/


#mysql Define PATH variable

M_files=mysql-5.5.20.tar.gz

m_files_dir=mysql-5.5.20

m_url=http://downl.chinaunix.net/distfiles/

m_prefix=/usr/local/mysql/


#PHP Define PATH variable

p_files=php-5.3.28.bar.bz2

p_files_dir=php-5.3.28

p_url=http://mirrors.sohu.com/php/

p_prefix=/usr/local/php5/


#auto Install httpd

If [-Z "$"];then

Echo-e "\033[36mplease Select Install Menu follow:\033[0m"

Echo-e "\033[32ml) compile and install Apache server \033[1m"

echo "2) compile and install MySQL server"

echo "3) Compile and install PHP server"

echo "4) Configure index.php and start lamp service"

Echo-e "\033[31musage: {/bin/sh $1|2|3|4|help}\033[0m"

Exit

Fi

if [["$"-eq "1"]];then

Wget-c $H _url/$H _files &&tar-jxvf $H _files &&cd $H _files_dir;. /configure--prefix= $H _prefix

If [$?-eq 0];then

Make &&make Install

Echo-e "\033[32mthe $H _files_dir Sever Install successfully!\033[0m"

Else

Echo-e "\033[32mthe $H _files_dir Sever install failed,please check...! \033[0m "

Exit

Fi

Fi



#auto install MySQL

if [["$"-eq "2"]];then

Wget-c $M _url/$H _files &&tar-zxvf $M _files &&cd $M _files_dir $ $yum Install cmake-y; Cmke. -dcmake_install_prefix= $M _prefix \

-dmysql_unix_addr=/tmp/mysql.sock \

-dmysql_datadir=/date/mysql \

-dsysconfdir=mysql \

-dmysql_user=mysql \

-dmysql_tcp_port=3306 \

-dwith_xtradb_storage_engine=1 \

-dwith_innobase_storage_engine=1 \

-dwith_partitiom_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

-dwith_myisam_storage_engine=1 \

-dwith_readline=1 \

-denabled_local_infile=1 \

-dwith_extra_charsets=1 \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-dextra_charsets=all \

-dwith_big_tables=1 \

-dwith_debug=0

If [$?-eq 0];then

Make &&make Install

Echo-e "\033[32mthe $M _files_dir Sever Install successfully!\033[0m"

Else

Echo-e "\033[32mthe $M _files_dir Sever install failed,please check...! \033[0m "

Exit

Fi

Fi



#auto Install PHP Server

if [["$"-eq "3"]];then

Wget-c $P _url/$P _files &&tar-jxvf $P _files &&cd $P _files_dir;. /configure--prefix= $P _prefix--with-config-file-path= $P _prefix/etc--with-mysql= $M _prefix--with-apxs2= $H _prefix/ Bin/apxs

If [$?-eq 0];then

Make zend_extra_libs= '-liconv ' && make Inatall

Echo-e "\033[32mthe $P _files_dir Sever Install successfully!\033[0m"

Else

Echo-e "\033[32mthe $P _files_dir Sever install failed,please check...! \033[0m "

Exit

Fi

Fi


if [["$"-eq "4"]];then

Sed-i '/directoryindex/s/index.html/indwx.php index.htl/g ' $H _prefix/conf/httpd.conf

$H _prefix/bin/apachectl Restart

echo "AddType application/x-httpd-php. php" >> $H _prefix/conf/httpd.conf

ip= ' ifconfig eth1|grep "bcast" |awk ' {print $} ' |cut-d:-f2 '

echo "You can access/HTTP $IP/"


Cat > $H _prefix/htdocs/index.php >>eof

>?php

Phpinfo ();

?>

Eof

Fi


Hey, you're done.


This article from "Poker Face" blog, reproduced please contact the author!

If condition integrated shell one button installation lamp

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.