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 ...
随机推荐
- 一个自己主动依据xcode中的objective-c代码生成类关系图的神器
https://github.com/kimsungwhee/KSHObjcUML 安装方法: 1.下载项目 2.执行 3.会又一次开启一个新的xcode 4.选择一个项目,点击 Objc-UML 会 ...
- Android中常用的优秀开源框架
Android开源框架库分类,挑选出最常用,最实用的开源项目,本篇主要介绍的是优秀开源框架库和项目,UI个性化控件会独立介绍.UI个性化控件 Index Dependency Injections A ...
- Linux下图形界面调试工具kdbg安装及測试
1.Ubuntu系统下安装 Ubuntu系统安装比較方便,直接apt-get即可 apt-get install kdbg 2.centos 安装 首先,在这个地址下下载rpm包.然后使用rpm命令安 ...
- nodejs版本号更新问题:express不是内部或外部命令
版本号更新后,我们使用熟悉的npm install -g express命令安装,可是,成功安装之后竟然提示express不是内部或外部命令. nodejs小问题:[1]express不是内部或外部命 ...
- [Angular] Dynamic components with ComponentFactoryResolver
To create a component dynamicly. 1. Add a container with ref: @Component({ selector: 'app-root', tem ...
- [Redux] Important things in Redux
Root Smart component can be overloaded, divide 'smart' component wisely & using Provider. Proble ...
- 【BZOJ 1011】[HNOI2008]遥远的行星
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1011 [题意] [题解] 这里的答案误差不超过5%是突破点; 如果是直接暴力写; 复杂 ...
- 选iphone5可以正常编译运行 , 但是5s和6和6s都会编译报错
选iphone5可以正常编译运行 但是5s和6和6s都会编译报错 iphone6编译报错iphone5s编译报错 解决办法是,Build settings里面把Architectures里面的$( ...
- centos安装启动ssh服务
centos安装启动ssh服务 #rpm -qa |grep ssh 检查是否装了SSH包 没有的话yum install openssh-server #chkconfig --list sshd ...
- 【BZOJ 1026】 [SCOI2009]windy数
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1026 [题意] [题解] 数位Dp 设f[i][j]表示长度为i,第一位(也就是最高位 ...