[英]How do I restart nginx from a python script?
我可以使用"nginx -s reload"
命令在 shell 上重新啟動 nginx。 但是,當我使用os.system("nginx -s reload")
命令時,會出現錯誤。
/usr/local/bin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
對於此錯誤。 我已經安裝了pcre。 是不是有一些魔法問題。
要在 python 腳本中運行此類命令,最好使用 subprocess library 。
試試這個代碼而不是你的:
import subprocess
subprocess.call('whatever command you want to run it in terminal', shell=True)
走運
您好,我建議您在發送重置之前先發送此驗證,以免頭疼
reinicioNGINX = subprocess.getoutput(['nginx -t'])
如果'nginx:配置文件/etc/nginx/nginx.conf語法沒問題'在reinicioNGINX中:
_command_restart
別的:
_command_avoid_restart
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.