Compile and install Apache

Source: Internet
Author: User
Tags openldap fully qualified domain name


First, compile and install apache2.4

1, download the required software source package, using the wget command to download:

Apr-1.5.1:wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.1.tar.bz2

Apr-util-1.5.3:wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.3.tar.bz2

Httpd-2.4.10:wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.10.tar.bz2

2. Solve the dependency relationship

(1) Some dependent libraries required to install the system using Yum

Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs e2fsprogs-devel kr B5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel nss_ldap openldap-clients Openldap-servers Pcre Pcre-devel


(2) Compile and install Apr first

Tar jxf apr-1.5.1.tar.bz2

CD apr-1.5.1

./configure--PREFIX=/USR/LOCAL/APR

Make && make install


(3) Re-compile and install Apr-util

Tar jxf apr-util-1.5.3.tar.bz2

CD apr-util-1.5.3

./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr # (Note:--WITH-APR=/USR/LOCAL/APR is the path to install Apr above)

Make && make install


3, formally compiled and installed httpd

Tar jxf httpd-2.4.10.tar.bz2

CD httpd-2.4.10

./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd--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-mods-shared=most--enable-mpms-shared=all--with-mpm=event

Make && make install


4, Configuration httpd

(1) Provide SYSV service startup and shutdown scripts for httpd, copy the following to/ETC/INIT.D/HTTPD, and give this file Execute permission (chmod +x/etc/rc.d/init.d/httpd), you can use the service directly httpd command-form control HTTPD Services:

#!/bin/bash

#

# httpd Startup script for the Apache HTTP Server

#

# Chkconfig:-85 15

# Description:apache is a world Wide Web server. It's used to serve \

# HTML files and CGI.

# PROCESSNAME:HTTPD

# config:/etc/httpd/conf/httpd.conf

# config:/etc/sysconfig/httpd

# Pidfile:/var/run/httpd.pid

# Source function library.

. /etc/rc.d/init.d/functions

if [-F/ETC/SYSCONFIG/HTTPD]; Then

. /etc/sysconfig/httpd

Fi

# Start httpd in the C locale by default.

httpd_lang=${httpd_lang-"C"}

# This would 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 this some modules may not

# work correctly with a thread-based MPM; Notably PHP would refuse to start.

# Path to the Apachectl script, server binary, and short-form for messages.

Apachectl=/usr/local/apache/bin/apachectl

HTTPD=${HTTPD-/USR/LOCAL/APACHE/BIN/HTTPD}

Prog=httpd

Pidfile=${pidfile-/var/run/httpd.pid}

LOCKFILE=${LOCKFILE-/VAR/LOCK/SUBSYS/HTTPD}

Retval=0

Start () {

Echo-n $ "Starting $prog:"

lang= $HTTPD _lang Daemon--pidfile=${pidfile} $httpd $OPTIONS

Retval=$?

Echo

[$RETVAL = 0] && Touch ${lockfile}

Return $RETVAL

}

Stop () {

Echo-n $ "Stopping $prog:"

Killproc-p ${pidfile}-D $httpd

Retval=$?

Echo

[$RETVAL = 0] && rm-f ${lockfile} ${pidfile}

}

Reload () {

Echo-n $ "Reloading $prog:"

if! lang= $HTTPD _lang $httpd $OPTIONS-T >&/dev/null; Then

Retval=$?

echo $ "not reloading due to configuration syntax error"

Failure $ "not reloading $HTTPD due to configuration syntax error"

Else

Killproc-p ${pidfile} $httpd-hup

Retval=$?

Fi

Echo

}


# See how we were called.

Case "$" in

Start

Start

;;

Stop

Stop

;;

Status

Status-p ${pidfile} $httpd

Retval=$?

;;

Restart

Stop

Start

;;

Condrestart)

If [-f ${pidfile}]; Then

Stop

Start

Fi

;;

Reload

Reload

;;

Graceful|help|configtest|fullstatus)

$apachectl [email protected]

Retval=$?

;;

*)

echo $ "Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"

Exit 1

Esac

Exit $RETVAL

(2) Add the HTTPD service as the boot-up self-boot:

Chkconfig--add httpd

Chkconfig httpd on

(3) Modify the httpd Master Profile/etc/httpd/httpd.conf, specify the PID file of the httpd service, add the following fields directly in the configuration file:

Pidfile "/var/run/httpd.pid"


(4) Start the HTTPD service and conduct an access test

Service httpd Start

(Note: This warning appears if you start: Httpd:apr_sockaddr_info_get () failed for Longren

Httpd:could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName, workaround: In/etc/ht tpd/httpd.conf add servername 127.0.0.1)

Access testing: http://your_ipadress, if it Works, proves that the HTTPD compilation installation was successful.


This article from "Bobcat" blog, declined reprint!

Compile and install Apache

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.