Skip to content

服务管理

服务程序一般是开机自启的,并且是一只运行着的,提供服务的,某些软件或者系统程序需要用到它提供的功能,它就默默的在后台运行着,用户看不到服务程序的界面。linux下也有服务程序,比如说Xshell是一个软件,内置了ssh客户端程序,linux开机就运行着sshd服务程序,客户端可以随时连接ssh。所以sshd是一个服务程序。

软件服务都是程序。

  • 软件一般是客户端,比如curl
  • 服务一般是给客户端程序提供一个功能,一直运行的

这里以安装一个apache服务为例:

服务的操作:

  • 开机自启
  • 重启服务
  • 启动服务
  • 停止服务

安装服务:

yum install httpd // httpd 就是 网站服务程序,也叫apache

查看所有服务列表:

systemctl list-unit-files

启动服务:

systemctl start httpd

停止服务:

systemctl stop httpd

重启服务:

systemctl restart httpd

查看服务状态:

systemctl status httpd

把服务设置为开启自启:

systemctl enable httpd.service

取消开机自启:

systemctl disable httpd.service