在CentOS系统中,服务的启动和停止通常通过systemctl
命令来完成。以下是一些基本步骤:
查看服务状态:
systemctl status 服务名
例如,查看httpd
服务的状态:
systemctl status httpd
启动服务:
systemctl start 服务名
例如,启动httpd
服务:
systemctl start httpd
设置服务开机自启:
systemctl enable 服务名
例如,设置httpd
服务开机自启:
systemctl enable httpd
停止服务:
systemctl stop 服务名
例如,停止httpd
服务:
systemctl stop httpd
禁用服务开机自启:
systemctl disable 服务名
例如,禁用httpd
服务开机自启:
systemctl disable httpd
systemctl list-units --type=service
systemctl status 服务名
systemctl restart 服务名
例如,重启httpd
服务:
systemctl restart httpd
journalctl -u 服务名
例如,查看httpd
服务的日志:
journalctl -u httpd
假设你想管理nginx
服务:
启动nginx
服务:
systemctl start nginx
停止nginx
服务:
systemctl stop nginx
查看nginx
服务状态:
systemctl status nginx
设置nginx
服务开机自启:
systemctl enable nginx
禁用nginx
服务开机自启:
systemctl disable nginx
查看nginx
服务的日志:
journalctl -u nginx
通过这些命令,你可以方便地管理CentOS系统中的各种服务。