httpd-2.4 requires a newer version of APR and Apr-util, so it needs to be upgraded beforehand. There are two ways to upgrade, one is to compile the installation through source code, and the other is to upgrade the RPM package directly.
Here you choose to use the source code to compile the way
1. Solve the dependency relationship
Yumgroupinstall-y "Development Tools" "Server platformdevelopment"
Yuminstall-y Pcre-devel
Download package
apr-1.5.0.tar.bz2
apr-util-1.5.3.tar.bz2
httpd-2.4.25.tar.bz2
(1) Compile and install Apr
Compiling the installation Apr
Unzip and enter the directory
./configure--PREFIX=/USR/LOCAL/APR
Make && make install
(2) Compile and install Apr-util
Unzip into the directory
./configure--prefix=/usr/local/apr-util--with-apr=/usr/lo CA L/APR need to specify Apr Path
(3) Compile and install httpd2.4
./configure--prefix=/usr/local/apache--sysconfdir=/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=event
Make && make install
Add:
(1) Constructing MPM as static module
In all platforms, MPM can be built as a static module. Select a mpm at build time, linked to the server. If you want to change MPM, you must rebuild it. In order to use the specified MPM, use the parameter--with-mpm=name when executing the Configure script.
Name is the specified MPM name. After the compilation is complete, you can use./httpd-l to determine the selected MPM. This command lists all modules that are compiled into the server program, including MPM.
(2) Build MPM as dynamic module
In UNIX or similar platforms, MPM can be built as a dynamic module and loaded at run time as with other dynamic modules. Building MPM as a dynamic module allows you to change the MPM by modifying the contents of the LoadModule directive without rebuilding the server program.
Use the--enable-mpms-shared option to enable this feature when you execute a configure script. All MPM modules supported by this platform will be installed when the given parameter is all.
You can also give a list of modules in the parameters. The default MPM, which can be automatically selected or specified by the--WITH-MPM option when the Configure script is executed, then appears in the generated server configuration file. Edit the loadmodule instruction content to select a different mpm.
3. Modify the main configuration file of httpd and set the path of its PID file.
To edit the/etc/httpd/httpd.conf, add the following line:
Pidfile "/var/run/httpd.pid"
4, provide SYSV service script/etc/rc.d/init.d/httpd, the content is as follows:
#!/bin/bash
#
# httpd Startup script for the Apache httpserver
#
# Chkconfig:-85 15
# Description:apacheis A World Wide Web server. It is usedto serve \
# HTML files and CGI.
# PROCESSNAME:HTTPD
# config:/etc/httpd/conf/httpd.conf
# CONFIG:/ETC/SYSCONFIG/HTTPD
# Pidfile:/var/run/httpd.pid
# Source Functionlibrary.
./etc/rc.d/init.d/functions
if [-F/ETC/SYSCONFIG/HTTPD]; Then
. /etc/sysconfig/httpd
Fi
# Start httpd in the Clocale by default.
httpd_lang=${httpd_lang-"C"}
# This would preventinitlog from swallowing up a pass-phrase prompt if
# Mod_ssl needs apass-phrase from the user.
Initlog_args= ""
# Sethttpd=/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 athread-based MPM; Notably PHP would refuse to start.
# Path to the Apachectlscript, 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 toconfiguration syntax error"
Failure $ "Not reloading $httpd dueto configuration Syntax error"
Else
Killproc-p ${pidfile} $httpd-hup
Retval=$?
Fi
Echo
}
# See how we werecalled.
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
The next step is to start the service and test it.
[[email protected]Linux bin] #service httpd restart
AH00557:httpd:apr_sockaddr_info_get () failed for Linux . 64.114
AH00558:httpd:Could not reliably determine the server ' s fully qualified domain
Name, using127.0.0.1. Set the ' ServerName ' directive globally to suppress this
Message
Workaround
[Email protected]httpd24]# pwd
/etc/httpd24
[Email protected]httpd24]# vim httpd.conf
Modify ServerName www.example.com:80 to servernamelocalhost:80
3 , continue to execute checking whether to enable Mod_ssl ... Configure:error:mod_ssl have been requested but can not is built due to Prerequi Site Failures, which is due to the lack of OpenSSL
[[email protected] httpd-2.4.18] #yum install Openssl-devel
4 , the last error that appears is Configure:error:MPM Most does isn't support dynamicloading.
You can literally understand that this will --enbale-mpm-shared instead All can be
Compiling and installing httpd2.4