{"id":274687,"date":"2016-02-21T04:58:02","date_gmt":"2016-02-21T01:58:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=274687"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=274687","title":{"rendered":"\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Django-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 VPS [\u0414\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432]"},"content":{"rendered":"<p>       \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Django \u043d\u0430 VPS \u043e\u0442 Reg.ru. \u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u043d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432, \u043e\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u044f\u0434 \u043d\u0435 \u0441\u0430\u043c\u044b\u0445 \u043b\u0443\u0447\u0448\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u043e \u0441 \u043d\u0438\u043c \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Django \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0430.<\/p>\n<p>  \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0438 \u0431\u043e\u043b\u0438, \u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0438 (\u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438). \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: centOS 7, Django 1.9.2 \u0438 Python 3.4.3<\/p>\n<p>  \u0420\u0435\u043c\u0430\u0440\u043a\u0430: \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0424\u0438\u043b\u0438\u043f\u043f\u0430 \u0422\u043e\u0440\u0447\u0438\u043d\u0441\u043a\u043e\u0433\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0442-\u0432\u0435\u0440\u0441\u0438\u0438 PyCharm \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Django.<\/p>\n<h3>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c<\/h3>\n<p>  \u041c\u044b \u0438\u043c\u0435\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Django \u0432 \u0441\u0440\u0435\u0434\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 PyCharm \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430. \u0422.\u0435. settings.py \u0438\u043c\u0435\u0435\u0442 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 sqlite3, \u0431\u0438\u0442\u044b\u0435 \u043f\u0443\u0442\u0438 \u043a \u0441\u0442\u0430\u0442\u0438\u0442\u0435 \u0438 \u043f\u0443\u0441\u0442\u043e\u0439 ALLOWED_HOSTS. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e.<a name=\"habracut\"><\/a><\/p>\n<h3>\u041c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c<\/h3>\n<p>  <\/p>\n<h5>\u042d\u0442\u0430\u043f 1<\/h5>\n<p>  \u041f\u043e\u043a\u0443\u043f\u0430\u0435\u043c \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Reg.ru. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e.<\/p>\n<p>  \u041f\u043e\u043a\u0443\u043f\u0430\u0435\u043c \u043d\u0430 Reg.ru VPS H-XEN-2 \u0441 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 XEN. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u044f\u0434\u0440\u0430 \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c CentOS 7. \u0422\u0430\u0440\u0438\u0444 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u0430\u0431\u044b\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0443 \u0432\u0437\u044f\u0442\u044c \u0435\u0451, \u043d\u0435\u0436\u0435\u043b\u0438 Ubuntu. Debian \u043d\u0435 \u0431\u0435\u0440\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043a\u0443\u043f\u043a\u0435 VPS \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e c\u043e \u0432\u0441\u0435\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0422\u0430\u043c \u0436\u0435 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0430\u0442 \u0441\u0432\u044f\u0437\u0430\u0442\u044c VPS \u0438 \u0434\u043e\u043c\u0435\u043d. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f DNSAdmin. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u044d\u0442\u0430 \u0448\u0442\u0443\u043a\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f Reg.ru \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438.<\/p>\n<p>   \u2014 \u0412\u0430\u0448 \u0434\u043e\u043c\u0435\u043d \u2014 DNS-\u0421\u0435\u0440\u0432\u0435\u0440\u0430. \u0421\u0442\u0430\u0432\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/750\/40f\/bf3\/75040fbf3381407eb9ecb1e54fc033c4.png\"\/><\/p>\n<p>   \u2014 \u0412\u0430\u0448 \u0434\u043e\u043c\u0435\u043d \u2014 \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u043e\u043d\u043e\u0439 \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u00abA\u00bb \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: (Ip-\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430 \u0432\u0430\u0448)<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/162\/06a\/926\/16206a92608e4018bd03a888a41af43c.png\"\/><\/p>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e, \u043c\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043b\u0438 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f \u043a \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0443. \u041d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<h5>\u042d\u0442\u0430\u043f 2<\/h5>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 CentOS 7 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430: <a href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/\">PuTTY<\/a>. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043c \u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0440\u0430\u0431\u043e\u0442\u0435.<\/p>\n<p>  <b>\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0445\u043e\u0441\u0442\u0438\u0433\u0430.<\/b><\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043f\u043e \u043e\u0448\u0438\u0431\u043a\u0435 \u0447\u0435\u0440\u0435\u0437 root-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u043b\u0438 \u0432\u0441\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<p>  1) \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 PuTTY \u0447\u0435\u0440\u0435\u0437 root-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p>   \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044e\u0437\u0435\u0440\u0430: <code>adduser habrauser<br \/>  <\/code><br \/>   \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044e\u0437\u0435\u0440\u0443 \u043f\u0430\u0440\u043e\u043b\u044c: <code>passwd habrauser<br \/>  <\/code><br \/>   \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e habrauser \u043f\u0440\u0430\u0432\u0430: <code>gpasswd -a habrauser wheel<br \/>  <\/code><br \/>   \u2014 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043e\u0442 \u0441\u0435\u0430\u043d\u0441\u0430 \u043f\u043e\u0434 root-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c: <code>exit<br \/>  <\/code><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c habrauser \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0443 sudo<\/p>\n<p>  2) \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 PuTTY \u043f\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c habrauser \u0438 \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u0442\u0430\u0439\u043c-\u0437\u043e\u043d\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443: <code>sudo timedatectl set-timezone Europe\/Moscow<br \/>  <\/code><br \/>   \u2014 \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c: <code>sudo timedatectl<br \/>  <\/code><br \/>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u0438: <code>sudo yum install ntp<br \/>  <\/code><br \/>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u0430:<br \/>   <code> sudo systemctl start ntpd<br \/>   sudo systemctl enable ntpd<br \/>   <\/code><\/p>\n<h5>\u042d\u0442\u0430\u043f 3<\/h5>\n<p>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043b\u044f centOS 7<\/p>\n<p>  <code>sudo yum install epel-release<br \/>  <\/code><\/p>\n<p>  <code>sudo yum install python-pip python-devel postgresql-server postgresql-devel postgresql-contrib gcc nginx <br \/>  <\/code><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c pip, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0438\u0442\u043e\u043d \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440<br \/>  <code>sudo yum install nano<br \/>  <\/code><\/p>\n<p>  <b>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c PostgreSQL<\/b><\/p>\n<p>   \u2014 \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c PostgreSQL:<\/p>\n<p>  <code>sudo postgresql-setup initdb<br \/>  <\/code><\/p>\n<p>   \u2014 \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 PostgreSQL:<\/p>\n<p>  <code>sudo systemctl start postgresql<br \/>  <\/code><\/p>\n<p>   \u2014 \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b:<\/p>\n<p>  <code>sudo nano \/var\/lib\/pgsql\/data\/pg_hba.conf<br \/>  <\/code><\/p>\n<p>   \u2014 \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0431\u0430\u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<p>  <code>. . .<\/p>\n<p>  # TYPE DATABASE USER ADDRESS METHOD<\/p>\n<p>  # &quot;local&quot; is for Unix domain socket connections only<br \/>  local all all peer<br \/>  # IPv4 local connections:<br \/>  #host all all 127.0.0.1\/32 ident<br \/>  host all all 127.0.0.1\/32 md5<br \/>  # IPv6 local connections:<br \/>  #host all all ::1\/128 ident<br \/>  host all all ::1\/128 md5<br \/>  <\/code><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c ctrl+O, \u0434\u0430\u043b\u0435\u0435 enter \u0438 yes. \u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0439\u0442\u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c ctrl+X.<\/p>\n<p>   \u2014 \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441<\/p>\n<p>  <code>sudo systemctl restart postgresql<br \/>  <\/code><\/p>\n<p>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a:<\/p>\n<p>  <code>sudo systemctl enable postgresql<br \/>  <\/code><\/p>\n<p>  <b>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 PostgreSQL:<\/b><\/p>\n<p>   \u2014 \u0432\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<p>  <code>sudo su - postgres<br \/>  <\/code><\/p>\n<p>  -\u0432\u0445\u043e\u0434\u0438\u043c \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0430\u043d\u0441: <\/p>\n<p>  <code>psql<br \/>  <\/code><\/p>\n<p>   \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 habradb:<\/p>\n<p>  <code>CREATE DATABASE habradb;<br \/>  <\/code><\/p>\n<p>   \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<p>  <code>CREATE USER user WITH PASSWORD 'password';<br \/>  <\/code><\/p>\n<p>   \u2014 \u0434\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e user \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 habradb:<\/p>\n<p>  <code>GRANT ALL PRIVILEGES ON DATABASE habradb TO user;<br \/>  <\/code><\/p>\n<p>   \u2014 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u0441\u0435\u0430\u043d\u0441 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439:<\/p>\n<p>  <code>\\q<br \/>  <\/code><\/p>\n<p>  <code>exit<br \/>  <\/code><\/p>\n<h5>\u042d\u0442\u0430\u043f 4<\/h5>\n<p>  \u041d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Python3.4.3, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e.<\/p>\n<p>   \u2014 \u0441\u0442\u0430\u0432\u0438\u043c Python 3.4.3<\/p>\n<p>  <code>sudo yum install python34-devel<br \/>  <\/code><\/p>\n<p>   \u2014 \u0441\u0442\u0430\u0432\u0438\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435: <\/p>\n<p>  <code>sudo pip install virtualenv<br \/>  <\/code><\/p>\n<p>   \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 apifolder (\u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443 \u0432\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u0430\u043c\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432 PyCharm):<\/p>\n<p>  <code>mkdir ~\/apifolder<br \/>  <\/code><\/p>\n<p>   \u2014 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443:<\/p>\n<p>  <code>cd ~\/apifolder<br \/>  <\/code><\/p>\n<p>  -\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 djangoen \u0441 \u043f\u0438\u0442\u043e\u043d\u043e\u043c python 3.4.3<\/p>\n<p>  <code>mkvirtualenv -p \/usr\/bin\/python3.4 djangoen <br \/>  <\/code><\/p>\n<p>  p.s. \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043f\u0438\u0442\u043e\u043d\u0443, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>which python3.4<br \/>  <\/code><\/p>\n<p>   \u2014 \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 \u0438 \u0432\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u0433\u043e<\/p>\n<p>  <code>source myprojectenv\/bin\/activate<br \/>  <\/code><\/p>\n<p>   \u2014 \u0441\u0442\u0430\u0432\u0438\u043c \u0434\u0436\u0430\u043d\u0433\u0443, \u044e\u043d\u0438\u043a\u043e\u0440\u043d \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0431\u0430\u0437\u044b<\/p>\n<p>  <code>pip install django gunicorn psycopg2<br \/>  <\/code><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e django, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <code>pip install django==1.9.2 #\u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e<br \/>  <\/code><\/p>\n<h5>\u042d\u0442\u0430\u043f 5<\/h5>\n<p>  \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 Django:<\/p>\n<p>   \u2014 \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 Django \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043f\u0430\u043f\u043a\u0435 (\u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0438\u043c\u0435\u0435\u0442 \u043c\u043e\u0435 \u0432 PyCharm):<\/p>\n<p>  <code>django-admin.py startproject apifolder . # \u0442\u043e\u0447\u043a\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u0430\u043f\u043a\u0443, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 apifolder.<br \/>  <\/code><\/p>\n<p>   \u2014 \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b.<\/p>\n<p>  \u041f\u043e \u0438\u0434\u0435\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0443\u0436\u043d\u043e \u043f\u0443\u0448\u0430\u043c\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f git, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 git, \u043f\u0443\u0448 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u0432\u0430\u0448\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 SFTP: <a href=\"https:\/\/www.reg.ru\/support\/hosting-i-servery\/hosting-sajtov\/nachalo-raboty-i-dostupy\/kak-podklyuchitsya-po-sftp\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f<\/a><\/li>\n<li>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 home\/habrauser\/apifolder<\/li>\n<li>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435<\/li>\n<li>\u041e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 apifolder, \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b (\u0435\u0433\u043e \u0438\u043c\u044f \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c apifolder, \u043b\u0438\u0431\u043e \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u0437\u0430\u0434\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435).<\/li>\n<\/ul>\n<p>   \u2014 \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b settings.py \u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/p>\n<p>  <code>nano apifoldert\/settings.py <br \/>  <\/code><\/p>\n<p>  \u041b\u0438\u0431\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 IDE, \u0430 \u043f\u043e\u0442\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 SFTP.<\/p>\n<p>  <code>DATABASES = {<br \/>   'default': {<br \/>   'ENGINE': 'django.db.backends.postgresql', # \u0442\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 django 1,8 \u0438 \u0432\u044b\u0448\u0435.<br \/>   'NAME': 'habradb',<br \/>   'USER': 'user',<br \/>   'PASSWORD': 'password',<br \/>   'HOST': 'localhost',<br \/>   'PORT': '',<br \/>   }<br \/>  }<\/p>\n<p>  #\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u043f\u0430\u043f\u043a\u0430 static \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0430 \u043d\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  STATIC_URL = '\/static\/'<br \/>  MEDIA_URL = '\/media\/'<br \/>  STATIC_ROOT = os.path.join(BASE_DIR, &quot;static&quot;)<br \/>  MEDIA_ROOT = os.path.join(BASE_DIR, &quot;media&quot;)<br \/>  STATICFILES_DIRS = (<br \/>  )<\/p>\n<p>  #\u042d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0430\u043c \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438. ALLOWED_HOSTS \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0432\u0430\u0448 \u0434\u043e\u043c\u0435\u043d.<\/p>\n<p>  DEBUG = True<\/p>\n<p>  ALLOWED_HOSTS = [<br \/>   '*',<br \/>   ]<br \/>  <\/code><\/p>\n<p>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b \u043c\u043e\u0434\u0435\u043b\u044c ImageFiled, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Pillow<\/p>\n<p>  <code>sudo yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel<br \/>  <\/code><\/p>\n<p>  <code>pip install Pillow<br \/>  <\/code><\/p>\n<p>   \u2014 \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e (\u0421\u0442\u0430\u0442\u0438\u043a\u0443 \u043f\u043e\u043a\u0430 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0435\u0451 \u0435\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0442\u0434\u0430\u0435\u0442).<\/p>\n<p>  <code>cd ~\/apifolder<br \/>  .\/manage.py makemigrations<br \/>  .\/manage.py migrate<br \/>  <\/code><\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c: <code>python manage.py makemigrations<br \/>  <\/code> \u0438\u0442\u0434<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<p>  <code>.\/manage.py createsuperuser<br \/>  <\/code><\/p>\n<p>   \u2014 \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443:<\/p>\n<p>  .\/manage.py runserver 0.0.0.0:8000<\/p>\n<p>  \u0421\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <a href=\"http:\/\/server_domain_or_IP\">server_domain_or_IP<\/a>:8000<\/p>\n<p>   \u2014 \u0447\u0435\u043a\u0430\u0435\u043c \u0432\u0441\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0443. \u0415\u0441\u043b\u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0438, \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435, \u0442\u043e \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043c\u0435\u043b\u043e\u0447\u0438: \u043f\u0430\u043a\u0435\u0442\u044b, url, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438.<\/p>\n<p>   \u2014 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f<\/p>\n<p>  <code>deactivate<br \/>  <\/code><\/p>\n<h5>\u042d\u0442\u0430\u043f 6<\/h5>\n<p>   \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u042e\u043d\u0438\u043a\u043e\u0440\u043d\u0430:<\/p>\n<p>  <code>sudo nano \/etc\/systemd\/system\/gunicorn.service<br \/>  <\/code><\/p>\n<p>  <code>[Unit]<br \/>  Description=gunicorn daemon<br \/>  After=network.target<\/p>\n<p>  [Service]<br \/>  User=habrauser<br \/>  Group=nginx<br \/>  WorkingDirectory=\/home\/habrauser\/apifolder<br \/>  ExecStart=\/home\/habrauser\/apifolder\/djangoen\/bin\/gunicorn --workers 3 --bind unix:\/home\/habrauser\/apifolder\/apifolder.sock apifolder.wsgi:application<\/p>\n<p>  [Install]<br \/>  WantedBy=multi-user.target<br \/>  <\/code><\/p>\n<p>   \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u044e\u043d\u0438\u043a\u043e\u0440\u043d \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0435\u043c\u0443 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a:<\/p>\n<p>  <code>sudo systemctl start gunicorn<br \/>  sudo systemctl enable gunicorn<br \/>  <\/code><\/p>\n<p>   \u2014 \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c Nginx<\/p>\n<p>  <code>sudo nano \/etc\/nginx\/nginx.conf<br \/>  <\/code><\/p>\n<p>  sudo nano \/etc\/nginx\/nginx.conf<\/p>\n<p>  \u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 \u0432:<\/p>\n<p>  <code>http {<br \/>   . . .<\/p>\n<p>  include \/etc\/nginx\/conf.d\/*.conf;<\/p>\n<p>  #\u0412\u043e\u0442 \u0441\u044e\u0434\u0430 <\/p>\n<p>  server {<br \/>   listen 80 default_server;<\/p>\n<p>  . . .<br \/>  <\/code><\/p>\n<p>  \u0441\u0430\u043c \u043a\u043e\u043d\u0444\u0438\u0433<\/p>\n<p>  <code>server {<br \/>   listen 80;<br \/>   server_name example.ru www.example.ru;<\/p>\n<p>  location = \/favicon.ico { access_log off; log_not_found off; }<br \/>   location \/static\/ {<br \/>   root \/home\/habrauser\/apifolder;<br \/>   }<\/p>\n<p>  location \/ {<br \/>   proxy_set_header Host $http_host;<br \/>   proxy_set_header X-Real-IP $remote_addr;<br \/>   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>   proxy_set_header X-Forwarded-Proto $scheme;<br \/>   proxy_pass http:\/\/unix:\/home\/habrauser\/apifolder\/apifolder.sock;<br \/>   }<br \/>  }<br \/>  <\/code><\/p>\n<p>   \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c nginx \u044e\u0437\u0435\u0440\u0443:<\/p>\n<p>  <code>sudo usermod -a -G habrauser nginx<br \/>  <\/code><\/p>\n<p>   \u2014 \u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0430:<\/p>\n<p>  <code>chmod 710 \/home\/habrauser<br \/>  <\/code><\/p>\n<p>   \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 nginx (\u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u0442\u044c \u0434\u0432\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438):<\/p>\n<p>  <code>sudo nginx -t<br \/>  <\/code><\/p>\n<p>   \u2014 \u0421\u0442\u0430\u0432\u0438\u043c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a:<\/p>\n<p>  <code>sudo systemctl start nginx<\/p>\n<p>  sudo systemctl enable nginx<br \/>  <\/code><\/p>\n<h5>\u042d\u0442\u0430\u043f 7<\/h5>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0434\u0435\u043b\u0430\u043d\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043c\u0430\u0448\u0438\u043d\u0443:<\/p>\n<p>   \u2014 \u0438\u0434\u0435\u043c \u043a \u043d\u0430\u0448\u0435\u0439 \u043f\u0430\u043f\u043a\u0435<\/p>\n<p>  <code>cd ~\/apifolder<br \/>  <\/code><\/p>\n<p>   \u2014 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435:<\/p>\n<p>  <code>source djangoen\/bin\/activate<br \/>  <\/code><\/p>\n<p>   \u2014 \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u043a\u0443:<\/p>\n<p>  <code>.\/manage.py collectstatic<br \/>  <\/code><\/p>\n<p>   \u2014 \u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b\u0438\u043a\u0435 setting.py ALLOWED_HOSTS = \u0432\u0430\u0448 \u0434\u043e\u043c\u0435\u043d, \u0438 DEBUG = False<\/p>\n<p>   \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440: reg.ru \u2014 \u043c\u043e\u0438 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0438 \u0443\u0441\u043b\u0443\u0433\u0438 \u2014 \u0432\u0430\u0448 VPS \u2014 \u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 (\u043d\u0435 \u0432\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437.<\/p>\n<p>  ___________________________________<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/initial-server-setup-with-centos-7\">www.digitalocean.com\/community\/tutorials\/initial-server-setup-with-centos-7<\/a><br \/>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/additional-recommended-steps-for-new-centos-7-servers\">www.digitalocean.com\/community\/tutorials\/additional-recommended-steps-for-new-centos-7-servers<\/a><br \/>  \u0421\u0430\u043c \u043a\u043e\u043d\u0444\u0438\u0433 <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7\">www.digitalocean.com\/community\/tutorials\/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7<\/a>               <\/p>\n<div class=\"clear\"><\/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:\/\/habrahabr.ru\/post\/277653\/\"> https:\/\/habrahabr.ru\/post\/277653\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Django \u043d\u0430 VPS \u043e\u0442 Reg.ru. \u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u043d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432, \u043e\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u044f\u0434 \u043d\u0435 \u0441\u0430\u043c\u044b\u0445 \u043b\u0443\u0447\u0448\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u043e \u0441 \u043d\u0438\u043c \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Django \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0430.<\/p>\n<p>  \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0438 \u0431\u043e\u043b\u0438, \u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0438 (\u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438). \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a: centOS 7, Django 1.9.2 \u0438 Python 3.4.3<\/p>\n<p>  \u0420\u0435\u043c\u0430\u0440\u043a\u0430: \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0424\u0438\u043b\u0438\u043f\u043f\u0430 \u0422\u043e\u0440\u0447\u0438\u043d\u0441\u043a\u043e\u0433\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0442-\u0432\u0435\u0440\u0441\u0438\u0438 PyCharm \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Django.<\/p>\n<h3>\u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c<\/h3>\n<p>  \u041c\u044b \u0438\u043c\u0435\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Django \u0432 \u0441\u0440\u0435\u0434\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 PyCharm \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430. \u0422.\u0435. settings.py \u0438\u043c\u0435\u0435\u0442 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 sqlite3, \u0431\u0438\u0442\u044b\u0435 \u043f\u0443\u0442\u0438 \u043a \u0441\u0442\u0430\u0442\u0438\u0442\u0435 \u0438 \u043f\u0443\u0441\u0442\u043e\u0439 ALLOWED_HOSTS. \u042d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e.<\/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-274687","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274687","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=274687"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274687\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}