把編譯安裝的httpd 實現服務指令碼,通過service和chkconfig 進行管理,httpdchkconfig
把編譯安裝的httpd 實現服務指令碼,通過service和chkconfig 進行管理
1 編譯安裝httpd
把httpd編譯安裝在/app/httpd/目錄下。
2 在/etc/rc.d/init.d/目錄下建立一個檔案httpd
這個檔案的目的在於讓service 命令可以管理編譯安裝的httpd服務。
檔案內容如下:
[root@CentOS68 ~]# cat /etc/rc.d/init.d/httpd#!/bin/bash## httpd Start up the httpd server daemon## chkconfig: 2345 99 01# description: httpd is a protocol for web server.# This service starts up the httpd server daemon.## processname: httpdcase $1 instart) /app/httpd/bin/apachectl start ;;stop) /app/httpd/bin/apachectl stop ;;status) /app/httpd/bin/apachectl status ;;*) echo erresac
3 添加為開機啟動
[root@CentOS68 /app/httpd/bin]# chkconfig --add httpd[root@CentOS68 /app/httpd/bin]# chkconfig --list |grep httpdhttpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
可以看到已經添加成功
4 通過service 命令啟動服務
[root@CentOS68 ~]# service httpd starthttpd: Could not reliably determine the server's fully qualified domain name, using CentOS68.localhost for ServerName
可以看到會報錯,但是服務已經啟動成功了,修改/app/httpd/conf/httpd.conf這個檔案,把98行前面的#去掉即可
98 #ServerName www.example.com:80
現在可以通過service命令管理手動安裝的httpd 服務了