#!/bin/bash
########## function ##########
depend_pkg ()
{
yum install gcc gcc-c++ make cmake ncurses-devel libxml2-devel \
perl-devel libcurl-devel libgcrypt libgcrypt-devel libxslt \
libxslt-devel pcre-devel openssl-devel wget -y
}
cat <<END
.[install apache2.]
.[install mysql5.]
.[install php5.]
END
read -p "Please input number : " NUM
case $NUM in
)
########## Install Depend Pkg ##########
depend_pkg;
WorkDIR=/usr/local/src
cd $WorkDIR
[ -f "apr-1.5.1.tar.gz" ] || wget http://mirror.bit.edu.cn/apache/apr/apr-1.5.1.tar.gz
[ -f "apr-util-1.5.3.tar.gz" ] || wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.3.tar.gz
[ -f "httpd-2.4.10.tar.gz" ] || wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.10.tar.gz
ls | xargs -I file tar zxvf file -C $WorkDIR
cd apr-1.5.
./configure --prefix=/usr/local/apr
make && make install
if [ $? -eq ];then
cd $WorkDIR
cd apr-util-1.5.
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
else
echo "------ apr make failed. ------"
exit
fi
########## Install Apache ##########
HTTPDIR=/usr/local/apache2.
if [ $? -eq ];then
cd $WorkDIR
cd httpd-2.4.
./configure -prefix=$HTTPDIR -enable-so -enable-rewrite -enable-modules=all \
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make && make install
else
echo "------ apr-util make failed. ------"
exit
fi
if [ $? -eq ];then
CONF=$HTTPDIR/conf/httpd.conf
cp $HTTPDIR/bin/apachectl /etc/init.d/httpd
chmod +x /etc/init.d/httpd
sed -i "s/#ServerName www.example.com:80/ServerName ${IP}:80/g" $CONF
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/g' $CONF
sed -i "391 s/^/AddType application\/x-httpd-php .php/" $CONF
/etc/init.d/httpd start
IP=`ifconfig eth0 |grep "inet addr" |cut -d: -f2 |awk '{print $1}'`
Urlcode=`curl -o /dev/null -s -w "%{http_code}" $IP/index.html`
[ $Urlcode -eq ] && echo "Apache install success." || echo "Apache install failed."
else
echo "------ apache make failed. ------"
exit
fi
;;
)
########## Install Depend Pkg ##########
depend_pkg;
########## Install Mysql ##########
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql -s /sbin/nologin mysql
WorkDIR=/usr/local/src
MYSQLDIR=/usr/local/mysql5.
cd $WorkDIR
[ -f "mysql-5.5.39.tar.gz" ] || wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.39.tar.gz
tar zxvf mysql-5.5..tar.gz
cd mysql-5.5.
cmake -DCMAKE_INSTALL_PREFIX=$MYSQLDIR \
-DSYSCONFDIR=$MYSQLDIR/etc \
-DMYSQL_DATADIR=$MYSQLDIR/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
if [ $? -eq ];then
$MYSQLDIR/scripts/mysql_install_db \
--basedir=$MYSQLDIR --datadir=$MYSQLDIR/data/ --user=mysql >/dev/null
mkdir $MYSQLDIR/etc
cp support-files/my-medium.cnf $MYSQLDIR/etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
rm -rf /etc/my.cnf
#echo "PATH=$PATH:$MYSQLDIR/bin" >> /etc/profile
#. /etc/profile
chmod +x /etc/init.d/mysqld
chown -R root.mysql $MYSQLDIR
chown -R mysql.mysql $MYSQLDIR/data/
$MYSQLDIR/bin/mysqld_safe --user=mysql&
$MYSQLDIR/bin/mysqladmin -u root password '123.com'
$MYSQLDIR/bin/mysql -uroot -p'123.com' -e "show databases;"
[ $? -eq ] && echo "MySQL install success." || echo "MySQL install failed."
else
echo "------mysql cmake failed.------"
exit
fi
;;
)
########## Install Depend Pkg ##########
depend_pkg;
########## Install GD ##########
yum install gd freetype freetype-devel libpng libpng-devel zlib zlib-devel libjpeg* -y
########## Install PHP ##########
WorkDIR=/usr/local/src
PHPDIR=/usr/local/php5.
PHPCONF=$PHPDIR/etc/php.ini
cd $WorkDIR
[ -f "php-5.4.31.tar.gz" ] || wget http://cn2.php.net/distributions/php-5.4.31.tar.gz
tar zxvf php-5.4..tar.gz
cd php-5.4.
./configure -prefix=$PHPDIR \
--with-config-file-path=$PHPDIR/etc \
--with-apxs2=/usr/local/apache2./bin/apxs \
--with-mysql=/usr/local/mysql5. \
--with-mysqli=/usr/local/mysql5./bin/mysql_config \
--enable-soap --enable-bcmath --enable-zip --enable-ftp \
--enable-mbstring --with-gd --with-libxml-dir --with-jpeg-dir \
--with-png-dir --with-freetype-dir --with-zlib \
--with-libxml-dir=/usr --with-curl --with-xsl --with-openssl
make && make install
if [ $? -eq ];then
cp php.ini-production $PHPCONF
echo "data.timezone = Asia\Shanghai" >> $PHPCONF
sed -i 's/upload_max_filesize = 2M/ upload_max_filesize = 50M/g' $PHPCONF
sed -i 's/display_errors = Off/display_errors = On/g' $PHPCONF
echo "<?php phpinfo();?>" > /usr/local/apache2./htdocs/index.php
/etc/init.d/httpd restart
/etc/init.d/mysqld restart &>/dev/null
IP=`ifconfig eth0 |grep "inet addr" |cut -d: -f2 |awk '{print $1}'`
Urlcode=`curl -o /dev/null -s -w "%{http_code}" $IP/index.php`
[ $Urlcode -eq ] && echo "PHP install success." || echo "PHP install failed."
echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local
chkconfig mysqld on
else
echo "------ php make failed. ------"
exit
fi
;;
*)
echo "Please input number 1 2 3."
esac

CentOS自动化安装LAMP脚本的更多相关文章

  1. CentOS yum 安装LAMP PHP5.4版本

    CentOS yum 安装LAMP PHP5.4版本 [日期:2015-06-04] 来源:Linux社区  作者:rogerzhanglijie [字体:大 中 小]     Linux系统版本:C ...

  2. 脚本实现自动化安装lamp&lnmp

    #备注:前提是将lnmp和lnmp自动化脚本写好放在相应的路径, 脚本已写好,请查看我博客中的 shell脚本 专栏! #!/bin/bash #安装lamp或者lnmp path=/server/s ...

  3. (转)CentOS一键安装Nginx脚本

    原文:https://www.xiaoz.me/archives/10301 https://blog.slogra.com/post-676.html-----centos7一键安装nginx脚本

  4. shell脚本自动化安装LAMP

    #!/bin/bash#auto make install LAMP#by authors yehailun #arp和apr-util依赖APR_FILES=apr-1.6.2.tar.gz APR ...

  5. CentOS编译安装lamp

    LAMP环境搭建(编译安装CentOS+httpd2.2+mysql5.5+php5.4) 首先准备以下压缩包 <ignore_js_op> (1)编译安装apache 1.配置防火墙,开 ...

  6. Centos 7 安装LAMP以及在Apache上安装positiveSSL。

    简介 LAMP(linux , Apache, mysql , php)是集成动态网站经常使用的一套开源软件,实际包含linux操作系统,Apache web服务器,mysql(mariadb 分支) ...

  7. linux centos yum安装LAMP环境

    centos 6.5 1.yum安装和源代码编译在使用的时候没啥区别,但是安装的过程就大相径庭了,yum只需要3个命令就可以完成,源代码需要13个包,还得加压编译,步骤很麻烦,而且当做有时候会出错,源 ...

  8. Centos编译安装 LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8)+ Redis

    转载地址:http://www.cnblogs.com/whoamme/p/3530056.html 软件源代码包存放位置:/usr/local/src 源码包编译安装位置:/usr/local/软件 ...

  9. Centos yum 安装lamp PHP5.4版本号

    centos 6.5 1.yum安装和源码编译在使用的时候没啥差别.可是安装的过程就大相径庭了,yum仅仅须要3个命令就能够完毕,源码须要13个包,还得加压编译.步骤非常麻烦,并且当做有时候会出错,源 ...

随机推荐

  1. Spring源码学习笔记之基于ClassPathXmlApplicationContext进行bean标签解析

    bean 标签在spring的配置文件中, 是非常重要的一个标签, 即便现在boot项目比较流行, 但是还是有必要理解bean标签的解析流程,有助于我们进行 基于注解配置, 也知道各个标签的作用,以及 ...

  2. harbor部署常见的错误

    总结部署harbor过程所遇到的一些坑   1:在使用docker push镜像的时候提示:denied: requested access to the resource is denied,用户和 ...

  3. Mybatis需要注意的细节

    mybatis第二篇 1.${}和#{}的区别 1.#在传参的时候,会自动拼接单引号:$不能拼接单引号; 2.$传参时,一般不支持jdbcType指定类型的写法;#则可以;如: ​ #{name,jd ...

  4. 有一部分程序员还不知道Java 中的注解到底是如何工作的?

    作者:人晓 自Java5.0版本引入注解之后,它就成为了Java平台中非常重要的一部分.开发过程中,我们也时常在应用代码中会看到诸如@Override,@Deprecated这样的注解. 这篇文章中, ...

  5. Java获取配置文件中的属性

    获取配置文件的属性值 example 目标配置文件jdbc.properties,现想要在java类里面调用opcl的url jdbc.url=jdbc:mysql://localhost:3306/ ...

  6. 牛客NOIP暑期七天营-提高组5+普及组5

    ————提高组———— 第一题:deco的abs 题目链接:https://ac.nowcoder.com/acm/contest/934/A 因为每个数都可以加任意次 d ,所以可以推出 0 < ...

  7. 《Dotnet9》系列-FluentValidation在C# WPF中的应用

    时间如流水,只能流去不流回! 点赞再看,养成习惯,这是您给我创作的动力! 本文 Dotnet9 https://dotnet9.com 已收录,站长乐于分享dotnet相关技术,比如Winform.W ...

  8. mySql的case when用法

    背景 有点忘了,记录下 写法一 case colume when condition then result when condition then result when condition the ...

  9. 找不到UseInMemoryDatabase方法

    创建WebApi项目时,在ConfigureServices中注册数据库上下文时,提示找不到UseInMemoryDatabase方法. 打开“工具-Nuget包管理器-程序包管理器控制台”,输入“I ...

  10. linux 删除.svn文件

    linux删除当前目录及其子目录下的.svn文件,linux下删除全部的.svn文件 find . -name "*.svn" -type d -print -exec rm -r ...