Linux服務程序管理
- 服務管理
- 程序管理
準備工作- 安裝nginx服務
準備安裝一個nginx 網站伺服器,預設端口為80。用于測試目的
yum -y install nginx
服務管理-systemctl
7 : systemctl 6: service
啟動 : systemctl start nginx
停止: systemctl stop nginx
重新開機: systemctl restart nginx
重載: systemctl reload nginx
狀态 : systemctl status nginx
開機自啟 : systemctl enable nginx
開機禁止: systemctl disable nginx
服務驗證
netstat 檢視端口,tcp:-anlpt , udp: -anlpu
[root@myserver ~]# netstat -anlpt | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6416/nginx: master
tcp6 0 0 :::80 :::* LISTEN 6416/nginx: master
ps 檢視程序狀态
[root@myserver ~]# ps aux |grep nginx
root 6416 0.0 0.5 118672 9920 ? Ss 09:10 0:00 nginx: master process /usr/sbin/nginx
nginx 6447 0.0 0.4 150020 9000 ? S 09:10 0:00 nginx: worker process
root 6635 0.0 0.0 12108 1088 pts/0 S+ 09:15 0:00 grep --color=auto nginx
###
運作使用者、程序id
kill pid
kill -9 123
kill -15 123
killall nginx ## 将nginx服務的所有程序停止