{"id":1143,"date":"2018-07-13T11:36:19","date_gmt":"2018-07-13T03:36:19","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=1143"},"modified":"2018-07-18T09:14:34","modified_gmt":"2018-07-18T01:14:34","slug":"install-apache-and-mod_wsgi","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=1143","title":{"rendered":"Install Apache and mod_wsgi\uff08\u672a\u5b8c\uff09"},"content":{"rendered":"<p>Django\u672c\u8eab\u81ea\u5e26\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684web\u670d\u52a1\u5668\uff0c\u4f46\u662f\u505a\u4e3a\u4ea7\u54c1\u90e8\u7f72\uff0c\u8fd8\u662f\u9700\u8981\u4e00\u4e2a\u66f4\u6210\u719f\u7684web\u670d\u52a1\u5668\u3002<\/p>\n<p>\u5982\u679c\u60f3\u5728Apache\u4e0a\u4f7f\u7528Django\uff0c\u9700\u8981APACHE\u652f\u6301<a href=\"http:\/\/modwsgi.readthedocs.io\/en\/develop\/\">mod_wsgi<\/a>\u6a21\u5757\u3002<\/p>\n<p>mod_wsgi\u5de5\u4f5c\u5728\u4e24\u79cd\u6a21\u5f0f\u4e2d\u7684\u4e00\u79cd\uff1a\u5d4c\u5165\u5f0f\u6a21\u5f0f\u548cdaemon\u6a21\u5f0f\u3002\u5728\u5d4c\u5165\u5f0f\u6a21\u5f0f\u4e2d\uff0cmod_wsgi\u7c7b\u4f3c\u4e8emod_perl\u2014\u2014\u5f53\u670d\u52a1\u542f\u52a8\u65f6\uff0c\u5b83\u5728APACHE\u4e2d\u5d4c\u5165PYTHON\u5e76\u52a0\u8f7dPYTHON\u5230\u5185\u5b58\u4e2d\u3002\u4ee3\u7801\u5728\u6574\u4e2a\u751f\u547d\u5468\u671f\u90fd\u653e\u5728\u5185\u5b58\u4e2d\uff0c\u8fd9\u5f88\u5bb9\u6613\u5bfc\u81f4\u6700\u540e\u5904\u7406\u80fd\u529b\u8d85\u51fa\u670d\u52a1\u5668\u7684\u8fb9\u754c\u3002\u5728daemon\u6a21\u5f0f\u4e2d\uff0cmod_wsgi\u4ea7\u751f\u4e00\u4e2a\u72ec\u7acb\u8fdb\u7a0b\u6765\u5904\u7406\u8bf7\u6c42\u3002daemon\u8fdb\u7a0b\u53ef\u4ee5\u4ee5\u4e0d\u540c\u4e8eweb\u670d\u52a1\u7528\u6237\u7684\u8eab\u4efd\u8fd0\u884c\uff0c\u8fd9\u6837\u53ef\u4ee5\u589e\u52a0\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u3002\u8be5\u8fdb\u7a0b \u53ef\u4ee5\u5728\u4e0d\u91cd\u542fAPACHE\u670d\u52a1\u7684\u60c5\u51b5\u4e0b\u91cd\u65b0\u542f\u52a8\u8fdb\u7a0b\uff0c\u8fd9\u53ef\u4ee5\u66f4\u65e0\u7f1d\u7684\u5237\u65b0\u4ee3\u7801\u5e93\u3002Django\u53ef\u4ee5\u5de5\u4f5c\u5728\u652f\u6301mod_wsgi\u7684apache\u7684\u4efb\u52a1\u7248\u672c\u3002<\/p>\n<p>mod_wsgi\u6709\u4e24\u79cd\u5b89\u88c5\u6a21\u5f0f\uff0c\u4e00\u79cd\u662f\u4f20\u7edf\u7684Apache\u6a21\u5757\u5b89\u88c5\u6a21\u5f0f\u3002\u53e6\u4e00\u79cd\u662f\u4f7f\u7528python\u7684PIP\u6765\u5b89\u88c5\u3002\u5982\u679c\u5e0c\u671b\u5728Docker\u5bb9\u5668\u4e2d\u4f7f\u7528apache\u548cmod_wsgi\uff0c\u90a3\u4e48\u540e\u8005\u662f\u6700\u597d\u7684\u9009\u62e9\u3002<\/p>\n<p>\u5b89\u88c5\u547d\u4ee4\uff1a<br \/>\n<code><br \/>\npip3 install mod_wsgi<br \/>\n<\/code><br \/>\n\u901a\u8fc7\u8be5\u547d\u4ee4\u5b89\u88c5\uff0c\u6211\u9047\u5230\u7684\u95ee\u9898\uff1a<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>\u627e\u5230\u4e0dAPXS\uff1a\u5f88\u591a\u4eba\u5efa\u8bae\u5b89\u88c5httpd-devel\u5305\uff0c\u5176\u5b9e\u6e90\u7801\u5b89\u88c5\u7684\u4eba\u4e0d\u9700\u8981\u8fd9\u6837\uff0c\u4f7f\u7528httpd -l\u67e5\u770bmod_so.c\u6a21\u5757\u662f\u5426\u6302\u8f7d\uff0c\u5df2\u7ecf\u6302\u8f7d\u5c31\u6ca1\u6709\u95ee\u9898\u4e86\u3002\u51fa\u73b0\u627e\u4e0d\u5230APXS\u7684\u539f\u56e0\u5c31\u662f\uff0capache2\u7684bin\u76ee\u5f55\u6ca1\u6709\u52a0\u5165\u5230<span style=\"color: #ff0000;\">$PATH<\/span>\u4e2d\u3002\u7f16\u8f91<span style=\"color: #ff0000;\">\/etc\/profile<\/span>\uff0c\u52a0\u5165apache2\/bin\u76ee\u5f55\u5c31\u53ef\u4ee5\u4e86\u3002<\/li>\n<li>\u56e0\u4e3a\u6211\u628a\u5b89\u88c5\u6587\u4ef6\u653e\u5230\u4e86root\u76ee\u5f55\u4e2d\uff0c\u5728pip3\u5b89\u88c5\u65f6\u8fd8\u9700\u8981\u7528\u5230\u8fd9\u4e2a\u76ee\u5f55\uff0c\u6240\u4ee5\u4ea7\u751f\u4e86\u7b2c\u4e8c\u4e2a\u95ee\u9898\u3002\u89e3\u51b3\u66f4\u7b80\u5355\uff0c\u628aapache2\u7684\u5b89\u88c5\u6e90\u6587\u4ef6\u653e\u5230\u53e6\u4e00\u4e2a\u76ee\u5f55\u4e2d\uff0c\u91cd\u65b0\u7f16\u8bd1\u5b89\u88c5\u4e00\u6b21\u3002<\/li>\n<li>\u7f16\u8bd1\u4e0d\u901a\u8fc7\uff0c\u63d0\u793a\u7684\u4fe1\u606f\u662fgcc\u8fd4\u56de\u72b6\u60011\u3002\u540e\u6765\u628a\u5b89\u88c5\u8fc7\u7a0b\u63d0\u793a\u7684\u5185\u5bb9\u91cd\u5b9a\u5411\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u53c8\u67e5\u770b\u4e86\u4e00\u4e0b\uff0c\u6700\u5f00\u59cb\u6709\u4e00\u4e2a\u8b66\u544a\uff0c\u662f\u8b66\u544apython\u6ca1\u6709\u5171\u4eab\u5e93\u3002\u91cd\u65b0\u7f16\u8bd1python3\uff0c<code>.\/configure --enable-shared<\/code><\/li>\n<li>\u542f\u52a8python3\u65f6\u63d0\u793a\u627e\u4e0d\u5230<span style=\"color: #ff0000;\">libpython3.6m.so.1.0<\/span>\u5171\u4eab\u5e93\u3002\u6709\u7f51\u53cb\u8bf4\u5b89\u88c5\u4e86virtualenv\u540e\u53ef\u80fd\u4f1a\u6709\u8fd9\u4e2a\u95ee\u9898\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u7f16\u8f91vi \/etc\/ld.so.conf\uff0c\u7136\u540e\u628a\u5305\u542blibpython3.6m.so.1.0\u7684\/usr\/local\/lib64\u76ee\u5f55\u6dfb\u52a0\u8fdb\u4e91<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u89e3\u51b3\u4e86\u4ee5\u4e0a\u51e0\u4e2a\u95ee\u9898\u540epip3\u5b89\u88c5\u987a\u5229\u5b8c\u6210\u3002\u53e6\uff1a\u6211\u662f\u5b89\u88c5\u5230virtualenv\u7684\u865a\u62df\u73af\u5883\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Django\u672c\u8eab\u81ea\u5e26\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684web\u670d\u52a1\u5668\uff0c\u4f46\u662f\u505a\u4e3a\u4ea7\u54c1\u90e8\u7f72\uff0c\u8fd8\u662f\u9700\u8981\u4e00\u4e2a\u66f4\u6210\u719f\u7684web\u670d\u52a1\u5668\u3002 \u5982\u679c\u60f3\u5728Apache\u4e0a\u4f7f\u7528Django\uff0c\u9700\u8981APACHE\u652f\u6301&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=1143\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[],"class_list":["post-1143","post","type-post","status-publish","format-standard","hentry","category-django"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/1143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1143"}],"version-history":[{"count":7,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/1143\/revisions"}],"predecessor-version":[{"id":1150,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/1143\/revisions\/1150"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}