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个包,还得加压编译.步骤非常麻烦,并且当做有时候会出错,源 ...
随机推荐
- CoderForces999B- Reversing Encryption
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 一些demo
绑定端口demo: #include <stdio.h> #include <sys/socket.h> #include <stdlib.h> #include ...
- sql service 从创建访问用户到数据库访问 【SQL】
create login [LoginMame] with password=[Pwd]--创建数据库登陆用户 create user [DBLoginName] for login [LoginMa ...
- Vue中实现聊天窗口overflow:auto自动滚动到底部,实现显示当前最新聊天消息
在做消息的项目,当有新消息的时候让新消息出现在最底部,此时的box用的是overflow:auto 注意:vue项目需要注意在dom结构渲染完再进行操作 <div class="mai ...
- 3年Java开发6个点搞定高并发系统面试疑惑
前言 其实所谓的高并发,如果你要理解这个问题呢,其实就得从高并发的根源出发,为啥会有高并发?为啥高并发就很牛逼? 说的浅显一点,很简单,就是因为刚开始系统都是连接数据库的,但是要知道数据库支撑到每秒并 ...
- Vue ---- 表单指令 条件指令 循环指令 分隔符 过滤器 计算属性 监听属性
目录 案例讲解: 一. 表单指令 1.重点: 补充 2.单选框 3.单一复选框 4.多复选框 二 . 条件指令 v-if/v-show ... v-clock 三 . 循环指令 string arra ...
- 牛客练习赛34 little w and Segment Coverage (差分区间)
链接:https://ac.nowcoder.com/acm/contest/297/C来源:牛客网 题目描述 小w有m条线段,编号为1到m. 用这些线段覆盖数轴上的n个点,编号为1到n. 第i条线段 ...
- Java8-Lamda和Stream原理引入
一说明 这边文章主要是带大家为什么会有lamda表达式的出现,流式思想的产生.具体的Lamda表达式操作,Stream流会在后面的文章更新,有兴趣的朋友也可以加一下我微信公众号,分享学习干货. 二ja ...
- [ASP.NET Core 3框架揭秘] 依赖注入[6]:服务注册
通过<利用容器提供服务>我们知道作为依赖注入容器的IServiceProvider对象是通过调用IServiceCollection接口的扩展方法BuildServiceProvider创 ...
- PyTorch-网络的创建,预训练模型的加载
本文是PyTorch使用过程中的的一些总结,有以下内容: 构建网络模型的方法 网络层的遍历 各层参数的遍历 模型的保存与加载 从预训练模型为网络参数赋值 主要涉及到以下函数的使用 add_module ...