1. 程式人生 > >apache編譯安裝 httpd 2.2 httpd 2.4

apache編譯安裝 httpd 2.2 httpd 2.4

oca 2.3 出現 目錄 export sco kcon rpm ini

#apache編譯安裝
#httpd 2.2 , httpd 2.4

#!/bin/sh
#apache編譯安裝
#httpd 2.2 , httpd 2.4
#centos 

#rpm -e httpd*
Ve=2.2
[ $1 = 2.4 ] && Ve=2.4 || Ve=2.2 #設置安裝版本2.2或2.4

#目錄
Ddir=/it/tools  #定義下載目錄
Sdir=/www/server #定義安裝目錄
Adir=$Sdir/apache$Ve
[ ! -d $Ddir ]  && mkdir -p $Ddir
mkdir -p $Adir

echo
#安裝需要的庫 yum install make gcc gcc-c++ pcre pcre-devel zlib* -y yum install expat-devel -y #安裝apr-util需要 #yum install apr apr-util -y yum install wget lrzsz -y yum install openssl openssl-devel -y # echo #添加用戶 # useradd apache -s /sbin/nologin -M # id apache echo "#下載" cd $Ddir wget http://mirrors.aliyun.com/apache/apr/apr-1.6.2.tar.gz
wget http://mirrors.aliyun.com/apache/apr/apr-util-1.6.0.tar.gz wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz [ $Ve = 2.4 ] && { wget http://mirrors.aliyun.com/apache/httpd/httpd-2.4.27.tar.gz ; }|| { wget http://mirrors.aliyun.com/apache/httpd/httpd-2.2.34.tar.gz ; } echo "解壓" tar -xf apr-1
.*.tar.gz tar -xf apr-util-1.*.tar.gz tar -xf pcre-8.*.tar.gz tar -xf httpd-$Ve.*.tar.gz [ $? = 0 ] || { echo "解壓出現問題 !";exit; } echo "#安裝" mkdir -p $Sdir/http/{apr,apr-util,pcre} cd $Ddir #apr cd apr-1.* ./configure --prefix=$Sdir/http/apr/ [ $? = 0 ] || { echo "編譯出現問題 !";exit; } make && make install cd .. #apr-util cd apr-util-1.* ./configure --prefix=$Sdir/http/apr-util/ --with-apr=$Sdir/http/apr/ [ $? = 0 ] || { echo "編譯出現問題 !";exit; } make && make install cd .. #pcre cd pcre-8.* ./configure --prefix=$Sdir/http/pcre/ [ $? = 0 ] || { echo "編譯出現問題 !";exit; } make && make install cd .. #httpd cd $Ddir/httpd-$Ve.* #./configure --help ./configure --prefix=$Adir --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite --with-apr=$Sdir/http/apr/ --with-apr-util=$Sdir/http/apr-util/ --with-pcre=$Sdir/http/pcre/ ap_cv_void_ptr_lt_long=no # [ $? = 0 ] || { echo "編譯出現問題 !";exit; } echo 編譯安裝 make -j4 && make install echo #編譯模塊查看 $Adir/bin/apachectl -l pkill `netstat -antp|grep 80|awk -F / { print $2}` &>/dev/null #關閉80端口進程 echo "ServerName localhost:80">>$Adir/conf/httpd.conf echo #啟動apache $Adir/bin/apachectl start echo #查看 netstat -antp|grep httpd ps -ef|grep http|grep -v "grep" echo "$Adir/bin/apachectl { start|restart|stop }" # 加入系統服務,開機啟動 sed -i -e 2 i #chkconfig: 2345 70 60 \n#description: apache $Adir/bin/apachectl # ln -s $Adir/bin/apachectl /etc/init.d/httpd # echo "$Adir/bin/apachectl start">>/etc/rc.local # chkconfig --add httpd # chkconfig httpd on # chkconfig --list httpd # # #添加環境變量 # echo "export PATH=$Adir/bin:$PATH">>/etc/profile.d/httpd.sh # . /etc/profile.d/httpd.sh # #添加庫文件至系統 # echo "$Adir/include/">>/etc/ld.so.conf.d/httpd.conf # ldconfig # #man文檔添加至系統 # man -M $Adir/man httpd # echo "MANPATH $Adir/man">>/etc/man.config # #隱藏頭文件版本 # echo "#隱藏頭文件版本 # ServerTokens ProductOnly # ServerSignature Off # ">>$Adir/conf/httpd.conf #php 測試 echo <?php phpinfo(); ?>>$Adir/htdocs/test.php # other #--sysconfdir=/etc/httpd #Apache配置php #php編譯時,需要有參數--with-apxs2=/apache安裝目錄/bin/apxs \ #php編譯完成後,apache配置文件裏會自動添加php模塊LoadModule php5_module module/libphp5.so #echo "Addtype application/x-httpd-php .php .phtml">>$Adir/conf/httpd.conf #開啟php支持 #另一種方式,使用fcgi接口方式,傳遞php給獨立php進程解析,配置略

apache編譯安裝 httpd 2.2 httpd 2.4