One-click Install Lamp Script--Advanced version

Source: Internet
Author: User

#!/bin/bash

#write by ZHANG_PC

#at 2015.07.24

#apache2.4 php.5.4 mysql5.5


Apr_files=apr-1.5.2.tar.gz

apr_dir=apr-1.5.2

Arp_pre=/usr/local/apr

Apr_url=http://mirror.bit.edu.cn/apache/apr/apr-1.5.2.tar.gz


Apr_u_files=apr-util-1.5.4.tar.gz

apr_u_dir=apr-util-1.5.4

Apr_u_pre=/usr/local/apr-util

Apr_u_url=http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.4.tar.gz


A_files=httpd-2.4.16.tar.gz

a_dir=httpd-2.4.16

A_pre=/usr/local/apache

A_url=http://mirrors.sohu.com/apache/httpd-2.4.16.tar.gz


M_files=mysql-5.5.44.tar.gz

m_dir=mysql-5.5.44

M_pre=/usr/local/mysql

M_url=http://download.softagency.net/mysql/downloads/mysql-5.5/mysql-5.5.44.tar.gz


P_files=php-5.4.22.tar.gz

p_dir=php-5.4.22

p_pre=/usr/local/php

P_url=http://mirrors.sohu.com/php/php-5.4.22.tar.gz




function Apache () {

TAR-ZXVF $APR _files;cd $APR _dir;. /configure--prefix= $APR _pre

If [$?-ne 0];then Exit;fi

Make

If [$?-ne 0];then Exit;fi

Make install

If [$?-ne 0];then Exit;fi

Cd..

TAR-ZXVF $APR _u_files;cd $APR _u_dir;. /configure--prefix= $APR _u_pre--with-apr= $APR _pre && make && make install

Cd..

Yum Install Pcre-devel openssl-devel-y

TAR-ZXVF $A _FILES;CD $A _dir

./configure--prefix= $A _pre--enable-so--enable-ssl--enable-cgi--enable-rewrite--with-zlib--with-pcre --with-arp= $APR _pre--with-apr-util= $APR _u_pre--enable-modules=most--enable-mpms-shared=all--with-mpm=prefork

Make-j2 && make Install-j2

If [$?-eq 0];then

echo "The Apache is successful"

Else

echo "The Apache is failed"

Exit

Fi

}



function MySQL () {

Yum install gcc-c++ cmake ncurses-devel Bison perl-y

Useradd-s/sbin/nologin MySQL

Mkdir-p/data/mysql

Chown-r Mysql.mysql/data/mysql

TAR-ZXVF $M _FILES;CD $M _dir

cmake-dcmake_install_prefix= $M _pre-dmysql_datadir=/data/mysql-dwith_myisam_storage_engine=1

-dwith_innobase_storage_engine=1-dwith_memory_storage_engine=1-dwith_readline=1-dmysql_tcp_port=3306

-denabled_local_infile=1-dwith_partition_storage_engine=1-dextra_charsets=all-ddefault_charset=utf8

-ddefault_collation=utf8_general_ci-dwith_debug=0-dmysql_user=mysql-dmysql_unix_addr=/data/mysql/mysql.sock

Make-j2 && make Install-j2

If [$?-eq 0];then

echo "The MySQL is successful"

Else

echo "The MySQL is failed"

Exit

Fi

}



function php () {

Yum install libxml2-devel libmcrypt-devel bzip2-devel libxml2-devel openssl-devel bzip2 bzip2-devel-y

TAR-ZXVF $P _FILES;CD $P _dir

./configure--prefix= $P _pre--with-config-file-path= $P _pre/etc--with-apxs2= $A _pre/bin/apxs--with-mysql= $M _pre

Make-j2 && make Install

If [$?-eq 0];then

echo "The PHP is successful"

Else

echo "The PHP is failed"

Exit

Fi

}



function lamp () {

Sed-i "s/#ServerName www.example.com:80/ServerName www.example.com:80/g"/usr/local/apache/conf/httpd.conf

Sed-i "S/directoryindex index.html/directoryindex index.php index.html/g"/usr/local/apache/conf/httpd.conf

Sed-i ' 310a addtype application/x-httpd-php. php '/usr/local/apache/conf/httpd.conf

/usr/local/apache/bin/apachectl start


/BIN/CP./$M _DIR/SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF

/BIN/CP./$M _dir/support-files/mysql.server/etc/init.d/mysqld

chmod 755/etc/init.d/mysqld

Sed-i ' 38a datadir=/data/mysql '/etc/my.cnf

Sed-i ' 38a basedir=/usr/local/mysql '/etc/my.cnf

/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/mysql--user=mysql

/etc/init.d/mysqld start

Chkconfig--add mysqld

echo "path= $PATH:/usr/local/mysql/bin" >>/etc/profile

Source/etc/profile

}




If [-Z $];then

ECHO-E "\033[32m Please select Count\033[1m"

Echo-e "\033[32m 1 installation apache\033[1m"

Echo-e "\033[32m 2 installation Mysql\033[1m"

Echo-e "\033[32M 3 installation Php\033[1m"

ECHO-E "\033[32M 4 lamp integration and start service \033[0m"

Exit

elif [$1-eq 1];then

wget $APR _url && wget $APR _u_url && wget $A _url && Apache

elif [$1-eq 2];then

wget $M _url && MySQL

elif [$1-eq 3];then

wget $P _url && php

elif [$1-eq 4];then

Lamp

Else

Exit

Fi


This article from the "PC personal blog" blog, reproduced please contact the author!

One-click Install Lamp Script--Advanced version

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.