Make the startup script for httpd Installation

Source: Internet
Author: User
The httpd server installed with yuminstallhttpd * is under the etchttpd directory by default, but the project path is under varwwwhtml by default. in the conf configuration file, check that if httpd is downloaded from the Internet for installation, it is different. If you need to start it, you cannot use servicehttpdstart. You need to go to the apac directory

Use yum installHttpd* The installed httpd server is under the/etc/httpd directory by default.

However, the project path is under/var/www/html by default, which can be viewed in the httpd. conf configuration file.

If you download httpd from the Internet for installation, it is different. If you need to start it, you cannot use service httpd start.

You need to go to the/apache2/bin/httpd directory. In this way, you can start

Install apacheCompression

Place the downloaded package under/usr/local/src and use tar zxvf httpd-NN.tar.gzExtract,
CdHttpd-NN
./Configure -- prefix =/usr/local/httpd
Make
Make install

Now you find that there is an extra httpd directory under/usr/local.
We can use/usr/local/httpd/bin/Apachectl-K start | stop | restart to manage httpd services.
To start with the system, add a line at the end of the/etc/rc. d/init. d/rc. local file:
/Usr/local/httpd/bin/apachectl-k start
Even so, we still cannot manage the httpd service. Can we use the service to manage the httpd service like rpm installation?
The answer is yes. We must do the following:
Create an httpd file under/etc/rc. d/init. d/and useChmod755 httpd makes it executable.
Add the following content to vi httpd:

  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 usEdTo serve
  7. # HTMLFileS 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. # SetHTTPD=/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; notablyPHPWill refuse to start.
  25. # Path to the apachectl script, server binary, and short-foRmFor messages.
  26. Apachectl=/Usr/sbin/apachectl
  27. Httpd={ {HTTPD-/usr/sbin/httpd}
  28. Prog=Httpd
  29. Pidfile=$ {PIDFILE-/var/run/httpd. pid}
  30. Lockfile={ {LOCKFILE-/var/lock/SuBsys/httpd}
  31. RETVAL=0
  32. # Check for 1.3 configuration
  33. Check13 (){
  34. CONFFILE=/Etc/httpd/conf/httpd. conf
  35. GONE=\ "(ServerType | BindADdRess | Port | AddModule | ClearModuleList | \"
  36. GONE=\ "$ {GONE} AgentLog | RefererLog | RefererIgnore | FancyIndExIng | \"
  37. GONE=\ "$ {GONE} AccessConfig | ResourceConfig )\"
  38. IfLANG=C Grep-Eiq \ "^ [[: space:] * ($ GONE) \" $ CONFFILE; then
  39. Echo
  40. Echo 1>& 2 \ "Apache 1.3 configuration ctictives found \"
  41. Echo 1>& 2 \ "please read/usr/share/doc/httpd-2.2.3/migration.html \"
  42. Failure \ "Apache 1.3 config directives test \"
  43. Echo
  44. Exit 1
  45. Fi
  46. }
  47. # The semantics of these two functionsDiffEr from the way apachectl does
  48. # Things -- attempting to start while running is a failure, and shutdown
  49. # When not running isLsO a failure. So we just do it the way init scripts
  50. # Are expected to behave here.
  51. Start (){
  52. Echo-n {1} quot; Starting $ prog :\"
  53. Check13 | exit 1
  54. LANG= $ HTTPD_LANG daemon $ httpd $ OPTIONS
  55. RETVAL= $?
  56. Echo
  57. [$RETVAL=0] &Touch$ {Lockfile}
  58. Return $ RETVAL
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.