1.
tar xvf apr-1.6.2.tar.gz
tar xvf apr-util-1.6.0.tar.gz
tar xvf httpd-2.4.28.tar.bz2
2.
cp -a apr-1.6.2 httpd-2.4.28/srclib/apr
cp -a apr-util-1.6.0 httpd-2.4.28/srclib/apr-util
3.
getent passwd apache查看apache帐户
groupadd -g 48 -r apache;useradd -r -u 48 -g apache -s /sbin/nologin -d /usr/share/httpd -c "Apache" apache 规范点的写法如此,也可以简单的写
useradd -r -d /app/httpd24 -m -s /sbin/nologin apache
4.
缺包装包
yum groupnstall 'development-tools'
yum install openssl-devel pcre-devel expat-devel
5.
cd httpd-2.4.28/
./configure --prefix=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-included-apr \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
6.make -j 4 && make install
7.
path变量
vim /etc/profile.d/httpd.sh
PATH=/app/httpd24/bin:$PATH
. /etc/profile.d/httpd.sh
8.
vim /app/http24/conf/httpd.conf
User apache
Group apache
9.准备服务脚本
cd /etc/init.d
cp httpd httpd24
服务脚本httpd,这里改为httpd24以便区分。httpd为原httpd包自带的,rpm -q --scripts httpd查看之前的服务脚本。或者从别的地方拷一个。这里阿拉拷贝好了一个。
#!/bin/bash # #httpdStartupscriptfortheApacheHTTPServer # #chkconfig:-8515 #description:TheApacheHTTPServerisanefficientandextensible\ #serverimplementingthecurrentHTTPstandards. #processname:httpd #config:/etc/httpd/conf/httpd.conf #config:/etc/sysconfig/httpd #pidfile:/var/run/httpd/httpd.pid # ###BEGININITINFO #Provides:httpd #required-Start:$local_fs$remote_fs$network$named #required-Stop:$local_fs$remote_fs$network #Should-Start:distcache #Short-Description:startandstopApacheHTTPServer #Description:TheApacheHTTPServerisanextensibleserver #implementingthecurrentHTTPstandards. ###ENDINITINFO #Sourcefunctionlibrary. ./etc/rc.d/init.d/functions if[-f/etc/sysconfig/httpd];then ./etc/sysconfig/httpd fi #StarthttpdintheClocalebydefault. HTTPD_LANG=${HTTPD_LANG-"C"} #Thiswillpreventinitlogfromswallowingupapass-phrasepromptif #mod_sslneedsapass-phrasefromtheuser. INITLOG_ARGS="" #SetHTTPD=/usr/sbin/httpd.workerin/etc/sysconfig/httpdtouseaserver #withthethread-based"worker"MPM;BEWARNEDthatsomemodulesmaynot #workcorrectlywithathread-basedMPM;notablyPHPwillrefusetostart. #Pathtotheapachectlscript,serverbinary,andshort-formformessages. apachectl=/usr/sbin/apachectl httpd=${HTTPD-/usr/sbin/httpd} prog=httpd pidfile=${PIDFILE-/var/run/httpd/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 STOP_TIMEOUT=${STOP_TIMEOUT-10} #Thesemanticsofthesetwofunctionsdifferfromthewayapachectldoes #things--attemptingtostartwhilerunningisafailure,andshutdown #whennotrunningisalsoafailure.Sowejustdoitthewayinitscripts #areexpectedtobehavehere. start(){ echo-n$"Starting$prog:" LANG=$HTTPD_LANGdaemon--pidfile=${pidfile}$httpd$OPTIONS RETVAL=$? echo [$RETVAL=0]&&touch${lockfile} return$RETVAL } #Whenstoppinghttpd,adelay(ofdefault10second)isrequired #beforeSIGKILLingthehttpdparent;thisgivesenoughtimeforthe #httpdparenttoSIGKILLanyerrantchildren. stop(){ status-p${pidfile}$httpd>/dev/null if[[$?=0]];then echo-n$"Stopping$prog:" killproc-p${pidfile}-d${STOP_TIMEOUT}$httpd else echo-n$"Stopping$prog:" success fi RETVAL=$? echo [$RETVAL=0]&&rm-f${lockfile}${pidfile} } reload(){ echo-n$"Reloading$prog:" if!LANG=$HTTPD_LANG$httpd$OPTIONS-t>&/dev/null;then RETVAL=6 echo$"notreloadingduetoconfigurationSyntaxerror" failure$"notreloading$httpdduetoconfigurationSyntaxerror" else #ForceLSBbehavIoUrfromkillproc LSB=1killproc-p${pidfile}$httpd-HUP RETVAL=$? if[$RETVAL-eq7];then failure$"httpdshutdown" fi fi echo } #Seehowwewerecalled. case"$1"in start) start ;; stop) stop ;; status) status-p${pidfile}$httpd RETVAL=$? ;; restart) stop start ;; condrestart|try-restart) ifstatus-p${pidfile}$httpd>&/dev/null;then stop start fi ;; force-reload|reload) reload ;; graceful|help|configtest|fullstatus) $apachectl$@ RETVAL=$? ;; *) echo$"Usage:$prog{start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}" RETVAL=2 esac exit$RETVAL
更改相关路径
vim httpd24
apachectl=/app/httpd24/bin/apachectl
httpd={HTTPD-/app/httpd24/bin/httpd}
pidfile={PIDFILE-/app/httpd24/logs/http.pid}
lockfile={LOCKFILE-/var/lock/subsys/httpd24}
启动服务
chkconfig --add httpd24
chkconfig httpd24 on
service httpd24 start
10.测试
原文链接:https://www.f2er.com/centos/375485.html