shell脚本自动化安装LAMP
#!/bin/bash
#auto make install LAMP
#by authors yehailun
#arp和apr-util依赖
APR_FILES=apr-1.6.2.tar.gz
APR_FILES_DIR=/usr/local/src/apr-1.6.2
APR_URL=http://mirrors.ustc.edu.cn/apache/apr
APR_PREFIX=/usr/local/apr
APR_UTIL_FILES=apr-util-1.6.0.tar.gz
APR_UTIL_FILES_DIR=/usr/local/src/apr-util-1.6.0
APR_UTIL_URL=http://mirrors.ustc.edu.cn/apache/apr
APR_UTIL_PREFIX=/usr/local/apr-util
#pcre
PCRE_FILES=pcre-8.37.tar.gz
PCRE_FILES_DIR=/usr/local/src/pcre-8.37
PCRE_URL=https://nchc.dl.sourceforge.net/project/pcre/pcre/8.37
PCRE_PREFIX=/usr/local/pcre
#Http define path variable
H_FILES=httpd-2.4.27.tar.gz
H_FILES_DIR=/usr/local/src/httpd-2.4.27
H_URL=http://mirrors.sohu.com/apache
H_PREFIX=/usr/local/apache
#MySQL define path variable
M_FILES=mysql-5.6.36.tar.gz
M_FILES_DIR=/usr/local/src/mysql-5.6.36
M_URL=http://mirrors.sohu.com/mysql/MySQL-5.6
M_PREFIX=/usr/local/mysql/
#PHP define path variable
P_FILES=php-5.6.13.tar.gz
P_FILES_DIR=/usr/local/src/php-5.6.13
P_URL=http://mirrors.sohu.com/php/
P_PREFIX=/usr/local/php
if [ -z "$1" ];then
echo -e "\033[32m Please Select Install Menu follow: \033[1m"
echo -e "1)安装依赖包"
echo -e "2)编译安装Apache服务器"
echo -e "3)编译安装MySQL服务器"
echo -e "4)编译安装PHP服务器"
echo -e "5)配置index.php并启动LAMP服务"
echo -e "\033[31m Usage:{ /bin/sh $0 1|2|3|4|5|help} \033[0m"
fi
if [[ "$1" -eq "1" ]];then
yum groupinstall "Development Tools" "Development Libraries" -y
yum install gcc gcc-c++ openssl-devel expat-devel -y
#Install apr
wget -c $APR_URL/$APR_FILES && tar -zxvf $APR_FILES -C /usr/local/src && cd $APR_FILES_DIR; ./configure --prefix=$APR_PREFIX
if [ $? -eq 0 ];then
make -j 4 && make install && cd
echo -e "\033[32m The Apr Install Successfully! \033[0m"
else
echo -e "\033[32m The Apr Install Failed,Please check! \033[0m"
exit
fi
#Install apr-util
wget -c $APR_UTIL_URL/$APR_UTIL_FILES && tar -zxvf $APR_UTIL_FILES -C /usr/local/src && cd $APR_UTIL_FILES_DIR; ./configure --prefix=$APR_UTIL_PREFIX --with-apr=$APR_PREFIX
if [ $? -eq 0 ];then
make -j 4 && make install && cd
echo -e "\033[32m The Apr-util Install Successfully! \033[0m"
else
echo -e "\033[32m The Apr-util Install Failed,Please check! \033[0m"
exit
fi
#Install pcre
wget -c $PCRE_URL/$PCRE_FILES && tar -zxvf $PCRE_FILES -C /usr/local/src && cd $PCRE_FILES_DIR; ./configure --prefix=$PCRE_PREFIX
if [ $? -eq 0 ];then
make -j 4 && make install && cd
echo -e "\033[32m The Pcre Install Successfully! \033[0m"
echo -e "\033[32m All Dependency Packages Are Installed Successfully! \033[0m"
else
echo -e "\033[32m The Pcre Install Failed,Please check! \033[0m"
exit
fi
fi
#Install Httpd Server
if [[ "$1" -eq "2" ]];then
wget -c $H_URL/$H_FILES && tar -zxvf $H_FILES -C /usr/local/src && cd $H_FILES_DIR ; ./configure --prefix=$H_PREFIX --enable-so --enable-rewrite --enable-ssl --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event
if [ $? -eq 0 ];then
make -j 4 && make install && cd
echo -e "\033[32m The Httpd Server Install Successfully! \033[0m"
chown -R apache:apache /usr/local/apache/
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
sed -i "9a # chkconfig:2345 64 36" /etc/init.d/httpd
sed -i "197a ServerName localhost:80" /usr/local/apache/conf/httpd.conf
useradd -M -s /sbin/nologin apache
sed -i "s/^User/User apache/g" /usr/local/apache/conf/httpd.conf
sed -i "s/^Group/Group apache/g" /usr/local/apache/conf/httpd.conf
chkconfig --add httpd
service httpd start
else
echo -e "\033[32m The Httpd Server Install Failed,Please check! \033[0m"
exit
fi
fi
#Install MySQL
if [[ "$1" -eq "3" ]];then
yum remove -y mysql mysql-server
rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64
yum install -y cmake ncurses-devel;
useradd -M -s /sbin/nologin mysql
wget -c $M_URL/$M_FILES && tar -zxvf $M_FILES -C /usr/local/src && cd $M_FILES_DIR
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL-USER=mysql
if [ $? -eq 0 ];then
make -j 4 && make install && cd
else
echo -e "\033[32m The MySQL Server Install Failed,Please check! \033[0m"
exit
fi
chown -R mysql:mysql /usr/local/mysql/
/bin/cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
/bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i 's%^basedir=%basedir=/usr/local/mysql%' /etc/init.d/mysqld
sed -i 's%^datadir=%datadir=/usr/local/mysql/data%' /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
/usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--basedir=/usr/local/mysql/ \
--datadir=/usr/local/mysql/data/ \
--user=mysql
if [ $? -eq 0 ];then
echo -e "033[32m The MySQL Server Install Successfully! \033[0m"
ln -s /usr/local/mysql/bin/* /bin/
service mysqld start
else
echo -e "033[32mThe MySQL Server Install Failed,Please check!\033[0m"
exit
fi
fi
#Install PHP Server
if [[ "$1" -eq "4" ]];then
yum install -y libxml2-devel
wget -c $P_URL/$P_FILES && tar -zxvf $P_FILES -C /usr/local/src && cd $P_FILES_DIR &&./configure --prefix=$P_PREFIX --with-apxs2=$H_PREFIX/bin/apxs --with-config-file-path=$P_PREFIX --with-mysql=$M_PREFIX
if [ $? -eq 0 ]; then
make && make install && cd $P_FILES_DIR
cp php.ini-production /usr/local/php/php.ini ; cd
echo -e "\033[32m The PHP Install Successfully! \033[0m"
else
echo -e "\033[32m The PHP Install Failed,Please check! \033[0m"
exit
fi
fi
#Start LAMP SERVICE
if [[ "$1" -eq "5" ]];then
sed -i '/DirectoryIndex/s/index.html/index.php index.html/g' $H_PREFIX/conf/httpd.conf
echo "AddType application/x-httpd-php .php" >> $H_PREFIX/conf/httpd.conf
service httpd restart
IP=`ifconfig eth0|grep "Bcast"|awk '{print $2}'| cut -d: -f2`
echo "You can access http://$IP/"
cat > $H_PREFIX/htdocs/index.php <<EOF
<?php
phpinfo();
?>
EOF
service httpd restart
fi
shell脚本自动化安装LAMP的更多相关文章
- shell脚本自动化安装pgsql10.5版本
看到有个大佬写了个很实用的脚本,于是这里做了转载 #!/bin/bash #进入软件的制定安装目录 echo "进入目录/usr/local,下载pgsql文件" cd /usr/ ...
- shell脚本编译安装LAMP环境
#filename lamp.sh#version Centos6.7;apache2.4.23;mariadb-5.5.40;php5.5.38#data 2016/09/28#mail 23853 ...
- fdisk分区硬盘并shell脚本自动化
最近工作需要用到对硬盘进行shell脚本自动化分区和mount的操作,google了一些资料,下面做个总结. 如果硬盘没有进行分区(逻辑分区或者扩展分区,关于两者概念,自行google),我们将无法将 ...
- Centos 6.4上面用Shell脚本一键安装vsftpd
Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...
- Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15 #!/bin/bash if [ `uname -m` == "x86_64" ];then machi ...
- shell脚本自动化部署服务
shell脚本自动化部署 !/bin/bash #export PATH=$PATH:/export/maven/bin run_flag_dir="/data0/shell/deploy_ ...
- 安装完Ubuntu后通过shell脚本一键安装软件
安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...
- shell脚本自动化部署
由于公司技术部团队较小,没有专门的运维团队,所以运维工作技术部承包了. 一.纯人工部署是这样的: 1. 本地打包:一般 maven clean package 2. 借助xftp上传到服务器对应目录 ...
- 脚本实现自动化安装lamp&lnmp
#备注:前提是将lnmp和lnmp自动化脚本写好放在相应的路径, 脚本已写好,请查看我博客中的 shell脚本 专栏! #!/bin/bash #安装lamp或者lnmp path=/server/s ...
随机推荐
- 前端js实现打印excel表格
产品原型: 图片.png 功能需求:点击导出考勤表格按钮,会自动下载成Excel格式 图片.png 图片.png jsp页面代码: <div class="tools"> ...
- 【u110】灾后重建
Time Limit: 1 second Memory Limit: 128 MB [问题描述] B地区在地震过后,所有村庄都造成了一定的损毁,而这场地震却没对公路造成什么影响.但是在村庄重建好之前, ...
- web报表工具FineReport经常使用函数的使用方法总结(文本函数)
文本函数 CHAR CHAR(number):依据指定数字返回相应的字符.CHAR函数可将计算机其它类型的数字代码转换为字符. Number:用于指定字符的数字,介于1Number:用于指定字符的数字 ...
- C#-numericUpDown-数字选择---ShinePans
program.cs using System; using System.Collections.Generic; using System.Linq; using System.Windows.F ...
- 【SAE 部署 JavaWeb 项目报 404 错误】
个人学习整理,如有不足之处,请不吝不吝赐教.转载请注明:@CSU-Max 今天写了一个小的 JavaWeb 项目传到 SAE 上.訪问的时候出错. 本地測试是正常的,并且曾经做微信平台开发的时候上传的 ...
- UUID不失精度,长度改进
在使用到uuid的时候,往往头疼于它的长度(如1bfe50d8-544e-4e8a-95b8-199ceff15268),于是乎就有了改写uuid的各种方法 1.去除"-"的uui ...
- 判断navigation中父控制器类型
for (UIViewController *controller in self.navigationController.viewControllers) { if ([controller is ...
- 在jsp页面里面设置全局引用文件
head.jsp文件 将项目中所需要用到次数比较多的的插件,库等,同意放在一个jsp文件里面,命名为head.jsp文件,相当于一个全局的 <%@ page language="jav ...
- Java Math数字处理类与包装类习题
//创建Integer类对象,并以int型返回 Integer intAb = new Integer("123"); System.out.println(intAb.intVa ...
- python2代码转换python3(2018新)
Python 3自带了一个叫做2to3.py,这个脚本会将你的Python 2程序源文件作为输入,然后自动将其转换到Python 3的形式,可进行to3.py -w 文件夹路径 若文件名2to3-sc ...