{"id":248741,"date":"2022-08-08T08:10:21","date_gmt":"2022-08-08T00:10:21","guid":{"rendered":"https:\/\/gulass.cn\/?p=248741"},"modified":"2022-07-26T11:11:20","modified_gmt":"2022-07-26T03:11:20","slug":"centos-supervisor-nginx","status":"publish","type":"post","link":"https:\/\/gulass.cn\/centos-supervisor-nginx.html","title":{"rendered":"\u8fd0\u7ef4\uff1aCentos8\u5b89\u88c5Supervisor\u5b88\u62a4Nginx\u8fdb\u7a0b\u7b14\u8bb0"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nSupervisor\u662f\u57fa\u4e8ePython\u8bed\u8a00\u5f00\u53d1\u7684\u4e00\u5957\u7684\u8fdb\u7a0b\u7ba1\u7406\u7a0b\u5e8f\uff0c\u5b83\u53ef\u4ee5\u5c06\u4e00\u4e2a\u666e\u901a\u7684\u547d\u4ee4\u884c\u8fdb\u7a0b\u53d8\u4e3a\u540e\u53f0daemon\uff0c\u5e76\u76d1\u63a7\u8fdb\u7a0b\u72b6\u6001\uff0c\u5f02\u5e38\u9000\u51fa\u65f6\u652f\u6301\u81ea\u52a8\u91cd\u542f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"
\n\u4eca\u5929\u7ed9\u5927\u5bb6\u5206\u4eabCentos8\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u5982\u4f55\u5b89\u88c5supervisor\u8fdb\u7a0b\u7ba1\u7406\u7a0b\u5e8f\u5e76\u5b88\u62a4Nginx\u8fdb\u7a0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u80fd\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n

\u4e00\u3001supervisor\u4ecb\u7ecd<\/strong><\/div>\n
1\u3001\u7b80\u4ecb<\/strong><\/span><\/div>\n

Supervisor\u662f\u57fa\u4e8ePython\u8bed\u8a00\u5f00\u53d1\u7684\u4e00\u5957\u7684\u8fdb\u7a0b\u7ba1\u7406\u7a0b\u5e8f\uff0c\u5b83\u53ef\u4ee5\u5c06\u4e00\u4e2a\u666e\u901a\u7684\u547d\u4ee4\u884c\u8fdb\u7a0b\u53d8\u4e3a\u540e\u53f0daemon\uff0c\u5e76\u76d1\u63a7\u8fdb\u7a0b\u72b6\u6001\uff0c\u5f02\u5e38\u9000\u51fa\u65f6\u652f\u6301\u81ea\u52a8\u91cd\u542f\u3002<\/p>\n

2\u3001\u5de5\u4f5c\u539f\u7406<\/strong><\/span><\/div>\n

\u5b83\u4e3b\u8981\u662f\u901a\u8fc7fork\/exec\u7684\u65b9\u5f0f\u628a\u8fd9\u4e9b\u88ab\u7ba1\u7406\u7684\u8fdb\u7a0b\u5f53\u4f5csupervisor\u7684\u5b50\u8fdb\u7a0b\u6765\u542f\u52a8\uff0c\u8fd9\u6837\u53ea\u8981\u5728supervisor\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u628a\u8981\u7ba1\u7406\u7684\u8fdb\u7a0b\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u5199\u8fdb\u53bb\u5373\u53ef\u3002\u4e5f\u5b9e\u73b0\u5f53\u5b50\u8fdb\u7a0b\u6302\u6389\u7684\u65f6\u5019\uff0c\u7236\u8fdb\u7a0b\u53ef\u4ee5\u51c6\u786e\u83b7\u53d6\u5b50\u8fdb\u7a0b\u6302\u6389\u7684\u4fe1\u606f\u7684\uff0c\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u81ea\u5df1\u542f\u52a8\u548c\u9884\u8b66\u3002supervisor\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u529f\u80fd\uff0c\u53ef\u4ee5\u4e3asupervisord\u6216\u8005\u6bcf\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u975eroot\u7684user\uff0c\u8fd9\u4e2auser\u5c31\u53ef\u4ee5\u7ba1\u7406\u5b83\u5bf9\u5e94\u7684\u8fdb\u7a0b\u3002<\/p>\n

3\u3001\u8fd0\u884c\u73af\u5883<\/strong><\/span><\/div>\n

supervisor\u53ef\u4ee5\u8fd0\u884c\u5728\u5927\u591a\u6570\u7c7bUNIX\u7cfb\u7edf\uff0c\u4e0d\u652f\u6301windows\u7cfb\u7edf\u8fd0\u884c\uff0cSupervisor\u8fd0\u884c\u5728python3\u7248\u672c3.4\u6216\u66f4\u9ad8\u7248\u672c\u4ee5\u53capython2\u7248\u672c2.7\u4e0a\u5de5\u4f5c\u3002<\/p>\n

4\u3001supervisor \u7ec4\u6210<\/strong><\/span><\/div>\n

supervisord\uff1asupervisor\u670d\u52a1\u7684\u4e3b\u8981\u7ba1\u7406\u5668\uff0c\u8d1f\u8d23\u7ba1\u7406\u6211\u4eec\u914d\u7f6e\u7684\u5b50\u8fdb\u7a0b\uff0c\u5305\u62ec\u91cd\u542f\u5d29\u6e83\u6216\u5f02\u5e38\u9000\u51fa\u7684\u5b50\u8fdb\u7a0b\uff0c\u540c\u65f6\u4e5f\u54cd\u5e94\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u3002<\/p>\n

supervisorctl\uff1asupervisord\u670d\u52a1\u7684\u5ba2\u6237\u7aef\u547d\u4ee4\u884c\u3002\u542c\u8fc7\u8fd9\u4e2a\uff0c\u6211\u4eec\u53ef\u4ee5\u83b7\u5f97\u7531\u4e3b\u8fdb\u7a0b\u63a7\u5236\u7684\u5b50\u8fdb\u7a0b\u7684\u72b6\u6001\uff0c\u505c\u6b62\u548c\u542f\u52a8\u5b50\u8fdb\u7a0b\uff0c\u5e76\u83b7\u5f97\u4e3b\u8fdb\u7a0b\u7684\u8fd0\u884c\u5217\u8868\u3002<\/p>\n

Web Server\uff1a\u901a\u8fc7web\u754c\u9762\u67e5\u770b\u548c\u63a7\u5236\u8fdb\u7a0b\u72b6\u6001\u3002<\/p>\n

XML-RPC Interface\uff1a\u670d\u52a1\u4e8eweb UI\u7684\u540c\u4e00\u4e2aHTTP\u670d\u52a1\u5668\u63d0\u4f9b\u4e00\u4e2aXML-RPC\u63a5\u53e3\uff0c\u53ef\u4ee5\u7528\u6765\u8be2\u95ee\u548c\u63a7\u5236\u7ba1\u7406\u7a0b\u5e8f\u53ca\u5176\u8fd0\u884c\u7684\u7a0b\u5e8f\u3002<\/p>\n

\u4e8c\u3001\u5b89\u88c5\u914d\u7f6e\u6b65\u9aa4<\/strong><\/div>\n
1\u3001 \u6267\u884c\u5b89\u88c5\u547d\u4ee4<\/strong><\/span><\/div>\n
yum install supervisor \uff1a<\/pre>\n

\"\"<\/p>\n

2\u3001\u56de\u8f66\u7ee7\u7eed<\/strong><\/span><\/div>\n

\u8f93\u5165 y \u56de\u8f66\u7ee7\u7eed\uff1a
\n\"\"<\/p>\n

3\u3001\u542f\u52a8supervisor\u670d\u52a1<\/strong><\/span><\/div>\n
mkdir \/run\/supervisor\r\nsupervisord -c \/etc\/supervisord.conf<\/pre>\n
4\u3001\u67e5\u770b\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/strong><\/span><\/div>\n
cat \/etc\/supervisord.conf\uff1a<\/pre>\n

\"\"
\n\u8bf4\u660e\u201c\uff1ailes = supervisord.d\/*.ini \u8868\u793a\u4f1a\u52a0\u8f7dsupervisord.d\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709.ini\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

\u4fee\u6539supervisord.conf\u6587\u4ef6\u914d\u7f6eweb\u9875\u9762\u8bbf\u95ee\u914d\u7f6e\u5185\u5bb9\u3002<\/p>\n

[inet_http_server]         ; #\u5f00\u542fweb\u8bbf\u95ee\r\n;port=127.0.0.1:9001        ; # \u8868\u793a\u5185\u7f51\u8bbf\u95ee\r\nport=*:9001                       ;#  \u8868\u793a\u5f00\u542f\u5916\u7f51\u8bbf\u95ee\uff0c\u8981\u6ce8\u610f\u5b89\u5168\u6027\uff0c\u4e0d\u9700\u8981\u5916\u7f51\uff0c\u4e0d\u8981\u542f\u7528 \r\nusername=admin              ; #\u8bbf\u95ee\u670d\u52a1\u7528\u6237\u540d\r\npassword=admin               ; #\u8bbf\u95ee\u670d\u52a1\u5bc6\u7801\r\n<\/pre>\n

\u6ce8\u610f\uff1a\u670d\u52a1\u5668\u8981\u5f00\u653e9001\u7aef\u53e3\u8bbf\u95ee\uff0c\u624d\u53ef\u4ee5\u6d4f\u89c8\u5668\u8bbf\u95ee\u3002<\/p>\n

cd \/etc\/supervisord.d  #\u8fdb\u5165ini\u6587\u4ef6\u5939\u3002<\/pre>\n
5\u3001\u521b\u5efa\u5b88\u62a4nginx\u8fdb\u7a0b\u914d\u7f6e\u6587\u4ef6 nginx.ini<\/strong><\/span><\/div>\n
[program:nginx]\r\ncommand=\/usr\/.\/sbin\/nginx -g 'daemon off;'  user=root                                               \r\nautostart=false                                       \r\nautorestart=true                                     \r\nstopasgroup=true                                        \r\nkillasgroup=true                                        \r\nstdout_logfile=\/etc\/supervisord.d\/nginx-out.log         \r\nstderr_logfile=\/etc\/supervisord.d\/nginx-err.log\r\n<\/pre>\n

\u6ce8\u610f\uff1a\u8981\u6839\u636e\u81ea\u5df1\u670d\u52a1\u5668\u5b89\u88c5\u7684nginx\u8def\u5f84\u4e3a\u51c6\u6765\u914d\u7f6enginx.ini \u6587\u4ef6\u3002<\/p>\n

6\u3001\u6dfb\u52a0\u914d\u7f6e\u6587\u4ef6\u540e\u91cd\u542f<\/strong><\/span><\/div>\n
supervisorctl # \u8fdb\u5165 supervisor\u63a7\u5236\u53f0\r\n admin  #\u8f93\u5165\u7528\u6237\u540d\r\n admin    #\u8f93\u5165\u5bc6\u7801\r\n reload   # \u91cd\u542f\u547d\u4ee4<\/pre>\n

\"\"<\/p>\n

7\u3001\u505c\u6b62\u6389\u81ea\u5df1\u670d\u52a1\u5668\u8fd0\u884c\u7684nginx\uff0c\u4f7f\u7528Supervisor \u8fdb\u884c\u7ba1\u7406<\/strong><\/span><\/div>\n
cd \/usr\/sbin\r\n.\/nginx -s stop\r\n\u8bbf\u95ee\u5730\u5740\uff1a http:\/\/127.0.0.1:9001\/\r\n<\/pre>\n

\u8bbf\u95ee\u4e3b\u9875\u9762\u5982\u4e0b\uff1a
\n\"\"
\n\u542f\u52a8nginx\uff1a
\n\"\"
\nnginx\u5982\u679c\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u8868\u793a\u5b89\u88c5\u6210\u529f\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4eca\u5929\u7ed9\u5927\u5bb6\u5206\u4eabCentos8\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u5982\u4f55\u5b89\u88c5supervisor\u8fdb\u7a0b\u7ba1\u7406\u7a0b\u5e8f\u5e76\u5b88\u62a4Nginx\u8fdb\u7a0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6 […]<\/p>\n","protected":false},"author":1469,"featured_media":248750,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-248741","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/248741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1469"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=248741"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/248741\/revisions"}],"predecessor-version":[{"id":248751,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/248741\/revisions\/248751"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/248750"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=248741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=248741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=248741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}