centos7 PHP7.1 Failed to restart php-fpm.service: Unit not found.


在編譯PHP以后沒有將PHP添加到服務列表導致使用systemcel命令時候出現
解決步驟
1.打開vi /lib/systemd/system/php-fpm.service文件,如果沒有就重新新建一個
2.復制一下內容到文件內,記着更改一下PHP的文件目錄

[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=你的文件目錄/php/sbin/php-fpm
ExecStop=/bin/pkill -9 php-fpm
PrivateTmp=true
[Install]
WantedBy=multi-user.target

3.添加完成以后保存,使用systemctl list-unit-files --type=service查看有沒有php-fpm.service
如果沒有就是用systemctl daemon-reload重新加載,在使用以上命令查看

4.添加開機自啟 systemctl enable php-fpm.service

字段說明

[Unit]:服務的說明
Description:描述服務
After:描述服務類別
[Service]服務運行參數的設置
Type=forking是后台運行的形式
ExecStart為服務的具體運行命令
ExecReload為重啟命令
ExecStop為停止命令
PrivateTmp=True表示給服務分配獨立的臨時空間
注意:[Service]的啟動、重啟、停止命令全部要求使用絕對路徑
[Install]運行級別下服務安裝的相關設置,可設置為多用戶,即系統運行級別為3

Nginx 服務字段

[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=目錄/nginx/sbin/nginx -c 目錄/nginx/conf/nginx.conf
ExecReload=目錄/nginx/sbin/nginx -s reload
ExecStop=目錄/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM