一键安装centos6或centos7 apache《转载》

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

原文地址:http://www.178linux.com/96852

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

(1)
上一篇 2018-04-22 20:31
下一篇 2018-04-22 20:40

相关推荐