lamp-Installation Script-Rev. 1

Source: Internet
Author: User

#!/bin/bash

#write by ZHANG_PC

#at 2015.07.25

#apache2.4 php.5.4 mysql5.5

#脚本说明, if the current machine can be connected to the Internet, download the source package from the Internet installation, if you can not surf the Internet, using the local source package, you need to upload the source package to the directory where the script



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 Apr_install () {

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

If [$?-eq 0];then

echo "The APR install is successful"

Else

echo "The APR install is failed"

Fi

}



function Apr_util_install () {

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

If [$?-eq 0];then

echo "The Apr_util install is successful"

Else

echo "The Apr_util install is failed"

Fi

}



function Apache_install () {

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 install is successful"

Else

echo "The Apache install is failed"

Exit

Fi

}


function Mysql_install () {

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-j

If [$?-eq 0];then

echo "The MySQL is successful"

Else

echo "The MySQL is failed"

Exit

Fi

}



function Php_install () {

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-j2

If [$?-eq 0];then

echo "The PHP is successful"

Else

echo "The PHP is failed"

Exit

Fi

}



function Lamp_zh () {

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[0m"

Echo-e "\033[32m 1 installation apr\033[0m"

Echo-e "\033[32m 2 installation apr-util\033[0m"

Echo-e "\033[32M 3 installation apache\033[0m"

Echo-e "\033[32m 4 installation mysql\033[0m"

Echo-e "\033[32m 5 Installation php\033[0m"

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

elif [$1-eq 1];then

Ping-c 2 www.baidu.com

If [$?-eq 0];then

wget $APR _url && apr_install

Else

Apr_install

Fi

elif [$1-eq 2];then

Ping-c 2 www.baidu.com

If [$?-eq 0];then

wget $APR _u_url && apr_util_install

Else

Apr_util_install

Fi

elif [$1-eq 3];then

Ping-c 2 www.baidu.com

If [$?-eq 0];then

wget $A _url && apache_install

Else

Apache_install

Fi

elif [$1-eq 4];then

Ping-c 2 www.baidu.com

If [$?-eq 0];then

wget $M _url && mysql_install

Else

Mysql_install

Fi

elif [$1-eq 5];then

Ping-c 2 www.baidu.com

If [$?-eq 0];then

wget $P _url && php_install

Else

Php_install

Fi

elif [$1-eq 6];then

Lamp_zh

Else

Exit

Fi








This article is from the "PC personal blog" blog, make sure to keep this source http://pc1990.blog.51cto.com/10541224/1678359

lamp-Installation Script-Rev. 1

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.