CentOS6 on the build installation httpd2.4

Source: Internet
Author: User

It is not possible to install httpd2.4 directly using the RPM package on CentOS6 because httpd2.4 depends on:

Version apr-1.4 and above

Version apr-util-1.4 and above

While directly upgrading APR and Apr-util will overwrite the direct version of the program, affecting the dependencies of other programs, it is common to install APR and Apr-util in a compiled installation, and then compile and install httpd2.4.


The steps are as follows:

1. Prepare the installation environment and source package

[[Email protected] ~] # yum Groupinstall "Development Tools" "Server Platform Development"-y[[email protected] ~] # Yum I Nstall pcre-devel-y

Download the source package, here I use:

apr-1.5.0.tar.bz2

apr-util-1.5.3.tar.bz2

httpd.2.4.9.tar.bz2

2. Compile and install Apr and Apr-util

[[Email protected] ~] # tar XF apr-1.5.0.tar.bz2[[email protected] ~] # CD Apr-1.5.0[[email protected] apr-1.5.0] #./con Figure--PREFIX=/USR/LOCAL/APR//To avoid affecting the original version APR, install the new version Apr to the new directory/usr/local/apr,--prefix option for the specified installation directory [[email protected] apr-1.5.0] # make && make Install[[email protected] ~] # tar XF apr-util-1.5.3.tar.bz2[[email protected] ~] # CD Apr-util-1.5.3[[email protected] apr-util-1.5.3] #./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/ apr//also installs apr-util to the new directory,--WITH-APR specifies the APR directory [[email protected] apr-util-1.5.3] # make && make install

3. Compile and install httpd2.4

[[email protected] ~] # tar xf httpd-2.4.9.tar.bz2[[email protected] ~ ] # cd httpd-2.4.9[[email protected] httpd-2.4.9 ] # ./configure  --prefix=/usr/local/apache --sysconf=/etc/httpd24 --enable-so --enable-ssl --enable-cgi  --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/ usr/local/apr-util --enable-modules=most --enable-mpms-shared =all --with-mpm=prefork//  --PREFIX=/USR/LOCAL/APACHE&NBSP: Installation location// -sysconf=/etc/httpd24 : Configuration file Location// --enable-so  : Support the DSO dynamic loading module// --ENABLE-SSL : SSL/TLS support, HTTPS protocol access, installation required openssl-devel// --enable-cgi  : Support CGI script// --enable-rewrite : support URL rewriting// --with-zlib : Using the specified zlib compression library, do not specify the path automatically find// -- WITH-PCRE : Enhanced regular expression analysis tool using the specified pcre library; Do not specify that the path will be automatically searched and need to be installed pcre-devel// --with-apr=/usr/local/apr  : Specifies the dependent APR program installation location// --with-apR-UTIL=/USR/LOCAL/APR-UTIL&NBSP: Specifies the dependent apr-util program installation location// --ENABLE-MODULES=MOST : Support dynamic Enable module: all: All ; most: Common// --enable-mpms-shared=all : Compiled and shared module// --with-mpm=event : MPM module enabled by default; option available prefork| worker|event[[email protected] httpd-2.4.9 ] # make && make  Install

4. Post-installation configuration

(1) Add environment variables and reread the file

Because it is a compile-and-install HTTPD, the PATH environment variable does not have the directory we have installed and needs to be manually added

[[Email protected] ~] # vim/etc/profile.d/httpd24.shexport Path=/usr/local/apache/bin: $PATH [[email protected] ~] # source/etc/profile.d/httpd24.sh

When the httpd command is executed, it can be used normally, if not added to the environment variable, it is inconvenient to use under absolute path.

(2) Export header file

[[Email protected] ~] # LN-SV/USR/LOCAL/APACHE/INCLUDE/USR/INCLUDE/HTTPD

No need to copy, create a soft link to

(3) Export Man Handbook

[[Email protected] ~] # VIM/ETC/MAN.CONFG

(4) Writing service scripts

[[email protected] ~]# vim /etc/rc.d/init.d/httpd#!/bin/bash## httpd         startup script for the apache http server##  chkconfig: - 85 15# description: the apache http server is  an efficient and extensible  #       server  implementing the current http standards.# processname: httpd# config:  /etc/httpd/conf/httpd.conf# config: /etc/sysconfig/httpd# pidfile: /var/run/httpd/ httpd.pid#### begin init info# provides: httpd# required-start:  $local _fs   $remote _fs  $network   $named # required-stop:  $local _fs  $remote _fs  $network #  Should-Start: distcache# Short-Description: start and stop Apache  Http server# description: the apache http server is an extensible server #   implementing the current HTTP standards.### END INIT INFO#  Source function library.  /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then         . /etc/sysconfig/httpdfi# start httpd in the  c locale by default. httpd_lang=${httpd_lang-"C"}# this will prevent initlog from swallowing up  a pass-phrase prompt if# mod_ssl needs a pass-phrase from  The user. Initlog_args= "" # set httpd=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use  a server# with the thread-based  "Worker"  MPM; BE WARNED  that some modules may not#  work correctly with a thread-based mpm; notably php will refuse  to start.# path to the apachectl script, server binary, and  short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=${httpd-/usr/sbin/httpd }prog=httpdpidfile=${pidfile-/var/run/httpd/httpd24.pid}lockfile=${lockfile-/var/lock/subsys/httpd24}retval= 0stop_timeout=${stop_timeout-10}# the semantics of these two functions  differ from the way apachectl does# things -- attempting to  start while running is a failure, and shutdown# when not  running is also a failure.  so we just do it the  Way init scripts# are expected to behave here.start ()  {         echo -n $ "starting  $prog: "          lang= $HTTPD _lang daemon --pidfile=${pidfile}  $httpd   $OPTIONS          RETVAL=$?        echo         [  $RETVAL  = 0 ] && touch ${lockfile}         return  $RETVAL}# when stopping httpd, a  delay  (Of default 10 second)  is required# before sigkilling the  httpd parent; this gives enough time for the# httpd parent  to sigkill any errant children.stop ()  {status -p ${pidfile} $ httpd > /dev/nullif [[ $? = 0 ]]; thenecho -n $ "Stopping   $prog:  "Killproc -p ${pidfile} -d ${stop_timeout}  $httpdelseecho  -n $ "Stopping  $prog:   "successfiretval=$?echo[  $RETVAL  = 0 ] && rm -f ${ Lockfile} ${pidfile}}reload ()  {    echo -n $ "Reloading  $prog:   "    if ! lang= $HTTPD _lang  $httpd   $OPTIONS  -t > &/dev/null; then        RETVAL=6         echo $ "not reloading due to configuration syntax  Error "        failure $" not reloading  $httpd  due  to configuration syntax error "    else         # Force LSB behaviour from killproc         lsb=1 killproc -p ${pidfile}  $httpd  -HUP        RETVAL=$?         if [  $RETVAL  -eq 7 ]; then             failure $ "Httpd shutdown"          fi    fi    echo}# See  how we were called.case  "$"  in  start) start;   stop) stop;;   status)         status -p ${pidfile} $ Httpdretval=$?;;   restart) Stopstart;;   condrestart|try-restart) if status -p ${pidfile}  $httpd  >&/dev/null ; thenstopstartfi;;   force-reload|reload)         reload;;   graceful|help|configtest|fullstatus) $apachectl  [email protected]rEtval=$?;;   *) echo $ "usage:  $prog  {start|stop|restart|condrestart|try-restart|force-reload| Reload|status|fullstatus|graceful|help|configtest} "retval=2esacexit  $RETVA

After you have written the service script, you need to set the service script to boot

[[email protected] ~]# chkconfig--add httpd[[email protected] ~]# chkconfig httpd on




Write the more scribbled, if there are missing errors and controversies, welcome everyone's criticism and discussion, thank you.

CentOS6 on the build installation httpd2.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.