CentOS 7設定開機啟動服務,添加自訂系統服務 centos 7 關閉防火牆 centos 7.2 centos 7 64位下載

來源:互聯網
上載者:User
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教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.