centos6或centos7一键安装apache脚本练习

脚本练习

一键安装centos6或centos7 apache

vim   apacheinstall.sh

脚本内容如下:

#!/bin/bash
#
#********************************************************************
#Author: wangxiaochun
#QQ: 29308620
#Date: 2018-04-22
#FileName: apacheinstall.sh
#URL: http://www.magedu.com
#Description: The test script
#Copyright (C): 2018 All rights reserved
#********************************************************************
yum -y install httpd
yum -y groupinstall “Development tools”
sed ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config
OS=cat /etc/redhat-release |grep -o " [0-9]\+." |grep -o "[0-9]\+"
cd /root
[ -d “src” ] || mkdir src
cd src
if [ $OS -eq 6 ];
then
service iptables stop
chkconfig iptables off
service httpd start
wget http://archive.apache.org/dist/httpd/httpd-2.2.34.tar.gz
tar xvf httpd-2.2.34.tar.gz
cd httpd-2.2.34
./configure –prefix=/app –sysconfdir=/etc/httpd22
[ echo $? -eq 0 ] && make -j 4 && make install
[ echo $? -eq 0 ] && echo -e “\e[1;31mInstall success\e[0m” || echo -e “\e[1;31mInstall failed\e[0m”
echo “PATH=/app/bin:$PATH” >> /etc/profile.d/env.sh
apachectl start
elif [ $OS -eq 7 ];
then
systemctl stop firewalld
systemctl disable firewalld
systemctl start httpd
wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz
tar xvf httpd-2.4.25.tar.gz
cd httpd-2.4.25
./configure –prefix=/app –sysconfdir=/etc/httpd22
[ echo $? -eq 0 ] && make -j 4 && make install
[ echo $? -eq 0 ] && echo -e “\e[1;31mInstall success\e[0m” || echo -e “\e[1;31mInstall failed\e[0m”
echo “PATH=/app/bin:$PATH” >> /etc/profile.d/env.sh
apachectl start
else
exit
fi

脚本编好后上传到专用服务器 /var/www/html/ 目录下

需要安装脚本时用一下命令即可一键安装

curl http://testsrv(专用服务器IP地址)/install.sh |bash

 

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/96852

发表评论

登录后才能评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1823388528@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班