手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

LAMP构建----基于FCGI的轻量级WEB服务器全手动编译安装

[日期:2013-04-18] 来源:Linux社区  作者:yhwhzhang [字体:大 中 小]

一、编译安装apache

1、解决依赖关系

httpd-2.4.4需要较新版本的apr和apr-util,因此需要事先对其进行升级。这里我们事先下载好了apr-1.4.6.tar.bz2和apr-util-1.5.2.tar.bz2的包。

(1) 编译安装apr
  1. # tar xf apr-1.4.6.tar.bz2
  2. # cd apr-1.4.6
  3. # ./configure --prefix=/usr/local/apr
  4. # make && make install
(2) 编译安装apr-util
  1. # tar xf apr-util-1.5.2.tar.bz2
  2. # cd apr-util-1.5.2
  3. # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  4. # make && make install
3、修改httpd的主配置文件,设置其Pid文件的路径
  1. 编辑/etc/httpd/httpd.conf,添加如下行即可:
  2. PidFile "/var/run/httpd.pid"#此步骤是为了我们下一步的脚本使用的
4、提供SysV服务脚本/etc/rc.d/init.d/httpd,以便于我们能够使用service httpd start开启和关闭服务,脚本我们已经写好了,这里就给大家共享一下:
  1. #!/bin/bash
  2. #
  3. # httpd Startup script for the Apache HTTP Server
  4. #
  5. # chkconfig: - 85 15
  6. # description: Apache is a World Wide Web server. It is used to serve \
  7. # HTML files and CGI.
  8. # processname: httpd
  9. # config: /etc/httpd/conf/httpd.conf
  10. # config: /etc/sysconfig/httpd
  11. # pidfile: /var/run/httpd.pid
  12. # Source function library.
  13. . /etc/rc.d/init.d/functions
  14. if [ -f /etc/sysconfig/httpd ]; then
  15. . /etc/sysconfig/httpd
  16. fi
  17. # Start httpd in the C locale by default.
  18. HTTPD_LANG=${HTTPD_LANG-"C"}
  19. # This will prevent initlog from swallowing up a pass-phrase prompt if
  20. # mod_ssl needs a pass-phrase from the user.
  21. INITLOG_ARGS=""
  22. # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
  23. # with the thread-based "worker" MPM; BE WARNED that some modules may not
  24. # work correctly with a thread-based MPM; notably PHP will refuse to start.
  25. # Path to the apachectl script, server binary, and short-form for messages.
  26. apachectl=/usr/local/apache/bin/apachectl
  27. httpd=${HTTPD-/usr/local/apache/bin/httpd}
  28. prog=httpd
  29. pidfile=${PIDFILE-/var/run/httpd.pid}
  30. lockfile=${LOCKFILE-/var/lock/subsys/httpd}
  31. RETVAL=0
  32. start() {
  33. echo -n $"Starting $prog: "
  34. LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
  35. RETVAL=$?
  36. echo
  37. [ $RETVAL = 0 ] && touch ${lockfile}
  38. return $RETVAL
  39. }
  40. stop() {
  41. echo -n $"Stopping $prog: "
  42. killproc -p ${pidfile} -d 10 $httpd
  43. RETVAL=$?
  44. echo
  45. [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
  46. }
  47. reload() {
  48. echo -n $"Reloading $prog: "
  49. if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
  50. RETVAL=$?
  51. echo $"not reloading due to configuration syntax error"
  52. failure $"not reloading $httpd due to configuration syntax error"
  53. else
  54. killproc -p ${pidfile} $httpd -HUP
  55. RETVAL=$?
  56. fi
  57. echo
  58. }
  59. # See how we were called.
  60. case "$1"in
  61. start)
  62. start
  63. ;;
  64. stop)
  65. stop
  66. ;;
  67. status)
  68. status -p ${pidfile} $httpd
  69. RETVAL=$?
  70. ;;
  71. restart)
  72. stop
  73. start
  74. ;;
  75. condrestart)
  76. if [ -f ${pidfile} ] ; then
  77. stop
  78. start
  79. fi
  80. ;;
  81. reload)
  82. reload
  83. ;;
  84. graceful|help|configtest|fullstatus)
  85. $apachectl $@
  86. RETVAL=$?
  87. ;;
  88. *)
  89. echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  90. exit 1
  91. esac
  92. exit $RETVAL
而后为此脚本赋予执行权限:
  1. # chmod +x /etc/rc.d/init.d/httpd
加入服务列表:
  1. # chkconfig --add httpd
  2. # chkconfig --level 35 httpd on
  3. # service httpd restart
将httpd服务命令添加到环境变量中去:
  1. # vim /etc/profile.d/httpd.sh
  2. export PATH=$PATH:/usr/local/apache/bin
如此我们的APACHE服务器就算是搭建好了!此时我们启动服务器,查看一下网页!

linux
相关资讯       lamp  LAMP编译安装 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款