{"id":689,"date":"2019-01-08T13:45:11","date_gmt":"2019-01-08T04:45:11","guid":{"rendered":"https:\/\/dong1lkim.oboki.net\/?p=689"},"modified":"2019-09-01T22:23:32","modified_gmt":"2019-09-01T13:23:32","slug":"flask-wsgi%eb%a5%bc-%ec%9d%b4%ec%9a%a9%ed%95%9c-apache-httpd-%ec%97%b0%eb%8f%99","status":"publish","type":"post","link":"https:\/\/oboki.net\/workspace\/python\/flask\/flask-wsgi%eb%a5%bc-%ec%9d%b4%ec%9a%a9%ed%95%9c-apache-httpd-%ec%97%b0%eb%8f%99\/","title":{"rendered":"[Python] Flask &#8211; wsgi\ub97c \uc774\uc6a9\ud55c Apache httpd \uc5f0\ub3d9"},"content":{"rendered":"<h1>wsgi\ub97c \uc774\uc6a9\ud55c Apache httpd \uc5f0\ub3d9<\/h1>\n<p><code>wsgi<\/code>\ub97c \uc774\uc6a9\ud574\uc11c apache httpd \uc6f9\uc11c\ubc84\uac00 flask application \uc744 \uc11c\ube44\uc2a4\ud560 \uc218 \uc788\ub2e4. python \ud504\ub85c\uc138\uc2a4 \ub2e8\uc704\ub85c \uc2e4\ud589\uc2dc\ud0ac \uc218\ub3c4 \uc788\uc9c0\ub9cc, ssl \ubcf4\uc548 \uc5f0\uacb0\uc774\ub098 \uac00\uc0c1 \ud638\uc2a4\ud2b8 \uc0ac\uc6a9 \ub4f1 httpd \uc5d0 \uc5b9\uc5b4\uc11c \uc4f0\uba74 \uad00\ub9ac \ucc28\uc6d0\uc5d0\uc11c httpd \uc5d0 \uc5b9\uc5b4 \uc4f0\ub294\uac8c \uc88b\uc744 \ub4ef \ud558\ub2e4.<\/p>\n<h2>\ud328\ud0a4\uc9c0 \uc124\uce58<\/h2>\n<p>\ud06c\uac8c \ubc84\uc804\uc744 \ud0c0\uc9c0 \uc54a\ub294 \ub77c\uc774\ube0c\ub7ec\ub9ac\ub4e4\uc740 yum \uc744 \uc774\uc6a9\ud574\uc11c \uc124\uce58 \ud558\uace0, apache httpd, python \ub4f1 \uc790\uccb4\uc801\uc73c\ub85c \ubc84\uc804\uad00\ub9ac\ub97c \ud558\uace0\uc790 \ud558\ub294 \ud504\ub85c\uadf8\ub7a8\ub4e4\uc740 <code>\/apps<\/code> \uacbd\ub85c \ud558\uc704\uc5d0 \uc124\uce58\ud55c\ub2e4.<\/p>\n<h3>apache \uc124\uce58<\/h3>\n<pre><code class=\"bash\">yum -y install apr-util-devel pcre-devel openssl-devel\nwget http:\/\/mirror.apache-kr.org\/\/httpd\/httpd-2.4.37.tar.gz\ntar -xvzf httpd-2.4.37.tar.gz -C \/src\/.\ncd \/src\/httpd-2.4.37\n.\/configure --prefix=\/apps\/httpd\/2.4.37 --enable-module=so --enable-so --enable-mods-shared=ssl --enable-ssl-shared --enable-rewrite\nmake &amp;&amp; make install\nln -s \/apps\/httpd\/2.4.37 \/apps\/httpd\/.\n<\/code><\/pre>\n<h3>wsgi \uc124\uce58<\/h3>\n<p>httpd \uc758 \ube4c\ub4dc \ub3c4\uad6c\uc778 <code>apxs<\/code>\ub97c \uc774\uc6a9\ud574\uc11c \ubaa8\ub4c8\uc744 \uc124\uce58\ud55c\ub2e4.<\/p>\n<pre><code class=\"bash\">wget https:\/\/github.com\/GrahamDumpleton\/mod_wsgi\/archive\/4.6.5.tar.gz\ntar -xvzf 4.6.5.tar.gz -C \/src\/.\ncd \/src\/4.6.5\n.\/configure --with-apxs=\/apps\/httpd\/bin\/apxs --with-python=\/apps\/python\/bin\/python\nmake &amp;&amp; make install\n<\/code><\/pre>\n<p>\uc815\uc0c1\uc801\uc73c\ub85c wsgi \ubaa8\ub4c8 \uc124\uce58\uac00 \uc644\ub8cc\ub418\uba74, <code>\/apps\/httpd\/modules<\/code> \uacbd\ub85c\uc5d0 <code>mod_wsgi.so<\/code> \ub77c\uc774\ube0c\ub7ec\ub9ac\uac00 \uc0dd\uc131\ub41c\ub2e4.<\/p>\n<h2>wsgi \uc124\uc815<\/h2>\n<h3>httpd.conf \uc124\uc815<\/h3>\n<p><code>vi httpd.conf<\/code><\/p>\n<pre><code class=\"conf\">## mod_wsgi \ubaa8\ub4c8 \ubd88\ub7ec\uc624\uae30\nLoadModule wsgi_module modules\/mod_wsgi.so\n\n&lt;IfModule wsgi_module&gt;\n## \uc6f9\uc11c\ube44\uc2a4 \"\/\" \uacbd\ub85c\uc5d0 wsgi \uc778\ud130\ud398\uc774\uc2a4 \uacbd\ub85c \uc9c0\uc815\nWSGIScriptAlias \/ \/apps\/python\/src\/flask\/httpd.wsgi\n## Python app \ud504\ub85c\uc138\uc2a4 \uc2e4\ud589 \ud658\uacbd \uc124\uc815\nWSGIDaemonProcess app user=python group=apps threads=1\n&lt;\/IfModule&gt;\n\n## Python app \uc11c\ube44\uc2a4\ub97c \uc704\ud55c app source \uacbd\ub85c \uad8c\ud55c \uc124\uc815\n&lt;Directory \"\/apps\/python\/src\"&gt;\n    Options Indexes FollowSymLinks\n    AllowOverride None\n    Require all granted\n&lt;\/Directory&gt;\n\n&lt;Directory \/apps\/python\/src\/flask&gt;\n    WSGIApplicationGroup %{GLOBAL}\n    Order deny,allow\n    Allow from all\n&lt;\/Directory&gt;\n<\/code><\/pre>\n<h3>httpd.wsgi \uc124\uc815<\/h3>\n<p><code>vi \/apps\/python\/src\/flask\/httpd.wsgi<\/code><\/p>\n<pre><code class=\"py\">import sys\nsys.path.insert(0, '\/apps\/python\/src\/flask')\n## \uc2e4\uc81c \uc2e4\ud589\uc2dc\ud0a4\uace0\uc790 \ud558\ub294 application \uc740 \uc544\ub798 app \uc18c\uc2a4\uc5d0 \ub4e4\uc5b4\uc788\uace0 \ud604\uc7ac httpd.wsgi \ud30c\uc77c\uc740 \uadf8\uc800 \uac8c\uc774\ud2b8\uc6e8\uc774 \uc5ed\ud560\nfrom app import App as application\n<\/code><\/pre>\n<h2>app \uc791\uc131 \ubc0f \uc2e4\ud589<\/h2>\n<h3>app.py<\/h3>\n<p>\uc544\ub798\uc640 \uac19\uc774 \uac04\ub2e8\ud558\uac8c &quot;\/&quot; \ubc0f &quot;\/test&quot; \uacbd\ub85c \uc694\uccad\uc5d0 \ub300\ud55c \uc751\ub2f5\uc744 \uc8fc\ub294 application \uc744 \uc791\uc131\ud55c\ub2e4.<\/p>\n<p><code>vi \/apps\/python\/src\/flask\/app.py<\/code><\/p>\n<pre><code class=\"py\">import flask\n\nApp = flask.Flask(__name__)\nApp.config[\"DEBUG\"] = True\n\n@App.route('\/', methods=['GET',])\ndef index():\n    return \"&lt;html&gt;&lt;body&gt;&lt;h1&gt;It works!&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;\"\n\n@App.route('\/test', methods=['GET',])\ndef test():\n    return \"&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello World!&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;\"\n<\/code><\/pre>\n<h3>httpd \uc2e4\ud589<\/h3>\n<pre><code class=\"bash\">export PATH=\/apps\/httpd\/bin:$PATH\nhttpd -k start\n<\/code><\/pre>\n<h3>\uc11c\ube44\uc2a4 \ud655\uc778<\/h3>\n<p>\uc6f9\ube0c\ub77c\uc6b0\uc800\uc5d0\uc11c <code>$HOSTNAME<\/code>, <code>$HOSTNAME\/test<\/code> \uacbd\ub85c\uc5d0 \uc811\uadfc\ud574\ubcf4\uba74 \uc544\ub798\uc640 \uac19\uc774 \uc6f9 \uc11c\ube44\uc2a4\uac00 \ub3d9\uc791\ud558\uace0 \uc788\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n<p><img decoding=\"async\" src=\"\/workspace\/wp-content\/uploads\/2019\/01\/wsgi.png\" alt=\"index\" \/><br \/>\n<img decoding=\"async\" src=\"\/workspace\/wp-content\/uploads\/2019\/01\/wsgi_test.png\" alt=\"index\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>wsgi\ub97c \uc774\uc6a9\ud55c Apache httpd \uc5f0\ub3d9 wsgi\ub97c \uc774\uc6a9\ud574\uc11c apache httpd \uc6f9\uc11c\ubc84\uac00 flask application \uc744 \uc11c\ube44\uc2a4\ud560 \uc218 \uc788\ub2e4. python \ud504\ub85c\uc138\uc2a4 \ub2e8\uc704\ub85c \uc2e4\ud589\uc2dc\ud0ac \uc218\ub3c4 \uc788\uc9c0\ub9cc, ssl \ubcf4\uc548 \uc5f0\uacb0\uc774\ub098 \uac00\uc0c1 \ud638\uc2a4\ud2b8 \uc0ac\uc6a9 \ub4f1 httpd \uc5d0 \uc5b9\uc5b4\uc11c \uc4f0\uba74 \uad00\ub9ac \ucc28\uc6d0\uc5d0\uc11c httpd \uc5d0 \uc5b9\uc5b4 \uc4f0\ub294\uac8c \uc88b\uc744 \ub4ef \ud558\ub2e4. \ud328\ud0a4\uc9c0 \uc124\uce58 \ud06c\uac8c \ubc84\uc804\uc744 \ud0c0\uc9c0 \uc54a\ub294 \ub77c\uc774\ube0c\ub7ec\ub9ac\ub4e4\uc740 yum \uc744 \uc774\uc6a9\ud574\uc11c \uc124\uce58 \ud558\uace0, apache [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[41,117,34,59,104],"class_list":["post-689","post","type-post","status-publish","format-standard","hentry","category-flask","tag-flask","tag-httpd","tag-python","tag-wsgi","tag-104"],"_links":{"self":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/689","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/comments?post=689"}],"version-history":[{"count":4,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/689\/revisions"}],"predecessor-version":[{"id":1367,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/posts\/689\/revisions\/1367"}],"wp:attachment":[{"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/media?parent=689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/categories?post=689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oboki.net\/workspace\/wp-json\/wp\/v2\/tags?post=689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}