httpd source installation

# HTTPD Detailed steps to compile and install
httpd part of the Apache Software Foundation, the organization, the official website address: https://www.apache.org
.
Installation HTTPD need to resolve its dependencies, install gcc, pcre, expat, apr, apr-util.
gcc, pcre, expat can be installed using yum:
yum -y install gcc * PCRE-devel expat-devel
.
arp and arp-util is a shared library, the httpd his function without considering the different underlying operating system, you can easy to transplant.
.
Arp use the compiler installation
link: http://apr.apache.org/download.cgi/arp-1.7.0.tar.gz
we will arp and arp-util downloaded to / usr / local / src / directory, use Source package installation during installation.
XF ARP-1.7.0.tar.gz the tar
CD On Apr-1.7.0
./configure --prefix = / usr / local / On Apr # Note: You can use other parameters ./configuer -help view, where no explanation;
the make the make install &&
.
apr-util source code is installed with the way
links: http://apr.apache.org/download.cgi/arp-util-1.6.1.tar.gz
On Apr-XF-util the tar 1.6.1.tar.gz
CD On Apr-1.6.1-util
./configure --prefix = / usr / local / util On Apr---with-On Apr = / usr / local / On Apr # - -with-apr apr statement is the location, as dependent apr apr-util toolkit.
make && make install
so that we resolve dependencies, and began to prepare httpd;
.
official website Download: http://httpd.apache.org/download.cgi#apache24
the same source package in / usr / local / src / directory
the tar XF 2.4.39.tar.gz the httpd-
CD the httpd-2.4.39
./configure --prefix = / usr / local / = --sysconfdir the httpd / etc / --enable the httpd-SO-mod_ssl --enable --enable-cgi --enable-cgid --enable- rewirte --enbale-modules = most --enable-mods-shared = most --enable-mpms-shared = all --with-apr = / usr / local / apr --with-apr-util = / usr / local / apr-util # Note: ./ configure other parameters can be viewed, according to their need to be added.
the make install && the make
.
The following is a description httpd source compiler parameters:
--prefix = / usr / local / httpd # Configure httpd installation path
--sysconfdir = / etc / httpd #httpd main configuration file path
--enable-so # supports dynamic sharing module
--enbale-mod_ssl # ssl function is enabled, not you can not use https enabled features
--enable-cgi # supports cgi protocols
--enable-cgid # If you are using vorker and event mode you need to add this
--enable-rewirte # support URL rewriting functionality
--enable-modules = most # enable module functions, most (most), all (all), few (few)
--enable-MODS = most # shared-enabled shared module
--enable-mpms-shared = all #mpm ( more than processing modules), all three modes will be made showing the module added (the prefork, vorker, Event)
--with-apr = / usr / local / # statement apr apr mounting position
--with-apr-util = / usr / local / apr-util # statement apr-util installation position
.
after installation in / usr / local / httpd / directory will generate about directory
bin: binary files
cgi-bin: position when executing cgi program
error: to store some errors information
htdocs: location page document
icons: some icons
include: headers
logs: log files
man: Help file
manual: Installation Manual
modules: Module directory
.
httpd default when selinux start, not start httpd, so we turn it off
to see: getenforse
temporarily modify: setenforse 0
permanent modifications to edit / etc / selinux / config file
SELINUX = disabled
to disabled can
.
we can use the / bin / apachectl start to start httpd service
netstat -nlpt see whether the port has been listening
to the PATH variable, edit the file /etc/profile.d/httpd.sh
Export PATH = $ PATH: / usr / local / httpd / bin
default httpd service does not support the service, you need to write your own script, edit /etc/init.d/httpd, the script reads as follows:
# / bin / bash!

#httpd Startup script for the Apache HTTP Server
#chkconfig: - 85 15

#description: Apache is a World Wide Web server. It is 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 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/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 10 $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 "$1" 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 $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac

exit $ RETVAL
then chmod + x /etc/init.d/script_name can
.
This makes it easy to enable or disable the httpd service.

Guess you like

Origin blog.51cto.com/14132521/2418682