Compiling and installing Apache 2.4.12

Source: Internet
Author: User

First, the environment

System: CentOS 6.4x64 Minimized installation

ip:192.168.3.54


Second, download the package

Apache official website www.apache.org to provide the source download

[Email protected] ~]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.12.tar.gz

Third, installation

Unzip and install

[[email protected] ~]# tar xf httpd-2.4.12.tar.gz [[email protected] ~ ]# cd httpd-2.4.12[[email protected] httpd-2.4.12]# ./configure > -- prefix=/usr/local/apache-2.4.12 > --enable-deflate \              #压缩 > --enable-expires \              #缓存 > --enable-headers > --enable-modules=most  > --enable-so > --with-mpm=worker \              #worker模型 > --enable-rewrite \               #rewrite重写规则 > --with-apr=/usr/local/apr > -- with-apr-util=/usr/local/apr-util> --enable-ssl                      #支持sslchecking  for chosen layout... apachechecking for  working mkdir -p... yeschecking for grep that handles long  lines and -e... /bin/grepchecking for egrep... /bin/grep -echecking  build system type... x86_64-unknown-linux-gnuchecking host system type...  X86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuconfigure:  configure: Configuring Apache Portable Runtime library...configure:  Checking for apr... noconfigure: error: apr not found.  please  read the documentation. #结果显示我们需要安装apr  apr-util,pcre-devel,openssl-devel# Download Apr and apr-util[[ email protected] ~]# wget [[email protected] ~]# wget http:// mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz  #先安装pcre-devel,apr[[email protected] httpd-2.4.12]# yum install  pcre-devel  openssl-devel -y[[email protected] ~]# tar xf  apr-1.5.2.tar.gz [[email protected] ~]# cd apr-1.5.2[[email protected]  Apr-1.5.2]# ./configure --prefix=/usr/local/apr[[email protected] apr-1.5.2]# make  && make install# installation apr-util[[email protected] ~]# tar xf  Apr-util-1.5.4.tar.gz [[email protected] ~]# cd apr-util-1.5.4[[email protected]  apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr[[ email protected] apr-util-1.5.4]# make && make install# Install Httpd[[email again  protected] httpd-2.4.12]# ./configure --prefix=/usr/local/apache-2.4.12 -- enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite - -enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util[[email protected]  httpd-2.4.12]# make && make install

After the installation is complete, create a soft connection for easy management

[Email protected] ~]# ln-s/usr/local/apache-2.4.12//usr/local/apache

Create the httpd startup script file, httpd the startup script to copy/usr/local/apache/bin/apachectl to the/ETC/INIT.D directory. Here we choose to manually create a startup script file

[[email protected] ~]# vim /etc/init.d/httpd#!/bin/bash## startup script  For the apache web server## chkconfig: - 85 15# description:  apache is a world wide web server.  it is used to  serve #              html  files and cgi.# processname: httpd# pidfile: /usr/local/apache2/logs/ Httpd.pid# config: /usr/local/apache2/conf/httpd.conf# source function library.  /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then         . /etc/sysconfig/httpdfi# This will prevent  Initlog from swallowing up a pass-phrase prompt if# mod_ssl needs  a pass-phrase from tHe user. Initlog_args= "" # path to the apachectl script, server binary, and  short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=/usr/local/apache/bin/ Httpdpid= $httpd/logs/httpd.pidprog=httpdretval=0# 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:           daemon  $httpd   $OPTIONS          retval=$?        echo        [ $ retval = 0 ] && touch /var/lock/subsys/httpd         return  $RETVAL}stop ()  {        echo  -n $ "stopping  $prog: "         killproc $ httpd        retval=$?         echo        [  $RETVAL  = 0 ] &&  rm -f /var/lock/subsys/httpd  $pid}reload ()  {         echo -n $ "reloading  $prog: "         killproc   $HTTPD  -HUP        RETVAL=$?         echo}#&nbsp see how we were called.case  "$"  in  start)          start        ;;   stop)         stop         ;;   status)         status  $httpd          RETVAL=$?        ;;   restart)         stop         start        ;;   condrestart)         if [ -f  $pid  ]  ; then                 stop                start        fi        ;;   reload)         reload         ;;   graceful|help|configtest|fullstatus)          $apachectl  [email protected]        RETVAL=$?         ;;   *)         echo $ "usage:  $prog  {start|stop| Restart|condrestart|reload|status "        echo $" |fullstatus| Graceful|help|configtest} "        exit 1esacexit  $RETVAL # Start httpd Service [email protected] ~]# /etc/init.d/httpd startstarting httpd: ah00557:  httpd: apr_sockaddr_info_get ()  failed for httpdah00558: httpd: could&Nbsp;not reliably determine the server ' S fully qualified domain name,  using 127.0.0.1. Set the  ' ServerName '  directive globally to  suppress this message                                                              [  OK  ]                                                               #提示有FQDN错误, resolved as follows [[EMAIL&Nbsp;protected] ~]# echo  "servername localhost:80"  >>/usr/local/apache/conf/ httpd.conf# Restart the httpd service [[EMAIL PROTECTED] ~]# /ETC/INIT.D/HTTPD STOPSTOPPING HTTPD:                                               [  ok  ][[email protected] ~]#  /etc/init.d/httpd startStarting httpd:                                              [   OK  ][[email protected] ~]# netstat -anpt |grep httpdtcp         0      0 :::80                        :::*                           listen      59398/httpd

Accessing the HTTPD service on the client

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/67/wKiom1VIfUyxuOYrAAByd8Ykg0Q394.jpg "title=" 1.JPG " alt= "Wkiom1vifuyxuoyraabyd8ykg0q394.jpg"/>


With the above steps, Apache has been successfully installed, the service starts normally, and finally the HTTPD service is added to boot automatically

[[email protected] ~]# chkconfig--add httpd[[email protected] ~]# chkconfig httpd on[[email protected] ~]# chkconfig |gre P HTTPHTTPD 0:off1:off2:on3:on4:on5:on6:off


This article is from the "ly36843" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1642118

Compiling and installing Apache 2.4.12

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.