centos下设置nginx,fdfs,docker开机自启动
1. 設(shè)置Nginx開機啟動
第一步:進入到/lib/systemd/system/目錄
# cd /lib/systemd/system/
第二步:創(chuàng)建nginx.service文件,并編輯
# vim nginx.service
內(nèi)如如下:
[Unit] Description=nginx service After=network.target [Service] Type=forking ExecStart=/mytest/nginx/sbin/nginx ExecReload=/mytest/nginx/sbin/nginx -s reload ExecStop=/mytest/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target
配置參數(shù)說明:
這里ExecStart ExecReload ExecStop 換成自己的啟動路徑;
[Unit]:服務(wù)的說明
Description:描述服務(wù)
After:描述服務(wù)類別
[Service]:服務(wù)運行參數(shù)的設(shè)置
Type=forking:是后臺運行的形式
ExecStart:為服務(wù)的具體運行命令
ExecReload:為重啟命令
ExecStop:為停止命令
PrivateTmp=True:表示給服務(wù)分配獨立的臨時空間
注意:[Service]的啟動、重啟、停止命令全部要求使用絕對路徑
[Install]運行級別下服務(wù)安裝的相關(guān)設(shè)置,可設(shè)置為多用戶,即系統(tǒng)運行級別為3
保存退出。
第三步:加入開機自啟動
# systemctl enable nginx
如果不想開機自啟動了,可以使用下面的命令取消開機自啟動
# systemctl disable nginx
第四步:服務(wù)的啟動/停止/刷新配置文件/查看狀態(tài)
# systemctl start nginx.service 啟動nginx服務(wù) # systemctl stop nginx.service 停止服務(wù) # systemctl restart nginx.service 重新啟動服務(wù) # systemctl list-units --type=service 查看所有已啟動的服務(wù) # systemctl status nginx.service 查看服務(wù)當前狀態(tài) # systemctl enable nginx.service 設(shè)置開機自啟動 # systemctl disable nginx.service 停止開機自啟動
2設(shè)置FDFS開機啟動:
fdfs_tracker:
cp FastDFS/init.d/fdfs_trackerd /etc/init.d/
chkconfig –add fdfs_trackerd
chkconfig fdfs_trackerd on
fdfs_storafed:
cp FastDFS/init.d/fdfs_storaged /etc/init.d/
chkconfig –add fdfs_storaged
chkconfig fdfs_storaged on
3.設(shè)置docker開機啟動
docker 服務(wù)器開機自啟動:
1.systemctl is-enabled docker.service 檢查服務(wù)是否開機啟動
2.systemctl enable docker.service 將服務(wù)配置成開機啟動
3.systemctl start docker.service 啟動服務(wù)
systemctl 相關(guān)其他命令:
systemctl disable docker.service 禁止開機啟動
systemctl stop docker.service 停止服務(wù)
systemctl restart docker.service 重啟服務(wù)
總結(jié)
以上是生活随笔為你收集整理的centos下设置nginx,fdfs,docker开机自启动的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 树莓派远程连接工具SSH使用教程
- 下一篇: .net core3.1连接GBase数