{"id":68,"date":"2024-12-04T04:13:04","date_gmt":"2024-12-04T04:13:04","guid":{"rendered":"http:\/\/211.230.203.47\/wordpress\/?p=68"},"modified":"2024-12-04T04:13:04","modified_gmt":"2024-12-04T04:13:04","slug":"%ed%8c%8c%ec%9d%b4%ec%8d%ac%ea%b3%bc-%ec%95%84%ed%8c%8c%ec%b9%98-%ec%97%b0%eb%8f%99%ed%95%98%eb%8a%94-%eb%b0%a9%eb%b2%95%ec%9d%80","status":"publish","type":"post","link":"https:\/\/www.soon7shop.kr\/wordpress\/?p=68","title":{"rendered":"\ud30c\uc774\uc36c\uacfc \uc544\ud30c\uce58 \uc5f0\ub3d9\ud558\ub294 \ubc29\ubc95\uc740?"},"content":{"rendered":"<p>Python\uacfc Apache HTTP \uc11c\ubc84\ub97c \uc5f0\ub3d9\ud558\uc5ec \uc6f9 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ubc30\ud3ec\ud558\ub294 \ubc29\ubc95\uc73c\ub85c\ub294 <strong>WSGI(Web Server Gateway Interface)<\/strong> \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc774 \uc77c\ubc18\uc801\uc785\ub2c8\ub2e4. Apache\uc5d0\uc11c\ub294 <strong>mod_wsgi<\/strong> \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud558\uc5ec Python \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc2e4\ud589\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc5ec\uae30\uc11c\ub294 Python Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 Apache \uc11c\ubc84\uc640 \uc5f0\ub3d9\ud558\ub294 \uacfc\uc815\uc744 \uc124\uba85\ud558 \uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<h3>1. \ud658\uacbd \uc900\ube44<\/h3>\n<ul>\n<li><strong>Python<\/strong>\uc774 \uc124\uce58\ub418\uc5b4 \uc788\uc5b4\uc57c \ud558\uace0, Flask \uac19\uc740 <strong>Python \uc6f9 \ud504\ub808\uc784\uc6cc\ud06c<\/strong>\uac00 \ud544\uc694\ud569\ub2c8\ub2e4.<\/li>\n<li><strong>Apache<\/strong> \uc11c\ubc84\uac00 \uc124\uce58\ub418\uc5b4 \uc788\uc5b4\uc57c \ud558\uba70, Apache\uc5d0 <code>mod_wsgi<\/code> \ubaa8\ub4c8\uc744 \ucd94\uac00\ub85c \uc124\uce58\ud574\uc57c \ud569\ub2c8\ub2e4.<\/li>\n<\/ul>\n<h3>2. mod_wsgi \uc124\uce58<\/h3>\n<p>\uba3c\uc800 mod_wsgi\ub97c \uc124\uce58\ud569\ub2c8\ub2e4. Ubuntu\ub97c \uc0ac\uc6a9\ud558\uace0 \uc788\ub2e4\uba74, \ub2e4\uc74c \uba85\ub839\uc5b4\ub85c \uc124\uce58\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-bash\">sudo apt-get update<br \/>\nsudo apt-get install libapache2-mod-wsgi-py3<br \/>\n<\/code><\/div>\n<\/div>\n<p>\uc124\uce58\uac00 \uc644\ub8cc\ub418\uba74 Apache \uc11c\ubc84\uc5d0 <code>mod_wsgi<\/code>\uac00 \ucd94\uac00\ub429\ub2c8\ub2e4.<\/p>\n<h3>3. Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \uc900\ube44<\/h3>\n<p>Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc900\ube44\ud569\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, <code>my_flask_app<\/code>\uc774\ub77c\ub294 Flask \ud504\ub85c\uc81d\ud2b8 \ub514\ub809\ud1a0\ub9ac \uc548\uc5d0 <code>app.py<\/code> \ud30c\uc77c\uc744 \uc0dd\uc131\ud558\uc5ec \uae30\ubcf8\uc801\uc778 Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc791\uc131\ud569\ub2c8\ub2e4.<\/p>\n<h4>\ub514\ub809\ud1a0\ub9ac \uad6c\uc870<\/h4>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\"><\/div>\n<h4><code>my_flask_app\/<br \/>\n\u251c\u2500\u2500 app.py # Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \uba54\uc778 \ud30c\uc77c<br \/>\n\u251c\u2500\u2500 myapp.wsgi # WSGI \ud30c\uc77c (Apache\uac00 Flask \uc571\uc744 \uc778\uc2dd\ud558\ub3c4\ub85d \ud568)<br \/>\n\u2514\u2500\u2500 templates\/ # HTML \ud30c\uc77c\ub4e4\uc774 \uc800\uc7a5\ub418\ub294 \ud3f4\ub354<br \/>\n\u2514\u2500\u2500 index.html<\/p>\n<p><\/code><\/h4>\n<h4><code>p.py<\/code> \uc608\uc81c<\/h4>\n<p>from flask import Flask<\/p>\n<p>app = Flask(__name__)<\/p>\n<p>@app.route(&#8216;\/&#8217;)<br \/>\ndef hello():<br \/>\nreturn &#8220;Hello, World! This is served by Apache and Flask.&#8221;<\/p>\n<p>if __name__ == &#8220;__main__&#8221;:<br \/>\napp.run()<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-python\"><br \/>\n<\/code><\/div>\n<\/div>\n<h3>4. WSGI \ud30c\uc77c \uc0dd\uc131 (<code>myapp.wsgi<\/code>)<\/h3>\n<p>Apache \uc11c\ubc84\uac00 Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc778\uc2dd\ud560 \uc218 \uc788\ub3c4\ub85d WSGI \ud30c\uc77c\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4. <code>my_flask_app<\/code> \ub514\ub809\ud1a0\ub9ac \ub0b4\uc5d0 <code>myapp.wsgi<\/code> \ud30c\uc77c\uc744 \uc791\uc131\ud569\ub2c8\ub2e4.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\"><\/div>\n<p>import sys<br \/>\nimport os<br \/>\nfrom app import app as application<\/p>\n<p># \uc560\ud50c\ub9ac\ucf00\uc774\uc158 \uacbd\ub85c \uc124\uc815<br \/>\nsys.path.insert(0, os.path.dirname(__file__))<\/p>\n<h3>5. Apache \uc124\uc815 \ud30c\uc77c \uc218\uc815<\/h3>\n<p>Apache \uc124\uc815 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uc5ec Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc11c\ube44\uc2a4\ud558\ub3c4\ub85d \uc124\uc815\ud569\ub2c8\ub2e4. \uc774 \uc124\uc815 \ud30c\uc77c\uc740 \ubcf4\ud1b5 <code>\/etc\/apache2\/sites-available\/000-default.conf<\/code> \ub610\ub294 \uc0c8\ub85c \uad6c\uc131\ud55c VirtualHost \ud30c\uc77c\uc785\ub2c8\ub2e4.<\/p>\n<h4>Apache \uc124\uc815 \uc608\uc2dc<\/h4>\n<p>Apache \uc124\uc815 \ud30c\uc77c\uc5d0 \ub2e4\uc74c\uacfc \uac19\uc740 \uad6c\uc131\uc744 \ucd94\uac00\ud569\ub2c8\ub2e4.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\"><\/div>\n<p>&lt;VirtualHost *:80&gt;<br \/>\nServerName myflaskapp.com # \ub3c4\uba54\uc778 \uc774\ub984 (\ub610\ub294 IP \uc8fc\uc18c)<\/p>\n<p>WSGIDaemonProcess myapp python-path=\/path\/to\/my_flask_app python-home=\/path\/to\/venv<br \/>\nWSGIScriptAlias \/ \/path\/to\/my_flask_app\/myapp.wsgi<\/p>\n<p>&lt;Directory \/path\/to\/my_flask_app&gt;<br \/>\nRequire all granted<br \/>\n&lt;\/Directory&gt;<\/p>\n<p>ErrorLog ${APACHE_LOG_DIR}\/error.log<br \/>\nCustomLog ${APACHE_LOG_DIR}\/access.log combined<br \/>\n&lt;\/VirtualHost&gt;<\/p>\n<ul>\n<li><strong>WSGIDaemonProcess<\/strong>: <code>python-path<\/code>\ub294 Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc774 \uc788\ub294 \uacbd\ub85c\ub97c \uc9c0\uc815\ud558\uace0, <code>python-home<\/code>\uc740 Python \uac00\uc0c1 \ud658\uacbd \uacbd\ub85c\ub97c \uc9c0\uc815\ud569\ub2c8\ub2e4.<\/li>\n<li><strong>WSGIScriptAlias<\/strong>: Apache\uac00 \uc694\uccad\uc744 <code>myapp.wsgi<\/code> \ud30c\uc77c\ub85c \uc804\ub2ec\ud558\ub3c4\ub85d \uc124\uc815\ud569\ub2c8\ub2e4.<\/li>\n<\/ul>\n<h3>6. Apache \uc11c\ubc84 \uc7ac\uc2dc\uc791<\/h3>\n<p>\uc124\uc815 \ud30c\uc77c\uc744 \uc800\uc7a5\ud55c \ud6c4, Apache \uc11c\ubc84\ub97c \uc7ac\uc2dc\uc791\ud558\uc5ec \ubcc0\uacbd\uc0ac\ud56d\uc744 \uc801\uc6a9\ud569\ub2c8\ub2e4.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">bash<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs language-bash\">sudo service apache2 restart<br \/>\n<\/code><\/div>\n<\/div>\n<h3>7. \uc811\uc18d \ud655\uc778<\/h3>\n<p>\uc6f9 \ube0c\ub77c\uc6b0\uc800\uc5d0\uc11c <code>http:\/\/your-domain.com<\/code> \ub610\ub294 <code>http:\/\/your-server-ip<\/code>\ub85c \uc811\uc18d\ud558\uc5ec Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc774 \uc815\uc0c1\uc801\uc73c\ub85c Apache\ub97c \ud1b5\ud574 \uc11c\ube44\uc2a4\ub418\ub294\uc9c0 \ud655\uc778\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc774 \uacfc\uc815\uc774 \uc644\ub8cc\ub418\uba74 Apache \uc11c\ubc84\uc640 Python Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc774 \uc5f0\ub3d9\ub418\uc5b4, Apache\ub97c \ud1b5\ud574 Python \uc6f9 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc11c\ube44\uc2a4\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\uacfc Apache HTTP \uc11c\ubc84\ub97c \uc5f0\ub3d9\ud558\uc5ec \uc6f9 \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ubc30\ud3ec\ud558\ub294 \ubc29\ubc95\uc73c\ub85c\ub294 WSGI(Web Server Gateway Interface) \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc774 \uc77c\ubc18\uc801\uc785\ub2c8\ub2e4. Apache\uc5d0\uc11c\ub294 mod_wsgi \ubaa8\ub4c8\uc744 \uc0ac\uc6a9\ud558\uc5ec Python \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \uc2e4\ud589\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc5ec\uae30\uc11c\ub294 Python Flask \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 Apache \uc11c\ubc84\uc640 \uc5f0\ub3d9\ud558\ub294 \uacfc\uc815\uc744 \uc124\uba85\ud558 \uaca0\uc2b5\ub2c8\ub2e4. 1. \ud658\uacbd \uc900\ube44 Python\uc774 \uc124\uce58\ub418\uc5b4 \uc788\uc5b4\uc57c \ud558\uace0, Flask \uac19\uc740 Python \uc6f9 \ud504\ub808\uc784\uc6cc\ud06c\uac00 \ud544\uc694\ud569\ub2c8\ub2e4. Apache \uc11c\ubc84\uac00 \uc124\uce58\ub418\uc5b4 \uc788\uc5b4\uc57c \ud558\uba70, Apache\uc5d0 &hellip; <a href=\"https:\/\/www.soon7shop.kr\/wordpress\/?p=68\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\ud30c\uc774\uc36c\uacfc \uc544\ud30c\uce58 \uc5f0\ub3d9\ud558\ub294 \ubc29\ubc95\uc740?&#8221;<\/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":[1],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=68"}],"version-history":[{"count":1,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":69,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions\/69"}],"wp:attachment":[{"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.soon7shop.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}