CentOS7、RHEL 7 以降のサービス起動・停止コマンド

クラウドサーバですとCentOS7も選択できるようになってきており、CentOS7でWebサーバ構築をする機会がありサービスの起動コマンドが変わっていたのでその時のメモとなります。
CentOS6以前で使用していたサービス起動「/etc/init.d/httpd start」や自動起動設定「chkconfig httpd on」などの実行が出来なくなっています。
CentOS7から各種サービスの管理が「systemd」に変更されているためとなります。

Contents

サービスの起動

systemctl start {サービス名}.service

(例)systemctl start httpd.service

停止

systemctl stop {サービス名}.service

(例)systemctl stop httpd.service

再起動

systemctl restart {サービス名}.service

(例)systemctl restart httpd.service

自動起動を有効

systemctl enable {サービス名}.service

(例)systemctl enable httpd.service

自動起動を無効

systemctl disable {サービス名}.service

(例)systemctl disable httpd.service

自動起動の状態表示

systemctl is-enabled {サービス名}.service

(例)systemctl is-enabled httpd.service

サービス一覧の表示

systemctl –type service {サービス名}.service

(例)systemctl is-enabled httpd.service

(Visited 3,111 times, 1 visits today)