码迷,mamicode.com
首页 > 其他好文 > 详细

lamp一键安装第四版

时间:2015-08-01 19:12:51      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:martin   local   

#!/bin/bash

#author by martin 2015-07-22

#auto install lamp


function apache_install(){

#apache auto install

echo -e "\033[32m prepare apache env \033[0m"

H_FILE=httpd-2.2.31.tar.gz

H_DIR=httpd-2.2.31


yum install apr apr-util apr-devel apr-util-devel   -y

cd /usr/src

wget  http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz

tar xf $H_FILE

cd $H_DIR

./configure --prefix=/usr/local/apache2/ --enable-rewrite  --enable-so --with-mpm=worker \

--enable-expires  --enable-deflate  --enable-headers

make && make install

        if [ $? -eq 0 ];then

                echo "apache install successful"

        fi

exit

}


function mysql_install(){

#mysql auto install

echo -e "\033[32m prepare mysql \033[0m" 


M_FILE=mysql-5.1.72.tar.gz

M_DIR=mysql-5.1.72

groupadd mysql

useradd -s /sbin/nologin -g mysql -M mysql

cd /usr/src


wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72.tar.gz

tar xf $M_FILE

cd $M_DIR

./configure --prefix=/usr/local/mysql --enable-assembler  --with-mysqld-user=mysql \

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --localstatedir=/usr/local/mysql/data


        if [ $? -eq 0 ];then

                make &&make install

        fi

                if [ $? -eq 0 ];then

                        echo -e "\033[32mmysql install succefull\033[0m"


                        /bin/cp support-files/my-small.cnf /etc/my.cnf

                        /bin/cp support-files/mysql.server /etc/init.d/mysqld

                        chmod +x /etc/init.d/mysqld


                        cd /usr/local/mysql/


                        mkdir data

                        chown mysql.mysql /usr/local/mysql/

                        ./bin/mysql_install_db --user=mysql 

                        exit


                fi

}


function php_install(){

#php auto install

echo -e "\033[32m prepare php \033[0m"

P_FILE=php-5.4.22.tar.gz

P_DIR=php-5.4.22


cd /usr/src

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

tar xf $P_FILE

cd $P_DIR

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs \

--with-mysql=/usr/local/mysql/     --enable-sockets

if [ $? -eq 0  ];then

        echo -e "\033[32m php install successful\033[0m"

fi

make&&make install 

/bin/cp /usr/src/php-5.4.22/php.ini-production /usr/local/php5/lib/php.ini

exit




#lamp整合 auto install

echo -e "\033[32m prepare lamp整合 \033[0m"

if [ $1 -eq 4 ];then

        sed -i ‘s#DirectoryIndex index.html#DirectoryIndex index.php index.html#g‘   /usr/local/apache2/conf/httpd.conf

        echo "AddType     application/x-httpd-php .php" >>/usr/local/apache2/conf/httpd.conf

cat > /usr/local/apache2/htdocs/index.php<<EOF

<?php

phpinfo();

?>

EOF


fi

}





PS3="pls select insatll lamp for menu:"


select i in apache_install mysql_install php_install

do


case $i in

        apache_install)

        apache_install

        ;;

        mysql_install)

        mysql_install

        ;;

        php_install)

        php_install

        ;;

        *)

        echo "usge:sh $0 1|2|3"

        ;;


esac


done


本文出自 “martin” 博客,请务必保留此出处http://huaxin.blog.51cto.com/903026/1680781

lamp一键安装第四版

标签:martin   local   

原文地址:http://huaxin.blog.51cto.com/903026/1680781

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!