Apache Compilation Installation httpd 2.2 httpd 2.4

Source: Internet
Author: User
Tags aliyun

#apache编译安装
#httpd 2.2, httpd 2.4

#!/bin/SH#apache编译安装 #httpd2.2, httpd2.4#centos #rpm-E httpd*Ve=2.2[ $1=2.4] && ve=2.4|| Ve=2.2#设置安装版本2.2 or 2.4#目录Ddir=/it/Tools #定义下载目录Sdir=/www/Server #定义安装目录Adir= $Sdir/apache$ve[! -D $Ddir] &&mkdir-P $Ddirmkdir-P $AdirEcho '#安装需要的库'Yum Install  Make GCC GCC-c++ pcre Pcre-devel zlib*-yYum InstallExpat-devel-y #安装apr-Util need #Yum InstallApr Apr-util-yYum Install wgetLrzsz-yYum InstallOpenSSL Openssl-devel-y #Echo '#添加用户'# Useradd Apache-s/sbin/nologin-M #IDApacheEcho "#下载"CD $Ddirwgethttp//mirrors.aliyun.com/apache/apr/apr-1.6.2.tar.gzwgethttp//mirrors.aliyun.com/apache/apr/apr-util-1.6.0.tar.gzwgetHttps//ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz[$Ve =2.4] && {     wgethttp//mirrors.aliyun.com/apache/httpd/httpd-2.4.27.tar.gz;}|| {     wgethttp//mirrors.aliyun.com/apache/httpd/httpd-2.2.34.tar.gz;    }Echo "Unzip"Tar-XF apr-1.*.Tar. GZTar-XF apr-util-1.*.Tar. GZTar-XF pcre-8.*.Tar. GZTar-XF httpd-$Ve. *.Tar. gz[$? =0] || {Echo "problem with decompression! "; exit;}Echo "#安装"mkdir-P $Sdir/http/{apr,apr-util,pcre}cd $Ddir #aprcd Apr-1.*./configure--prefix= $Sdir/http/apr/[ $? =0] || {Echo "Problem compiling! "; exit;} Make&& Make InstallCD.. #apr-UTILCD Apr-util-1.*./configure--prefix= $Sdir/http/apr-util/--with-apr= $Sdir/http/apr/[ $? =0] || {Echo "Problem compiling! "; exit;} Make&& Make InstallCD.. #pcrecd Pcre-8.*./configure--prefix= $Sdir/http/pcre/[ $? =0] || {Echo "Problem compiling! "; exit;} Make&& Make InstallCD.. #httpdcd $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 "Problem compiling! "; exit;}EchoCompiling the installation Make-j4 && Make InstallEcho '#编译模块查看'$Adir/bin/apachectl-l Pkill ' netstat-antp|grep  the|awk-F'/' '{print $}'' &>/dev/NULL#关闭80端口进程Echo "ServerName localhost:80">> $Adir/conf/httpd.confEcho '#启动apache'$Adir/bin/apachectl StartEcho '#查看'netstat-antp|grephttpdPS-ef|grephttp|grep-V"grep"Echo "$Adir/bin/apachectl {start|restart|stop}"# Join system service, boot upsed-i-e'2 I #chkconfig: 2345 \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文档添加至系统 #Mans-M $Adir/Manshttpd#Echo "MANPATH $Adir/man">>/etc/Mans. config# #隐藏头文件版本 #Echo "#隐藏头文件版本# servertokens productonly# serversignature off#">> $Adir/conf/httpd.conf#php TestEcho '<?php phpinfo ();?>'> $Adir/htdocs/test.php# other#--sysconfdir=/etc/httpd #Apache配置php #php Compile, parameters are required--with-apxs2=/apache installation directory/bin/apxs \ #php编译完成后, the PHP module is automatically added to the Apache configuration file loadmodule php5_module module/libphp5.so#Echo "addtype application/x-httpd-php. php. phtml">> $Adir/conf/httpd.conf #开启php支持 # Another way, using the Fcgi interface method, passing PHP to the independent PHP process parsing, configuration slightly

Apache Compilation Installation httpd 2.2 httpd 2.4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.