CentOS自动化安装LAMP脚本
#!/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脚本的更多相关文章
- CentOS yum 安装LAMP PHP5.4版本
CentOS yum 安装LAMP PHP5.4版本 [日期:2015-06-04] 来源:Linux社区 作者:rogerzhanglijie [字体:大 中 小] Linux系统版本:C ...
- 脚本实现自动化安装lamp&lnmp
#备注:前提是将lnmp和lnmp自动化脚本写好放在相应的路径, 脚本已写好,请查看我博客中的 shell脚本 专栏! #!/bin/bash #安装lamp或者lnmp path=/server/s ...
- (转)CentOS一键安装Nginx脚本
原文:https://www.xiaoz.me/archives/10301 https://blog.slogra.com/post-676.html-----centos7一键安装nginx脚本
- shell脚本自动化安装LAMP
#!/bin/bash#auto make install LAMP#by authors yehailun #arp和apr-util依赖APR_FILES=apr-1.6.2.tar.gz APR ...
- CentOS编译安装lamp
LAMP环境搭建(编译安装CentOS+httpd2.2+mysql5.5+php5.4) 首先准备以下压缩包 <ignore_js_op> (1)编译安装apache 1.配置防火墙,开 ...
- Centos 7 安装LAMP以及在Apache上安装positiveSSL。
简介 LAMP(linux , Apache, mysql , php)是集成动态网站经常使用的一套开源软件,实际包含linux操作系统,Apache web服务器,mysql(mariadb 分支) ...
- linux centos yum安装LAMP环境
centos 6.5 1.yum安装和源代码编译在使用的时候没啥区别,但是安装的过程就大相径庭了,yum只需要3个命令就可以完成,源代码需要13个包,还得加压编译,步骤很麻烦,而且当做有时候会出错,源 ...
- 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/软件 ...
- Centos yum 安装lamp PHP5.4版本号
centos 6.5 1.yum安装和源码编译在使用的时候没啥差别.可是安装的过程就大相径庭了,yum仅仅须要3个命令就能够完毕,源码须要13个包,还得加压编译.步骤非常麻烦,并且当做有时候会出错,源 ...
随机推荐
- 转化欧拉回路(难题)-UESTC-1957励志的猴子
励志的猴子 Time Limit: 1000 MS Memory Limit: 256 MB Submit Status 上图是2013南京亚青会吉祥物圆圆.自从它诞生以来,它就被吐槽为最丑吉 ...
- Redis 使用消息隊列
關鍵函數 ListRightPush 生產消息 ListRightPop 消費消息 這是從右面增或取 左邊亦然
- Socket无法通过防火墙的问题
无论是配好端口还是例外的应用程序都不行 更改本地终结点为 socket.Bind()); IPAddress.Any 不要使用127.0.0.1 不要使用127.0.0.1 不要使用127.0.0.1
- springboot自动装配(3)---条件注解@Conditional
之前有说到springboot自动装配的时候,都是去寻找一个XXXAutoConfiguration的配置类,然而我们的springboot的spring.factories文件中有各种组件的自动装配 ...
- art-template与swiper发生冲突导致swiper的一些样式不起作用
我们在实际中的前后端分离开发中,在进行渲染后端返回来的数据时我们有时会用到模板来进行渲染数据,而在渲染数据中我们可能用到一些组件来进行一些样式显示.而在页面中数据显示了导致组件的一些样式没有显示,一些 ...
- vue中$attrs和$listeners以及inheritAttrs的用法
官方文档说明: 一.解释:包含了父作用域中不作为 prop 被识别 (且获取) 的特性绑定 (class 和 style 除外). 意思就是父组件往子组件传没有在props里声明过的值时,子组件可以通 ...
- 【Java Web开发学习】Spring配置数据源
Spring配置数据源 转载:https://www.cnblogs.com/yangchongxing/p/10027495.html =============================== ...
- 面试完腾讯,总结了这12道Zookeeper面试题!
前言 ZooKeeper 是一个开源的分布式协调服务,可以基于 ZooKeeper 实现诸如:数据发布/订阅.负载均衡.命名服务.分布式协调/通知.集群管理.Master 选举.配置维护,名字服务.分 ...
- Ansible-上部
Ansible概述 Ansible是一个配置管理系统configuration management systempython 语言是运维人员必须会的语言ansible 是一个基于python 开发的 ...
- CCF-CSP题解 201803-4 棋局评估
求当前井字棋局的得分. 用dfs虚构一下搜索树,每个节点对应一个不同的棋局. 每个节点有一个situation()情况评估,若胜负已定,则对应该棋局的评分:否则为0,表示胜负未定或平局. 每个节点还有 ...