{"title":"정적 파일을 배포하는 방법","version":"6.1","locale":"ko","docname":"howto/static-files/deployment","url":"/ko/6.1/howto/static-files/deployment/","canonical":"https://djangodocs.dev/ko/6.1/howto/static-files/deployment/","summary":"더 보기 :mod:’django.contrib.static files’의 사용에 대한 자세한 내용은 :doc:’/how to/static files/index’를 참조하십시오. 프로덕션에서 정적파일 제공하기 Link to this heading # 정적 파일을 프로덕션에 배포하는 기본 과정은…","html":"<h1>정적 파일을 배포하는 방법<a class=\"heading-anchor\" href=\"#how-to-deploy-static-files\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<aside class=\"admonition admonition-seealso\">\n<p class=\"admonition-title\">더 보기</p>\n<p>:mod:’django.contrib.static files’의 사용에 대한 자세한 내용은 :doc:’/how to/static files/index’를 참조하십시오.</p>\n</aside>\n<section id=\"serving-static-files-in-production\">\n<span id=\"staticfiles-production\"></span><h2>프로덕션에서 정적파일 제공하기<a class=\"heading-anchor\" href=\"#serving-static-files-in-production\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>정적 파일을 프로덕션에 배포하는 기본 과정은 두 가지 단계로 구성됩니다. 정적 파일이 변경되면 <a class=\"reference internal\" href=\"/ko/6.1/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a> 명령을 실행한 다음, 수집된 정적 파일 디렉토리(<a class=\"reference internal\" href=\"/ko/6.1/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_ROOT</span></code></a>)가 정적 파일 서버로 이동되어 제공되도록 구성합니다. <code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> <a class=\"reference internal\" href=\"/ko/6.1/ref/settings/#std-setting-STORAGES\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STORAGES</span></code></a> 별칭에 따라 파일을 수동으로 새 위치에 이동시켜야 할 수도 있고 <code class=\"docutils literal notranslate\"><span class=\"pre\">Storage</span></code> 클래스의 <a class=\"reference internal\" href=\"/ko/6.1/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.StaticFilesStorage.post_process\" title=\"django.contrib.staticfiles.storage.StaticFilesStorage.post_process\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">post_process</span></code></a> 메서드가 이를 처리할 수도 있습니다.</p>\n<p>모든 배포 작업과 마찬가지로 세부 사항도 중요합니다. 모든 프로덕션 설정은 약간 다르므로 필요에 맞게 기본 개요를 조정해야 합니다. 다음은 도움이 될 수 있는 몇 가지 일반적인 패턴입니다.</p>\n<section id=\"serving-the-site-and-your-static-files-from-the-same-server\">\n<h3>같은 서버에서 정적파일과 사이트를 제공하기<a class=\"heading-anchor\" href=\"#serving-the-site-and-your-static-files-from-the-same-server\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>사이트에 이미 서비스를 제공하고 있는 서버와 동일한 서버에서 정적 파일을 제공하려는 경우 프로세스는 다음과 같을 수 있습니다.</p>\n<ul class=\"simple\">\n<li><p>개발서버로 코드 올리기</p></li>\n<li><p>서버에서 :djadmin:’collectstatic’을 실행하여 모든 정적 파일을 :seting:’에 복사합니다.STATIC_ROOT’입니다.</p></li>\n<li><p>:seting:’에서 파일을 서비스하도록 웹 서버를 구성합니다.URL의 STATIC_ROOT’ 아래에 있습니다. 설정:’:’STATIC_URL’입니다. 예를 들어 다음과 같습니다.Apache 및 mod_wsgi로 이 작업을 수행하는 방법입니다.</p></li>\n</ul>\n<p>특히 웹 서버가 여러 개인 경우 이 프로세스를 자동화할 수 있습니다.</p>\n</section>\n<section id=\"serving-static-files-from-a-dedicated-server\">\n<h3>특정 서버에서 정적파일 제공하기<a class=\"heading-anchor\" href=\"#serving-static-files-from-a-dedicated-server\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>대부분의 대형 Django 사이트에서는 정적 파일을 처리하기 위해 별도의 웹 서버(예: Django를 실행하지 않는 서버)를 사용합니다. 이 서버는 종종 다른 유형의 웹 서버를 실행하며 속도는 빠르지만 기능은 부족합니다. 일반적인 선택은 다음과 같습니다:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference external\" href=\"https://nginx.org/en/\">Nginx</a></p></li>\n<li><p>Apache_의 stripped-down 버전</p></li>\n</ul>\n<p>이 서버 구성은 이 문서의 범위를 벗어납니다. 각 서버의 해당 문서에서 지침을 확인하십시오.</p>\n<p>정적 파일 서버가 Django를 실행하지 않으므로 다음과 같이 배포 전략을 수정해야 합니다.</p>\n<ul class=\"simple\">\n<li><p>정적 파일이 수정되었다면, 로컬에서 <a class=\"reference internal\" href=\"/ko/6.1/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a> 를 실행하세요.</p></li>\n<li><p>로컬:설정:’를 누릅니다.STATIC_ROOT’을(를) 정적 파일 서버에 올려서 서비스 중인 디렉토리에 넣습니다. ‘rsync <a class=\"reference external\" href=\"https://rsync.samba.org/\">https://rsync.samba.org/</a>’_은(는) 변경된 정적 파일의 비트만 전송하면 되기 때문에 이 단계에서 흔히 선택할 수 있습니다.</p></li>\n</ul>\n</section>\n<section id=\"serving-static-files-from-a-cloud-service-or-cdn\">\n<span id=\"staticfiles-from-cdn\"></span><h3>클라우드 서비스나 CDN으로 정적 파일 제공하기<a class=\"heading-anchor\" href=\"#serving-static-files-from-a-cloud-service-or-cdn\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>또 다른 일반적인 방법은 Amazon의 S3 및/또는 CDN(컨텐츠 제공 네트워크)과 같은 클라우드 스토리지 공급업체의 정적 파일을 제공하는 것입니다. 이렇게 하면 정적 파일 서비스 문제를 무시할 수 있으며 웹 페이지를 더 빨리 로드할 수 있습니다(특히 CDN 사용 시).</p>\n<p>이러한 서비스를 사용할 때 기본 워크플로우는 위와 약간 비슷하지만 서버에 정적 파일을 전송하기 위해 “rsync”를 사용하는 대신 정적 파일을 스토리지 공급자 또는 CDN으로 전송해야 한다는 점을 제외하면 그렇습니다.</p>\n<p>방법은 여러 가지가 있지만 제공업체에 API가 있는 경우 :doc:<a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>custom file storage backend &lt;/howto/custom-file-storage&gt;`를 사용하여 Django 프로젝트와 CDN을 통합할 수 있습니다. 제3자 사용자 정의 스토리지 백엔드를 작성했거나 사용 중이라면 :setting:<a href=\"#id3\"><span class=\"problematic\" id=\"id4\">`</span></a>STORAGES`에서 <a href=\"#id5\"><span class=\"problematic\" id=\"id6\">``</span></a>staticfiles``를 설정하여 :djadmin:<a href=\"#id7\"><span class=\"problematic\" id=\"id8\">`</span></a>collectstatic`이 이를 사용하도록 지정할 수 있습니다.</p>\n<p>예를 들어 “myproject.storage”에 S3 스토리지 백엔드를 작성한 경우입니다.S3Storage는 다음과 같은 용도로 사용할 수 있습니다.</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">STORAGES</span> <span class=\"o\">=</span> <span class=\"p\">{</span>\n    <span class=\"c1\"># ...</span>\n    <span class=\"s2\">&quot;staticfiles&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span><span class=\"s2\">&quot;BACKEND&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;myproject.storage.S3Storage&quot;</span><span class=\"p\">}</span>\n<span class=\"p\">}</span>\n</code></pre></div>\n<p>작업이 완료되면 <code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic`을</span> <span class=\"pre\">실행하기만</span> <span class=\"pre\">하면</span> <span class=\"pre\">됩니다.</span> <span class=\"pre\">그러면</span> <span class=\"pre\">정적</span> <span class=\"pre\">파일이</span> <span class=\"pre\">스토리지</span> <span class=\"pre\">패키지를</span> <span class=\"pre\">통해</span> <span class=\"pre\">S3로</span> <span class=\"pre\">업로드됩니다.</span> <span class=\"pre\">나중에</span> <span class=\"pre\">다른</span> <span class=\"pre\">스토리지</span> <span class=\"pre\">제공업체로</span> <span class=\"pre\">전환해야</span> <span class=\"pre\">하는</span> <span class=\"pre\">경우</span> <span class=\"pre\">:setting:`STORAGES</span></code> 설정에서 <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">``</span></a>staticfiles``만 변경하면 됩니다.</p>\n<p>백엔드를 작성하는 방법에 대한 자세한 내용은:doc:’/how to/custom-file-storage’를 참조하십시오. 많은 공통 파일 스토리지 API에 대한 스토리지 백엔드를 제공하는 타사 앱이 있습니다. 좋은 출발점이 바로 djangopackages.org입니다.</p>\n</section>\n</section>\n<section id=\"learn-more\">\n<h2>추가사항<a class=\"heading-anchor\" href=\"#learn-more\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>:mod:’django.contrib.static files’에 포함된 모든 설정, 명령, 템플릿 태그 및 기타 항목에 대한 자세한 내용은 :doc:’static files reference’를 참조하십시오.</p>\n</section>","rootId":"how-to-deploy-static-files","toc":[{"title":"프로덕션에서 정적파일 제공하기","anchor":"serving-static-files-in-production","children":[{"title":"같은 서버에서 정적파일과 사이트를 제공하기","anchor":"serving-the-site-and-your-static-files-from-the-same-server","children":[]},{"title":"특정 서버에서 정적파일 제공하기","anchor":"serving-static-files-from-a-dedicated-server","children":[]},{"title":"클라우드 서비스나 CDN으로 정적 파일 제공하기","anchor":"serving-static-files-from-a-cloud-service-or-cdn","children":[]}]},{"title":"추가사항","anchor":"learn-more","children":[]}],"breadcrumbs":[{"docname":"howto/index","title":"How-to 가이드","url":"/ko/6.1/howto/"}],"prev":{"docname":"howto/deployment/checklist","title":"배포 전 체크리스트","url":"/ko/6.1/howto/deployment/checklist/"},"next":{"docname":"howto/auth-remote-user","title":"“REMOTE_USER”를 이용해 인증하는 방법","url":"/ko/6.1/howto/auth-remote-user/"},"formats":{"html":"/ko/6.1/howto/static-files/deployment/","markdown":"/ko/6.1/howto/static-files/deployment.md","json":"/ko/6.1/howto/static-files/deployment.json"},"source":"https://github.com/django/django/blob/stable/6.1.x/docs/howto/static-files/deployment.txt","official":"https://docs.djangoproject.com/ko/6.1/howto/static-files/deployment/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}