{"id":303370,"date":"2020-05-11T15:00:23","date_gmt":"2020-05-11T15:00:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=303370"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=303370","title":{"rendered":"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Debian, Nginx \u0438 Gunicorn \u0434\u043b\u044f Django \u043f\u0440\u043e\u0435\u043a\u0442\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/501414\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/z9\/fb\/jx\/z9fbjxytkq-jcp5yonlmrsdmxiy.png\"\/><\/p>\n<p>  \u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a. <\/p>\n<p>  \u0411\u044b\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439 Debian \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Nginx \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 Django 3.\u0445. \u041f\u0435\u0440\u0435\u0440\u044b\u0432 \u043a\u0443\u0447\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0430\u0439\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f Django-\u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442\u043e \u2014 \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u0435\u0431\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043b\u0438, \u043a\u0442\u043e \u044f. \u042f \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043d\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442, \u043d\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0438\u043c\u0435\u044e IT-\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u042f \u0443\u0447\u0438\u0442\u0435\u043b\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0438. \u041d\u043e \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0443\u0447\u0435\u043d\u0438\u043a\u0430\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043e\u0447\u0435\u043d\u044c \u0434\u0430\u043b\u0451\u043a\u0438\u0435 \u043e\u0442 \u0448\u043a\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0438 \u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u044d\u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 Django. <\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438<\/h2>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 Debian 10, \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 Debian \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e. \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0447\u0438\u0441\u0442\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0437\u0430\u0448\u0451\u043b \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 <b>root <\/b>\u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043b \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. <\/p>\n<pre><code class=\"bash\">apt-get update apt-get install -y sudo htop git curl wget unzip zip gcc build-essential make apt-get install -y tree redis-server nginx  libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-dev python-pil ython3-pil  apt-get install -y python3-lxml libxslt-dev python-libxml2 python-libxslt1 python-dev gnumeric libpq-dev libxml2-dev libxslt1-dev libjpeg-dev libfreetype6-dev libcurl4-openssl-dev supervisor libgdbm-dev libnss3-dev ufw <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u0432\u044b\u0434\u0430\u043b \u043e\u0448\u0438\u0431\u043a\u0443, \u0430 \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u0441\u0451 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 <b>sudo<\/b>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043e\u0433 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code class=\"bash\">adduser username  usermod -aG sudo username <\/code><\/pre>\n<p>  \u0433\u0434\u0435 <b>username <\/b> \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<br \/>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e <b>Python<\/b> \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u044d\u0442\u043e \u0431\u044b\u043b\u0430 <b>3.8.2<\/b>.<\/p>\n<pre><code class=\"bash\">cd \/home\/username curl -O https:\/\/www.python.org\/ftp\/python\/3.8.2\/Python-3.8.2.tar.xz tar -xf Python-3.8.2.tar.xz cd Python-3.8.2 <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c<\/b>                         <\/p>\n<div class=\"spoiler_text\">cd \u2014 \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430, \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 <b>change directory<\/b>;<br \/>  curl \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u043f\u043e URL. \u041c\u044b \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430;<br \/>  tar \u2014 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0441\u043a\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430.  <\/div>\n<\/p><\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 <b>Python<\/b> \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"bash\">.\/configure --enable-optimizations make -j 2 <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Python. \u0417\u0434\u0435\u0441\u044c \u0447\u0438\u0441\u043b\u043e 2, \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <b>nproc<\/b>.<br \/>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443.  <\/p>\n<pre><code class=\"bash\">make altinstall <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e <b>Python<\/b> \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">python3.8 -V <\/code><\/pre>\n<p>  \u041e\u043d\u0430 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044e <b>Python<\/b>.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c <b>pip <\/b>\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043b\u044f <b>Python<\/b>.  <\/p>\n<pre><code class=\"bash\">python3.8 -m pip install -U pip python3.8 -m pip install -U setuptools python3.8 -m pip install pillow python3.8 -m pip install virtualenv <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Django<\/h2>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0432\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <b>\/var\/www<\/b> \u0438 \u0441\u043a\u0430\u0447\u0430\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u043d\u0430 <b>GitHub<\/b>.<\/p>\n<pre><code class=\"bash\">cd \/var\/www sudo git clone LINK_TO_PROJECT <\/code><\/pre>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0440\u0430\u0432\u0430, \u0434\u043b\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u043c <b>\/var\/www<\/b>  <\/p>\n<pre><code class=\"bash\">sudo chown -R www-data:www-data \/var\/www sudo usermod -aG www-data username sudo chmod go-rwx \/var\/www sudo chmod go+x \/var\/www sudo chgrp -R www-data \/var\/www sudo chmod -R go-rwx \/var\/www sudo chmod -R g+rwx \/var\/www <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0434\u043d\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0430 \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u043c \u0438\u0445, \u043d\u043e \u0441\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438\u0445 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u043b\u0438 \u0433\u0440\u0443\u043f\u043f\u0435.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"bash\">cd djangoprojectname\/ virtualenv env source .\/env\/bin\/activate <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0438\u0434\u0430: (env) username@server.<\/p>\n<p>  \u041f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\/\u043e\u0431\u043d\u043e\u0432\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u043d\u0430\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">pip install -U pip pip install -U setuptools pip install -U pillow <\/code><\/pre>\n<p>  \u0421\u0442\u0430\u0432\u0438\u043c Django, Gunicorn \u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f PostgreSQL. <\/p>\n<pre><code class=\"bash\">pip install django gunicorn psycopg2-binary <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0435\u0449\u0451 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0430\u043a\u0435\u0442\u044b, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e summernote \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<pre><code class=\"bash\">pip install django-summernote<\/code><\/pre>\n<p>  \u041c\u044b \u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0431\u0440\u0430\u043d\u0434\u043c\u0430\u0443\u044d\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0440\u0442 8000 (\u0435\u0433\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0435\u0441\u043b\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439, \u0442\u043e \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0435\u0433\u043e):<\/p>\n<pre><code class=\"bash\">sudo ufw allow 8000<\/code><\/pre>\n<p>  \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0433 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">python3.8 manage.py runserver 0.0.0.0:8000<\/code><\/pre>\n<p>  \u0418 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448 \u0441\u0430\u0439\u0442, <b>DOMAIN_NAME:8000<\/b>, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442! \u041d\u043e, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u0435\u0449\u0451 \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e\u0435, \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u0438 \u0442.\u0434.<br \/>  \u0415\u0441\u043b\u0438 \u0443 \u0412\u0430\u0441 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f \u0441\u0430\u0439\u0442, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430) \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u0442\u0443\u0442 \u0432\u0441\u0451 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0435\u043c \u043a\u043b\u0430\u0432\u0438\u0448: <b>CTRL+C<\/b>.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f, \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041b\u0443\u0447\u0448\u0435 \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u0441\u043d\u043e\u0441\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u0434 \u043a\u043e\u0440\u0435\u043d\u044c (\u044f \u0441\u043d\u043e\u0441\u0438\u043b 3 \u0440\u0430\u0437\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0447\u0430\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e, \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u044f \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435).<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 Gunicorn:<\/p>\n<pre><code class=\"bash\">gunicorn --bind 0.0.0.0:8000 MAINAPPNAME.wsgi<\/code><\/pre>\n<p>  <b>MAINAPPNAME <\/b> \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043b\u0435\u0436\u0438\u0442 <b>settings.py<\/b>.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435. <\/p>\n<p>  \u0417\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0435\u043c \u043a\u043b\u0430\u0432\u0438\u0448: C<b>TRL+C<\/b>.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 settings.py<\/h2>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u043d\u0430 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u0435\u0431\u0430\u0433 \u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u044f \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 <b>settings.py<\/b> \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. <\/p>\n<pre><code class=\"python\">DEBUG = False if DEBUG:     ALLOWED_HOSTS = ['*'] else:     ALLOWED_HOSTS = ['HOST IP', 'DOMAIN NAIM', 'localhost'] ... STATIC_URL = '\/static\/' if DEBUG:     STATIC_DIR = os.path.join(BASE_DIR, 'static')     STATICFILES_DIRS = [         STATIC_DIR,         '\/var\/www\/static\/',     ] else:     STATIC_ROOT = os.path.join(BASE_DIR, 'static\/')     STATICFILES_FINDERS = (         'django.contrib.staticfiles.finders.FileSystemFinder',         'django.contrib.staticfiles.finders.AppDirectoriesFinder',     ) MEDIA_URL = '\/media\/' <\/code><\/pre>\n<p>  \u0412 <b>urls.py<\/b> \u044f \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u043a\u0438 \u0438 \u043c\u0435\u0434\u0438\u0430.<\/p>\n<pre><code class=\"python\">if settings.DEBUG:     urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)     urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) <\/code><\/pre>\n<p>  \u042f \u043d\u0435 \u0437\u043d\u0430\u044e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u041d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 DEBUG \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">python3.8 manage.py collectstatic <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u043a\u0438 \u0438 \u0434\u0435\u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">deactivate<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Gunicorn<\/h2>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <\/p>\n<pre><code class=\"bash\">sudo nano \/etc\/systemd\/system\/gunicorn.socket<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0432 \u0444\u0430\u0439\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a:<\/p>\n<pre><code class=\"nginx\">[Unit] Description=gunicorn socket  [Socket] ListenStream=\/run\/gunicorn.sock  [Install] WantedBy=sockets.target<\/code><\/pre>\n<p>  \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0440\u0430\u0437\u0434\u0435\u043b [Unit] \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043e\u043a\u0435\u0442\u0430, \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 [Socket] \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u043a\u0435\u0442\u0430 \u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 [Install] \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u043e\u043a\u0435\u0442\u0430 \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0439 \u0444\u0430\u0439\u043b systemd \u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<pre><code class=\"bash\">sudo nano \/etc\/systemd\/system\/gunicorn.service<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"nginx\">[Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target  [Service] User=username Group=www-data WorkingDirectory=\/var\/www\/djangoprojectname ExecStart=\/var\/www\/djangoprojectname\/env\/bin\/gunicorn \\           --access-logfile - \\           --workers 5 \\           --bind unix:\/run\/gunicorn.sock \\           myproject.wsgi:application  [Install] WantedBy=multi-user.target<\/code><\/pre>\n<p>  \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u0430\u0448\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0432\u0430\u0448\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u041a\u0430\u043a \u043c\u043d\u0435 \u043f\u043e\u044f\u0441\u043d\u0438\u043b\u0438 workers \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a <b>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 * 2 + 1<\/b>.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u043a\u0435\u0442 Gunicorn. <\/p>\n<pre><code class=\"bash\">sudo systemctl start gunicorn.socket sudo systemctl enable gunicorn.socket<\/code><\/pre>\n<p>  \u0418 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<pre><code class=\"bash\">sudo systemctl status gunicorn.socket<\/code><\/pre>\n<p>  \u0414\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435.<\/p>\n<p>  \u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 <b>Q<\/b> \u0434\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u0430 (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0439 \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u043a\u0435).<\/p>\n<pre><code class=\"bash\">file \/run\/gunicorn.sock<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <b>sudo systemctl status gunicorn.socket<\/b> \u0432\u044b\u0434\u0430\u0451\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0438\u043b\u0438 \u0435\u0441\u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <b>file \/run\/gunicorn.sock<\/b> \u0441\u043e\u043e\u0431\u0449\u0438\u0442, \u0447\u0442\u043e \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0430\u0439\u043b gunicorn.sock, \u0442\u043e \u0441\u043e\u043a\u0435\u0442 Gunicorn \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b\u044b \u0441\u043e\u043a\u0435\u0442\u0430 Gunicorn \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">sudo journalctl -u gunicorn.socket<\/code><\/pre>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0447\u0451\u043c \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0441\u043e\u043a\u0435\u0442\u0430.<\/p>\n<pre><code class=\"bash\">sudo systemctl status gunicorn<\/code><\/pre>\n<p>  \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code class=\"bash\">Active: inactive (dead)<\/code><\/pre>\n<p>  \u041f\u043e\u043a\u0430 \u0432\u0441\u0451 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0441\u043e\u043a\u0435\u0442\u043e\u043c \u0447\u0435\u0440\u0435\u0437 curl.<\/p>\n<pre><code class=\"bash\">curl --unix-socket \/run\/gunicorn.sock localhost<\/code><\/pre>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u0432\u044b\u0434\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 Bad Request (400).<\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0432\u043c\u0435\u0441\u0442\u043e <b>localhost <\/b>\u0443\u043a\u0430\u0437\u0430\u0442\u044c <b>IP \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/b>, \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0438\u0437-\u0437\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a nginx, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0435\u0449\u0451 \u043d\u0435 \u0434\u0435\u043b\u0430\u043b\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435. <\/p>\n<p>  \u0418 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u0443\u0441\u0430:<\/p>\n<pre><code class=\"bash\">sudo systemctl status gunicorn<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">Active: active (running)<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 + \u0435\u0449\u0451 \u043c\u0430\u0441\u0441\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043d\u043e \u043d\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445, \u0442\u043e \u0432\u0441\u0451 \u043e\u0442\u043b\u0438\u0447\u043d\u043e.<\/p>\n<p>  \u0418\u043d\u0430\u0447\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0435 <\/p>\n<pre><code class=\"bash\">sudo journalctl -u gunicorn<\/code><\/pre>\n<p>  \u0418 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b Gunicorn<\/p>\n<pre><code class=\"bash\">sudo systemctl daemon-reload sudo systemctl restart gunicorn<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 NGINX<\/h2>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0441\u0430\u0439\u0442\u0443 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u043d\u0438\u043c\u0430\u043b \u0447\u0442\u043e \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0440\u0430\u0442\u044c.<\/p>\n<pre><code class=\"bash\">sudo nano \/etc\/nginx\/sites-available\/djangoprojectname<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"nginx\">server {     listen 80;     server_name server_domain_or_IP;      location = \/favicon.ico { access_log off; log_not_found off; }     location \/static\/ {         alias \/var\/www\/djangoprojectname\/static\/;     }      location \/media\/ {         alias \/var\/www\/djangoprojectname\/media\/;     }      location \/ {         include proxy_params;         proxy_pass http:\/\/unix:\/run\/gunicorn.sock;     } }<\/code><\/pre>\n<p>  \u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 sever_name \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b.<\/p>\n<p>  \u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435:<\/p>\n<pre><code class=\"bash\">sudo nginx -t<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435\u0442, \u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0434\u0430\u0451\u043c \u043d\u0430\u0448\u0435\u043c\u0443 \u0431\u0440\u0430\u043d\u0434\u043c\u0430\u0443\u044d\u0440\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u0430\u0432\u0430:<\/p>\n<pre><code class=\"bash\">sudo systemctl restart nginx sudo ufw allow 'Nginx Full' <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0440\u0442\u0443 8000<\/p>\n<pre><code class=\"bash\">sudo ufw delete allow 8000<\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u0441\u0451 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0432\u0441\u0451 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u043a\u0430 \u044f \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b https. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043c\u043e\u0433\u0443 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0441 \u0447\u0435\u043c \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e, \u043d\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u0430 \u043d\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u043b\u0430\u0441\u044c, \u0445\u043e\u0442\u044f \u043c\u0435\u0434\u0438\u0430 \u0444\u0430\u0439\u043b\u044b \u0433\u0440\u0443\u0437\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 HTTPS<\/h2>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/certbot.eff.org\/lets-encrypt\/debianbuster-nginx\">Cerbot<\/a><\/p>\n<pre><code class=\"bash\">sudo apt-get install certbot python-certbot-nginx sudo certbot \u2013nginx <\/code><\/pre>\n<p>  \u0418 \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u0415\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u0435 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0448\u0438\u0431\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f, \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0435\u0441\u044f \u043a \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443.<br \/>  \u0414\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443.<\/p>\n<pre><code class=\"bash\">sudo certbot renew --dry-run <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0435\u0441\u0442\u0438\u043c \u0441\u0430\u0439\u0442 \u0438 \u0432\u0441\u0451 \u0434\u043e\u043b\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c!<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u043a\u0430 \u0442\u0430\u043a \u0438 \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043b\u0430\u0441\u044c, \u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c css \u0444\u0430\u0439\u043b \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u043e\u043b\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0434\u043e \u043d\u0435\u0433\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b\u0434\u0430\u043b \u043e\u0448\u0438\u0431\u043a\u0443 403, \u0442\u043e \u0432\u0441\u0451 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u043f\u0440\u0430\u0432\u0430\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0443\u0436\u043d\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0438\u043c\u0438, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0430\u0432 \u0434\u043b\u044f <b>www-data<\/b> \u043d\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <b>\/var\/www<\/b>. \u0415\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 404, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a <b>location <\/b>\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 <b>NGINX<\/b>.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 PostgreSQL<\/h2>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c PostgreSQL \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 SQLite. \u0415\u0441\u043b\u0438 \u0412\u0430\u043c \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u0448\u0430\u0433, \u043b\u0438\u0431\u043e \u0432\u043e\u0437\u044c\u043c\u0438\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 PostgreSQL.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code class=\"bash\">sudo -u postgres psql<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"pgsql\">CREATE DATABASE dbforproject; CREATE USER projectdbuser WITH PASSWORD 'password';<\/code><\/pre>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u043c \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443 Django.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e UTF-8, \u0441\u0445\u0435\u043c\u0443 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u00abread committed\u00bb, \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043d\u0435\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439. \u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e \u0413\u0440\u0438\u043d\u0432\u0438\u0447\u0443 (UTC).<\/p>\n<pre><code class=\"pgsql\">ALTER ROLE projectdbuser SET client_encoding TO 'utf8'; ALTER ROLE projectdbuser SET default_transaction_isolation TO 'read committed'; ALTER ROLE projectdbuser SET timezone TO 'UTC';<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"pgsql\">GRANT ALL PRIVILEGES ON DATABASE dbforproject TO projectdbuser;<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0434\u0438\u0430\u043b\u043e\u0433 PostgreSQL \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"pgsql\">\\q<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 PostgreSQL \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c Django \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PostreSQL.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 SQLite (\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">cd \/var\/www\/djangoprojectname source .\/env\/bin\/activate cd mainappname\/ python3.8 manage.py dumpdata &gt; datadump.json<\/code><\/pre>\n<p>  \u041f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"python\">DATABASES = {     'default': {         'ENGINE': 'django.db.backends.postgresql_psycopg2',         'NAME': 'dbforproject',         'USER': 'projectdbuser',         'PASSWORD': 'password',         'HOST': 'localhost',         'PORT': '',     } }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0411\u0414:<\/p>\n<pre><code class=\"bash\">python3.8 manage.py migrate --run-syncdb<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e shell:<\/p>\n<pre><code class=\"bash\">python3 manage.py shell<\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043d\u0451\u043c:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; from django.contrib.contenttypes.models import ContentType &gt;&gt;&gt; ContentType.objects.all().delete() &gt;&gt;&gt; quit()<\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u043c \u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 SQLite:<\/p>\n<pre><code class=\"bash\">python3.8 manage.py loaddata datadump.json<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451, \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0451 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u043e\u0441\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0448\u0430\u0433\u0438 \u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>  \u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04-ru\">www.digitalocean.com\/community\/tutorials\/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04-ru<\/a><\/li>\n<li><a href=\"https:\/\/vexxhost.com\/resources\/tutorials\/how-to-deploy-django-on-nginx-gunicorn-with-postgres\/\">vexxhost.com\/resources\/tutorials\/how-to-deploy-django-on-nginx-gunicorn-with-postgres<\/a><\/li>\n<li><a href=\"https:\/\/pythonworld.ru\/web\/django-ubuntu1604.html\">pythonworld.ru\/web\/django-ubuntu1604.html<\/a><\/li>\n<\/ol>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/501414\/\"> https:\/\/habr.com\/ru\/post\/501414\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/501414\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/z9\/fb\/jx\/z9fbjxytkq-jcp5yonlmrsdmxiy.png\"\/><\/p>\n<p>  \u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a. <\/p>\n<p>  \u0411\u044b\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0439 Debian \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Nginx \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 Django 3.\u0445. \u041f\u0435\u0440\u0435\u0440\u044b\u0432 \u043a\u0443\u0447\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0430\u0439\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f Django-\u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442\u043e \u2014 \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-303370","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303370"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303370\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}