centos6编译httpd2.4

前端之家收集整理的这篇文章主要介绍了centos6编译httpd2.4前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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帐户

须保证apache用户为系统用户

则需要userdel -r apache删除用户重新创建

创建apache用户需指定家目录及登录shell

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查看之前的服务脚本。或者从别的地方拷一个。这里阿拉拷贝好了一个。

  1. #!/bin/bash
  2. #
  3. #httpdStartupscriptfortheApacheHTTPServer
  4. #
  5. #chkconfig:-8515
  6. #description:TheApacheHTTPServerisanefficientandextensible\
  7. #serverimplementingthecurrentHTTPstandards.
  8. #processname:httpd
  9. #config:/etc/httpd/conf/httpd.conf
  10. #config:/etc/sysconfig/httpd
  11. #pidfile:/var/run/httpd/httpd.pid
  12. #
  13. ###BEGININITINFO
  14. #Provides:httpd
  15. #required-Start:$local_fs$remote_fs$network$named
  16. #required-Stop:$local_fs$remote_fs$network
  17. #Should-Start:distcache
  18. #Short-Description:startandstopApacheHTTPServer
  19. #Description:TheApacheHTTPServerisanextensibleserver
  20. #implementingthecurrentHTTPstandards.
  21. ###ENDINITINFO
  22.  
  23. #Sourcefunctionlibrary.
  24. ./etc/rc.d/init.d/functions
  25.  
  26. if[-f/etc/sysconfig/httpd];then
  27. ./etc/sysconfig/httpd
  28. fi
  29.  
  30. #StarthttpdintheClocalebydefault.
  31. HTTPD_LANG=${HTTPD_LANG-"C"}
  32.  
  33. #Thiswillpreventinitlogfromswallowingupapass-phrasepromptif
  34. #mod_sslneedsapass-phrasefromtheuser.
  35. INITLOG_ARGS=""
  36. #SetHTTPD=/usr/sbin/httpd.workerin/etc/sysconfig/httpdtouseaserver
  37. #withthethread-based"worker"MPM;BEWARNEDthatsomemodulesmaynot
  38. #workcorrectlywithathread-basedMPM;notablyPHPwillrefusetostart.
  39.  
  40. #Pathtotheapachectlscript,serverbinary,andshort-formformessages.
  41. apachectl=/usr/sbin/apachectl
  42. httpd=${HTTPD-/usr/sbin/httpd}
  43. prog=httpd
  44. pidfile=${PIDFILE-/var/run/httpd/httpd.pid}
  45. lockfile=${LOCKFILE-/var/lock/subsys/httpd}
  46. RETVAL=0
  47. STOP_TIMEOUT=${STOP_TIMEOUT-10}
  48.  
  49. #Thesemanticsofthesetwofunctionsdifferfromthewayapachectldoes
  50. #things--attemptingtostartwhilerunningisafailure,andshutdown
  51. #whennotrunningisalsoafailure.Sowejustdoitthewayinitscripts
  52. #areexpectedtobehavehere.
  53. start(){
  54. echo-n$"Starting$prog:"
  55. LANG=$HTTPD_LANGdaemon--pidfile=${pidfile}$httpd$OPTIONS
  56. RETVAL=$?
  57. echo
  58. [$RETVAL=0]&&touch${lockfile}
  59. return$RETVAL
  60. }
  61.  
  62. #Whenstoppinghttpd,adelay(ofdefault10second)isrequired
  63. #beforeSIGKILLingthehttpdparent;thisgivesenoughtimeforthe
  64. #httpdparenttoSIGKILLanyerrantchildren.
  65. stop(){
  66. status-p${pidfile}$httpd>/dev/null
  67. if[[$?=0]];then
  68. echo-n$"Stopping$prog:"
  69. killproc-p${pidfile}-d${STOP_TIMEOUT}$httpd
  70. else
  71. echo-n$"Stopping$prog:"
  72. success
  73. fi
  74. RETVAL=$?
  75. echo
  76. [$RETVAL=0]&&rm-f${lockfile}${pidfile}
  77. }
  78. reload(){
  79. echo-n$"Reloading$prog:"
  80. if!LANG=$HTTPD_LANG$httpd$OPTIONS-t>&/dev/null;then
  81. RETVAL=6
  82. echo$"notreloadingduetoconfigurationSyntaxerror"
  83. failure$"notreloading$httpdduetoconfigurationSyntaxerror"
  84. else
  85. #ForceLSBbehavIoUrfromkillproc
  86. LSB=1killproc-p${pidfile}$httpd-HUP
  87. RETVAL=$?
  88. if[$RETVAL-eq7];then
  89. failure$"httpdshutdown"
  90. fi
  91. fi
  92. echo
  93. }
  94. #Seehowwewerecalled.
  95. case"$1"in
  96. start)
  97. start
  98. ;;
  99. stop)
  100. stop
  101. ;;
  102. status)
  103. status-p${pidfile}$httpd
  104. RETVAL=$?
  105. ;;
  106. restart)
  107. stop
  108. start
  109. ;;
  110. condrestart|try-restart)
  111. ifstatus-p${pidfile}$httpd>&/dev/null;then
  112. stop
  113. start
  114. fi
  115. ;;
  116. force-reload|reload)
  117. reload
  118. ;;
  119. graceful|help|configtest|fullstatus)
  120. $apachectl$@
  121. RETVAL=$?
  122. ;;
  123. *)
  124. echo$"Usage:$prog{start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
  125. RETVAL=2
  126. esac
  127.  
  128. 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.测试

猜你在找的CentOS相关文章