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个包,还得加压编译.步骤非常麻烦,并且当做有时候会出错,源 ...
随机推荐
- CF296C Greg and Array 查分数组
题目链接:http://codeforces.com/problemset/problem/296/C 题意:给你n.m.k,表示n个数a[i],m个对数的操作,k个对操作的操作.m个操作:数a[l] ...
- NIM游戏,NIM游戏变形,威佐夫博弈以及巴什博奕总结
NIM游戏,NIM游戏变形,威佐夫博弈以及巴什博奕总结 经典NIM游戏: 一共有N堆石子,编号1..n,第i堆中有个a[i]个石子. 每一次操作Alice和Bob可以从任意一堆石子中取出任意数量的石子 ...
- SpringBoot系列之JDBC数据访问
SpringBoot系列之JDBC数据访问 New->Project or Module->Spring Initializer 选择JDBC和mysql驱动,为了方便测试web等等也可以 ...
- Flink入门(四)——编程模型
flink是一款开源的大数据流式处理框架,他可以同时批处理和流处理,具有容错性.高吞吐.低延迟等优势,本文简述flink的编程模型. 数据集类型: 无穷数据集:无穷的持续集成的数据集合 有界数据集:有 ...
- CyAPI环境搭建
http://jingyan.baidu.com/article/e6c8503c0690cee54f1a1893.html
- JS操作document对象
找到对象: document.getElementById():返回对拥有指定 id 的第一个对象的引用. document.getElementsByName():返回带有指定名称的对象集合. do ...
- 【Vuejs】301- Vue 3.0前的 TypeScript 最佳入门实践
前言 我个人对更严格类型限制没有积极的看法,毕竟各类转类型的骚写法写习惯了. 然鹅最近的一个项目中,是 TypeScript+ Vue,毛计喇,学之...-真香! 1. 使用官方脚手架构建 npm i ...
- 理解Vue中的nextTick
参考博客:https://www.jianshu.com/p/a7550c0e164f
- Mysql Commands
start service: mysqld --console; start client: mysql -uroot -proot; check server version: show varia ...
- Redis面试热点工程架构篇之数据同步
温馨提示 更佳阅读体验:[决战西二旗]|Redis面试热点之工程架构篇[2] 前言 前面用了3篇文章介绍了一些底层实现和工程架构相关的问题,鉴于Redis的热点问题还是比较多的,因此今天继续来看工程架 ...