CentOS 7設定開機啟動服務,添加自訂系統服務
1.建立服務檔案
檔案路徑
vim /usr/lib/systemd/system/nginx.service
服務檔案內容
[Unit]Description=nginx - high performance web serverAfter=network.target remote-fs.target nss-lookup.target[Service]Type=forkingExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/usr/local/nginx/sbin/nginx -s reloadExecStop=/usr/local/nginx/sbin/nginx -s stop[Install]WantedBy=multi-user.target
檔案內容解釋
[Unit]:服務的說明Description:描述服務After:描述服務類別[Service]服務運行參數的設定Type=forking是後台啟動並執行形式ExecStart為服務的具體運行命令ExecReload為重啟命令ExecStop為停止命令PrivateTmp=True表示給服務分配獨立的臨時空間注意:啟動、重啟、停止命令全部要求使用絕對路徑[Install]服務安裝的相關設定,可設定為多使用者
2.儲存目錄
以754的許可權儲存在目錄:
/usr/lib/systemd/system
3.設定開機自啟動
任意目錄下執行
systemctl enable nginx.service
4.其他命令
啟動nginx服務
systemctl start nginx.service
設定開機自啟動
systemctl enable nginx.service
停止開機自啟動
systemctl disable nginx.service
查看服務目前狀態
systemctl status nginx.service
重新啟動服務
systemctl restart nginx.service
查看所有已啟動的服務
systemctl list-units --type=service
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了CentOS 7設定開機啟動服務,添加自訂系統服務,包括了centos 7方面的內容,希望對PHP教程有興趣的朋友有所協助。