一鍵安裝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.www58058.com/96852