本文摘自PHP中文网,作者巴扎黑,侵删。
把编译安装的httpd 实现服务脚本,通过service和chkconfig 进行管理
1 编译安装httpd
把httpd编译安装在/app/httpd/目录下。
2 在/etc/rc.d/init.d/目录下新建一个文件httpd
这个文件的目的在于让service 命令可以管理编译安装的httpd服务。
文件内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | [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: httpd
case $1 in
start)
/app/httpd/bin/apachectl start ;;
stop)
/app/httpd/bin/apachectl stop ;;
status)
/app/httpd/bin/apachectl status ;;
*)
echo err
esac
|
3 添加为开机启动
1 2 3 | [root@CentOS68 /app/httpd/bin]# chkconfig --add httpd
[root@CentOS68 /app/httpd/bin]# chkconfig --list |grep httpd
httpd 0:off 1:off 2: on 3: on 4: on 5: on 6:off
|
可以看到已经添加成功
4 通过service 命令启动服务
1 2 | [root@CentOS68 ~]# service httpd start
httpd: 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 服务了
以上就是把编译安装的httpd,利用service和chkconfig进行管理的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
http和www服务的详细介绍
把编译安装的httpd,利用service和chkconfig进行管理
虚拟机实现静态ip登录的实例介绍
centos系统下无法启动httpd
linux实现显示器不休眠
centos下httpd无法访问怎么办
linux实现免密登录功能
linux中查看服务是否启动的方法有哪些
linux怎么重启服务
linux系统如何实现登录与退出
更多相关阅读请进入《httpd》频道 >>
转载请注明出处:木庄网络博客 » 把编译安装的httpd,利用service和chkconfig进行管理