chkconfig httpd任務(wù)添加具體實(shí)現(xiàn)代碼詳解
在Linux中chkconfighttpd任務(wù)添加,Apache服務(wù)器的***穩(wěn)定發(fā)布版本是httpd-2.2..0,官方下載地址是:http://httpd.apache.org/download.cgi。我們通過(guò)下面的步驟來(lái)快速的搭建一個(gè)web服務(wù)器。
1、下載源碼文件httpd-2.2.0.tar.gz 到linux服務(wù)器的某個(gè)目錄。
2、解壓文件 # tar zxvf httpd-2.2.0.tar.gz .
3、配置 # ./configure –refix=/usr/local/apache //指定安裝目錄,以后要?jiǎng)h除安裝就只需刪除這個(gè)目錄。
4、編譯和安裝。 # make ; make install .
5、編寫啟動(dòng)腳本,把它放到目錄 /etc/rc.d/init.d/里,這里取名為httpd,其內(nèi)容如下:
- #!/bin/bash
- #description:http server
- #chkconfig: 235 98 98
- case "$1" in
- start)
- echo "Starting Apache daemon..."
- /usr/local/apache2/bin/apachectl -k start
- ;;
- stop)
- echo "Stopping Apache daemon..."
- /usr/local/apache2/bin/apachectl -k stop
- ;;
- restart)
- echo "Restarting Apache daemon..."
- /usr/local/apache2/bin/apachectl -k restart
- ;;
- status)
- statusproc /usr/local/apache2/bin/httpd
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|status}"
- exit 1
- ;;
- Esac
注意:#description:http server 這一行必須加上,否則在執(zhí)行命令 # chkconfig –add httpd 時(shí)會(huì)出現(xiàn)“service apache does not support chkconfig”的錯(cuò)誤報(bào)告。#chkconfig: 2345 98 98 表示在執(zhí)行命令 # chkconfig –add httpd 時(shí)會(huì)在目錄 /etc/rc2.d/ 、/etc/rc3.d/ /etc/rc5.d 分別生成文件 S98httpd和 K98httpd。這個(gè)數(shù)字可以是別的。
6、執(zhí)行命令 # chkconfig –add httpd ,進(jìn)入目錄/etc/rc3.d/檢查是否生成文件 S98httpd及K98httpd.
7、啟動(dòng)服務(wù) # service httpd start .
【編輯推薦】
- 輕松掌握Linux chgrp與chown命令
- Linux Cat命令深度用法實(shí)例說(shuō)明
- Linux Cat命令實(shí)際應(yīng)用詳解
- Linux Cat命令三大主要功能詳解
- 詳解Linux chgrp和chown命令的用法