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.www58058.com/96852

(2)
ponypony
上一篇 2018-04-22 18:46
下一篇 2018-04-22 19:29

相關推薦

  • 編譯安裝LAMP示例

    httpd 2.4.9 + mysql-5.5.33 + php-5.4.26編譯安裝過程: 一、編譯安裝apache 1、解決依賴關系 httpd-2.4.9需要較新版本的apr和apr-util,因此需要事先對其進行升級。升級方式有兩種,一種是通過源代碼編譯安裝,一種是直接升級rpm包。這里選擇使用編譯源代碼的方式進行,它們的下載路徑為ftp://172…

    Linux筆記 2018-05-29
  • 用 percona-xtrabackup 實現備份實例

    安裝2.4.11版本的percona wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.11/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.11-1.el7.x86_64.rpm 下載新版的percona 看下后…

    Linux筆記 2018-06-14
  • Linux用戶組管理及用戶權限

    1、列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登錄多次,則只顯示一次即可。 ]# who | cut -d” ” -f1 | sort -u 2、取出最后登錄到當前系統的用戶的相關信息。 ]# last | head -1? 3、取出當前系統上被用戶當作其默認shell的最多的那個shell。 ]# cat /etc/…

    2018-07-05
  • liunx 基礎

    時間和日期:

    Linux筆記 2018-04-01
  • shell腳本編程

    shell腳本基礎篇——簡單介紹腳本的書寫規范

    2018-04-12
  • 學習筆記(4)

    學習筆記(4)

    Linux筆記 2018-04-22
欧美性久久久久