#!/bin/bash
#write by ZHANG_PC
#at 2015.07.21
#apache2.2.27 mysql5.1 php5.4
#安装说明, because of the speed of the reason, will not download, execute the script before you upload the source code to the same directory as the script
Echo-e "\033[32m This is a lamp one button installation script\033[0m"
Echo-e "\033[32m first step to install Apache \033[0m"
Echo-e "\033[32m second step to install MySQL \033[0m"
Echo-e "\033[32m The third step to install PHP \033[0m"
ECHO-E "\033[32m Lamp integrated and started service \033[0m"
File_a=httpd-2.2.27.tar.gz
dir_a=httpd-2.2.27
File_m=mysql-5.1.63.tar.gz
dir_m=mysql-5.1.63
file_p=php-5.4.13.tar.bz2
dir_p=php-5.4.13
-------------------------------------------------------------------------------
#安装apache
Yum install-y gcc
TAR-ZXVF $file _a;cd $dir _a
./configure--prefix=/usr/local/apache--enable-so--enable-rewrite
Make-j2 && make Install-j2
If [$?-eq 0];then
Echo-e "\033[32m The Apache is successful\033[0m"
Else
Echo-e "\033[32m The Apache is failed\033[0m"
Exit
Fi
----------------------------------------------------------------------------------
#安装mysql
Cd..
Yum install-y ncurses-devel gcc-c++
TAR-ZXVF $file _m;cd $dir _m
./configure--prefix=/usr/local/mysql--enable-assembler
Make-j2 && make Install-j2
If [$?-eq 0];then
Echo-e "\033[32m the MySQL is successful\033[0m"
Else
Echo-e "\033[32m the MySQL is failed\033[0m"
Exit
Fi
-------------------------------------------------------------------------------------
#安装php
Cd..
Yum Install-y libxml2-devel
TAR-JXVF $file _p;cd $dir _p
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin /apxs--with-mysql=/usr/local/mysql/
Make-j2 && make Install-j2
If [$?-eq 0];then
Echo-e "\033[32m the PHP is successful\033[0m"
Else
Echo-e "\033[32m the PHP is failed\033[0m"
Fi
-------------------------------------------------------------------------------------
#整合lamp, and start the service
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.html index.php/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
Cd..
/BIN/CP./$dir _M/SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
/BIN/CP./$dir _m/support-files/mysql.server/etc/init.d/mysqld
chmod 755/etc/init.d/mysqld
Mkdir-p/data/mysql
Useradd-s/sbin/nologing MySQL
Chown-r Mysql.mysql/data/mysql
Sed-i ' 38a datadir=/data/mysql '/etc/my.cnf
Sed-i ' 38a basedir=/usr/local/mysql '/etc/my.cnf
/usr/local/mysql/bin/mysql_install_db--user=mysql
/etc/init.d/mysqld start
Chkconfig--add mysqld && chkconfig--level mysqld
This article is from the "PC personal blog" blog, make sure to keep this source http://pc1990.blog.51cto.com/10541224/1677579
One-click Install lamp Script--Beginner version