CentOS 6 apache源碼編譯一鍵部署指令碼

來源:互聯網
上載者:User

標籤:apache源碼編譯指令碼

需求:源碼編譯apache

環境:CentOS 6 64位系統安裝的案頭版

軟體:httpd-2.4.12.tar.gz、pcre-8.31.tar.bz2、apr-util-1.5.3、apr-1.5.1.tar.gz

備忘:目前只在centos 6環境下測試過,如果有報錯可能是依賴包安裝有缺失,本來想把這幾個源碼包上傳上去的,上傳一直失敗,以上幾個源碼包需要到網上下載一下


[[email protected] ~]# cat apache.sh 

#!/bin/bash

#

#適用版本CentOS 6 64位

#2017.5.11

. /etc/init.d/functions

dir=/root/test

del_dir() {

read -p "需要刪除${dir} 是否刪除[Y|y/N|n]:" del

case $del in

Y|y)

rm -rf $dir

mkdir $dir

cd $dir

;;

N|n)

echo "安裝終止"

exit 7

;;

*)

echo "請輸入正確的值"

exit 8

;;

esac

}

[ ! -d $dir ] && {

mkdir $dir

cd $dir

} || del_dir

yum -y install gcc gcc-c++ cmake ncurses-devel bison ncurses

sleep 2 

echo "##################################下載依賴包###################################"

wget http://172.2.0.68/apr-1.5.1.tar.gz

wget http://172.2.0.68/apr-util-1.5.3.tar.gz

wget http://172.2.0.68/pcre-8.31.tar.bz2

wget http://172.2.0.68/httpd-2.4.12.tar.gz

#wget http://172.2.0.68/configure.txt

[ $? -eq 0 ] && echo "下載apr依賴包,準備安裝" || exit 7

sleep 5

tar -xzvf apr-1.5.1.tar.gz

tar -xzvf apr-util-1.5.3.tar.gz

sleep 3

cd apr-1.5.1

[ $? -eq 0 ] && {

./configure --prefix=/usr/local/apr

} || {

echo "解壓包出錯"

exit 9

}

echo "####################準備編譯##################"

sleep 3

make && make install

cd ..

[ $? -eq 0 ] && cd apr-util-1.5.3 || exit 5

./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr

echo "####################準備編譯##################"

make && make install

cd ..

echo "###########安裝pcre######################"

sleep 4

tar -jxvf pcre-8.31.tar.bz2

[ $? -eq 0 ] && cd pcre-8.31 || exit 6

./configure --prefix=/usr/local/pcre

make && make install

echo "###########安裝apache###############"

cd ..

groupadd www

useradd -M -g www -s /sbin/nologin www

tar -xzvf httpd-2.4.12.tar.gz

[ $? -eq 0 ] && cd httpd-2.4.12 || exit 3

echo "##################編譯apache##################"

#configure

./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-expires --enable-headers --enable-modules=most --with-mpm=worker --enable-ssl --enable-rewite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

[ $? -eq 0 ] && echo "編譯apache成功" || {

echo "編譯apache失敗"

exit 5

}

echo "###################安裝Apache##############################"

sleep 2

make && make install 

[ $? -eq 0 ] && echo "##################apache安裝成功#######" || {

echo "apache安裝失敗"

exit 7

}

sleep 2

##apache服務啟動指令碼

cp build/rpm/httpd.init /etc/init.d/httpd

chmod 700 /etc/init.d/httpd

sed -i ‘s/HTTPD-\/usr\/sbin\/httpd/HTTPD-\/usr\/local\/apache\/bin\/httpd/g‘ /etc/init.d/httpd

sed -i ‘s/PIDFILE-\/var\/run/PIDFILE-\/usr\/local\/apache\/logs/g‘ /etc/init.d/httpd

sed -i ‘s/CONFFILE=\/etc\/httpd\/conf\/httpd.conf/CONFFILE=\/usr\/local\/apache\/conf\/httpd.conf/g‘ /etc/init.d/httpd

[ $? -eq 0 ] && echo "#########繼續############" || exit 5

chkconfig --add httpd

[ $? -eq 0 ] && echo "###########添加httpd啟動項成功########" || echo "###################添加httpd啟動項失敗############"

chkconfig --level 35 httpd on


本文出自 “常想一二” 部落格,請務必保留此出處http://250919938.blog.51cto.com/962010/1924392

CentOS 6 apache源碼編譯一鍵部署指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.