Compile and install Apache

Source: Internet
Author: User

1. Install the Dependent Library: "Development Tools" "Server Platform Development" Pcre-devel

2. Installing Apr,apr-util

Download the installation package from the Yum source installation or go to Apr website, which is compiled and installed.

Install Apr:

CD Apr

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

Install Apr-util:

CD Apr-util

./configure--prefilx=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR

3. Installing Apache

./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd--with-apr=/usr/local/apr--with-apr-util=/usr/ Local/apr-util--enable-ssl--enable-so--enable-rewrite--enable-zlib--enable-pcre--enable-cache-- Enable-cache-disk--enable-proxy--enable-proxy-fcgi--enable-cgi--enable-modules=most--enable-mpms-shared=all-- With-mpm=prefork

4. Modify the httpd Master profile to set the path of its PID file

Add the following line to the httpd.conf file:

Pidfile "/var/run/httpd.pid"

5. Add Environment variables

vim/etc/profile.d/httpd.sh

Export Path=/usr/loca/apache/bin: $PATH

6.

Provides the SYSV service script/etc/rc.d/init.d/httpd, as follows:

#!/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:"
I F! lang= $HTTPD _lang $httpd $OPTIONS-T >&/dev/null; Then
retval=$?
Echo $ ' not reloading due to configuration syntax error '
Failure $ ' not reloading $httpd due to C onfiguration 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

Then give execute permission for this script:
# chmod +X/ETC/RC.D/INIT.D/HTTPD

Join the Service list:
# chkconfig--add httpd

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.