{"id":213269,"date":"2014-02-20T10:19:03","date_gmt":"2014-02-20T06:19:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=213269"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=213269","title":{"rendered":"<span class=\"post_title\">Deploy \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 RoR 4 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Capistrano 3<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/0a6\/3aa\/2f6\/0a63aa2f640920d345e0d82d27fe3466.jpg\" \/><\/div>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435: \u0412\u044b \u2014 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u043b Ruby on Rails. \u0418 \u0442\u0443\u0442 \u0412\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u0442\u0430\u0434\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. <br \/>  \u0412\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 Heroku, \u043d\u043e \u0442\u0430\u043c\u043e\u0448\u043d\u0438\u0435 \u0446\u0435\u043d\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u0430\u044e\u0442\u0441\u044f. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0443\u043f\u0438\u0442\u044c VPS, \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u0438 \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0442\u0443\u0434\u0430. <br \/>  \u00ab\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0449\u0435? \u041d\u0430\u0439\u0434\u0443 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0433\u0430\u0439\u0434, \u0434\u0430 \u0441\u043b\u0435\u0434\u0430\u044e \u0432\u0441\u0451 \u043f\u043e \u043d\u0435\u043c\u0443\u00bb \u2014 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u0412\u044b. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u0430\u0439\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043d\u043e \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0435\u043b\u0430\u044e\u0442, \u2014 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0434\u0430 \u0438 \u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0443\u044e \u0432\u0442\u043e\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Capistrano.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0433\u0430\u0439\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c:   <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 nginx (\u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c PageSpeed), postgresql, redis<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 rvm, rails<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0433\u0435\u043c\u0430 foreman \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0412\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 Unicorn<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0433\u0435\u043c\u0430 Capistrano (v3.1) \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u043f\u043b\u043e\u044f <\/li>\n<\/ul>\n<p>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0433\u0430\u0439\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c, \u043d\u043e \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0441\u043e \u0441\u0442\u0430\u0436\u0435\u043c.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/2d0\/6b4\/21c\/2d06b421c7b265808e7d2c24f4624065.jpg\" \/><\/div>\n<p>  \u0412\u044b \u043a\u0443\u043f\u0438\u043b\u0438 \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 VPS, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u041e\u0421 (\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e ubuntu 12.04 LTS \u0438 \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0443\u0434\u0443 \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434 \u043d\u0435\u0451), \u0437\u0430\u0448\u043b\u0438 \u043f\u043e SSH. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435? <\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0441\u043c\u0435\u043d\u0438\u043c \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f root \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">passwd  <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:   <\/p>\n<pre><code class=\"bash\">adduser deployer <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043e\u0439 sudo:   <\/p>\n<pre><code class=\"bash\">visudo  <\/code><\/pre>\n<p> \u0438 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c: <\/p>\n<pre><code>deployer ALL=(ALL:ALL) ALL <\/code><\/pre>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 ssh \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u0437\u0430\u043f\u0440\u0435\u0442\u0438\u043c \u043b\u043e\u0433\u0438\u043d \u043f\u043e\u0434 root, \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u043b\u043e\u0433\u0438\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 \u043d\u0430\u0448\u0438\u043c \u043d\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c). \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0444\u0430\u0439\u043b &#8216;\/etc\/ssh\/sshd_config&#8217;:  <\/p>\n<pre><code>PermitRootLogin no UseDNS no AllowUsers deployer <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c ssh \u0441\u0435\u0440\u0432\u0435\u0440 \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">reload ssh <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0430\u0440\u043e\u043b\u044c \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u043e ssh, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c ssh \u043a\u043b\u044e\u0447 \u0441 \u0412\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 <\/p>\n<pre><code class=\"bash\">ssh-copy-id deployer@123.123.123.123 <\/code><\/pre>\n<p> (\u041d\u0430 \u043c\u0430\u043a\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 ssh-copy-id, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 brew, \u043d\u0430 Windows \u043d\u0435 \u0437\u043d\u0430\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439, \u043d\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443).<\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435, \u043f\u043e\u043a\u0430 \u0443\u0436 \u043c\u044b \u043f\u043e\u0434 \u0440\u0443\u0442\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c SWAP \u0444\u0430\u0439\u043b, \u0435\u0441\u043b\u0438 \u0443 \u0412\u0430\u0441 \u043c\u0430\u043b\u043e RAM. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"bash\">dd if=\/dev\/zero of=\/swapfile bs=1024 count=512k mkswap \/swapfile swapon \/swapfile <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 &#8216;\/etc\/fstab&#8217; \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0443:   <\/p>\n<pre><code> \/swapfile       none    swap    sw      0       0  <\/code><\/pre>\n<p>  \u0418 \u0434\u0430\u043b\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">echo 0 &gt; \/proc\/sys\/vm\/swappiness sudo chown root:root \/swapfile  sudo chmod 0600 \/swapfile <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 SWAP \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">swapon -s  <\/code><\/pre>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 nginx<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/541\/7a6\/785\/5417a67857580be18180dbb0d30a1384.png\" \/><\/div>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043b\u043e\u0433\u0438\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u0434 \u043d\u0430\u0448\u0438\u043c \u043d\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">ssh deployer@123.123.123.123<\/code><\/pre>\n<p> (\u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435).<br \/>  \u041b\u0438\u0447\u043d\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043c\u043e\u0434\u0443\u043b\u044c PageSpeed, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 nginx \u0441\u043e\u0431\u0438\u0440\u0430\u044e \u0441\u0430\u043c. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u044b:  <\/p>\n<pre><code class=\"bash\">sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">wget https:\/\/github.com\/pagespeed\/ngx_pagespeed\/archive\/v1.7.30.1-beta.zip unzip v1.7.30.1-beta.zip cd ngx_pagespeed-1.7.30.1-beta wget https:\/\/dl.google.com\/dl\/page-speed\/psol\/1.7.30.1.tar.gz tar -xzvf 1.7.30.1.tar.gz wget http:\/\/nginx.org\/download\/nginx-1.4.4.tar.gz tar -xzvf nginx-1.4.4.tar.gz cd nginx-1.4.4 .\/configure --add-module=$HOME\/ngx_pagespeed-1.7.30.1-beta make sudo make install <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f nginx \u043d\u0430\u043f\u0438\u0448\u0435\u043c <a href=\"http:\/\/upstart.ubuntu.com\/\">upstart<\/a> \u0441\u043a\u0440\u0438\u043f\u0442. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u0430\u0439\u043b &#8216;\/etc\/init\/nginx.conf&#8217; \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">etc\/init\/nginx.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>description &quot;nginx http daemon&quot; author &quot;George Shammas &lt;georgyo@gmail.com&gt;&quot;   start on (filesystem and net-device-up IFACE=lo) stop on runlevel [!2345]   env DAEMON=\/usr\/local\/nginx\/sbin\/nginx env PID=\/var\/run\/nginx.pid   expect fork respawn respawn limit 10 5 #oom never   pre-start script         $DAEMON -t         if [ $? -ne 0 ]                 then exit $?         fi end script   exec $DAEMON <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c <\/p>\n<pre><code class=\"bash\">sudo start\/stop\/restart\/status nginx <\/code><\/pre>\n<p>  \u041d\u0430\u0448 nginx.conf \u043b\u0435\u0436\u0438\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 &#8216;\/usr\/local\/nginx\/conf\/nginx.conf&#8217;, \u043d\u043e \u043f\u043e\u043a\u0430 \u043c\u044b \u0435\u0433\u043e \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u041c\u044b \u0435\u0433\u043e \u0437\u0430\u043b\u044c\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u043f\u043b\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u043e\u0432\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0435\u0431\u044f \u0432 \u044d\u0442\u0443 \u0433\u0440\u0443\u043f\u043f\u0443, \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443:  <\/p>\n<pre><code class=\"bash\">sudo useradd -s \/sbin\/nologin -r nginx sudo groupadd web sudo usermod -a -G web nginx sudo usermod -a -G web deployer sudo mkdir \/var\/www sudo chgrp -R web \/var\/www sudo chmod -R 775 \/var\/www <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u0438 \u0437\u0430\u0439\u0442\u0438 \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0434 \u043d\u0430\u0448\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 PostgreSQL<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/c46\/490\/b80\/c46490b8070528ded4adc5ddd2d2e480.png\" \/><\/div>\n<p>  \u0412 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445 ubuntu \u043b\u0435\u0436\u0438\u0442 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439 \u0440\u0435\u043f\u043e. \u0412 \u0444\u0430\u0439\u043b &#8216;\/etc\/apt\/sources.list.d\/pgdg.list&#8217; \u0434\u043e\u0431\u0430\u0432\u0438\u043c:  <\/p>\n<pre><code>deb http:\/\/apt.postgresql.org\/pub\/repos\/apt\/ precise-pgdg main <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u044e\u0447 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c PostgreSQL:  <\/p>\n<pre><code class=\"bash\">wget --quiet -O - http:\/\/apt.postgresql.org\/pub\/repos\/apt\/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 <\/code><\/pre>\n<p>  \u0418 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:   <\/p>\n<pre><code class=\"bash\">sudo -u postgres psql  create user deployer with password '\u0432\u0430\u0448 \u043f\u0430\u0440\u043e\u043b\u044c'; alter role deployer superuser createrole createdb replication;  \\q <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 &#8216;\/etc\/postgresql\/9.3\/main\/postgresql.conf&#8217; \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>listen_addresses = 'localhost'<\/code> \u043d\u0430 <code>listen_addresses = '*'<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b &#8216;\/etc\/postgresql\/9.3\/main\/pg_hba.conf&#8217; \u0441\u0442\u0440\u043e\u0447\u043a\u0443  <\/p>\n<pre><code>host    all             deployer       \u0432\u0430\u0448.\u0432\u043d\u0435\u0448\u043d\u0438\u0439.ip.\u0430\u0434\u0440\u0435\u0441 255.255.255.0 md5 <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c postgresql \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">sudo service postgresql restart <\/code><\/pre>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Redis<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/f4e\/5dc\/854\/f4e5dc8543844123d64fb68139951e31.png\" \/><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0412\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0442\u0435 gem <a href=\"https:\/\/github.com\/resque\/resque\">resque<\/a>, \u0442\u043e \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Redis. \u0418\u0431\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u044f \u0435\u0433\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u044e \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u044d\u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438:  <\/p>\n<pre><code class=\"bash\">sudo apt-get install tcl8.5 wget http:\/\/download.redis.io\/redis-stable.tar.gz tar xvzf redis-stable.tar.gz cd redis-stable make make test sudo cp src\/redis-server \/usr\/local\/bin sudo cp src\/redis-cli \/usr\/local\/bin <\/code><\/pre>\n<p>  Redis \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0435\u043d \u043f\u0430\u0440\u043e\u043b\u0435\u043c \u0438 \u043e\u0442\u043a\u0440\u044b\u0442 \u0432\u0441\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u043e\u043b\u044c: \u0432 \u0444\u0430\u0439\u043b\u0435 &#8216;redis.conf&#8217; \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>requirepass<\/code> \u0441 \u043d\u0430\u0448\u0438\u043c \u043f\u0430\u0440\u043e\u043b\u0435\u043c. Redis \u043b\u0435\u0433\u043a\u043e \u0431\u0440\u0443\u0442\u0444\u043e\u0440\u0441\u0438\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u0435\u043b\u0430\u044e \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 100 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0422\u0430\u043a\u0436\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u043d\u0435 \u0432\u044b\u043b\u0435\u0442\u0430\u043b\u043e \u043e\u0448\u0438\u0431\u043e\u043a, \u043c\u0435\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>dir<\/code> \u043d\u0430<code> \/var\/www\/other<\/code>, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432 \u0442\u0430\u043a\u0443\u044e \u043f\u0430\u043f\u043a\u0443 (<code>mkdir \/var\/www\/other<\/code>).<br \/>  \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0444\u0438\u0433 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">sudo cp redis.conf \/etc\/redis\/redis.conf  <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c upstart \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 &#8216;\/etc\/init\/redis-server.conf&#8217; \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\/etc\/init\/redis-server.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#!upstart description &quot;Redis Server&quot;  env USER=deployer  start on runlevel [2345] stop on runlevel [016]  respawn exec start-stop-daemon --start --make-pidfile --pidfile \/var\/run\/redis-server.pid --chuid $USER --exec \/usr\/local\/bin\/redis-server \/etc\/redis\/redis.conf &gt;&gt; \/var\/www\/log\/redis.log 2&gt;&1 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c Redis\u043e\u043c \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u0430\u043c\u0438 <\/p>\n<pre><code class=\"bash\">sudo start\/stop\/restart\/status redis-server <\/code><\/pre>\n<p>, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432 \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u043b\u043e\u0433\u043e\u0432 (<code>mkdir \/var\/www\/log<\/code>).<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 RVM, Ruby, Rails, Bundler<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/fd7\/5bf\/168\/fd75bf168d048c419cf083bad58c8e51.png\" \/><\/div>\n<p>  \u0422\u0443\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e:  <\/p>\n<pre><code class=\"bash\">sudo apt-get install git curl python-software-properties  sudo add-apt-repository ppa:chris-lea\/node.js sudo apt-get update sudo apt-get install nodejs  curl -L get.rvm.io | bash -s stable source ~\/.rvm\/scripts\/rvm rvm requirements  rvm install 2.0.0 rvm use 2.0.0 --default gem install rails --no-ri --no-rdoc gem install bundler <\/code><\/pre>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 GitHub\/BitBucket<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/3d1\/b5c\/563\/3d1b5c56357a4371884a9d1b1a94ac13.png\" \/><\/div>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c git \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0434\u043b\u044f \u0434\u0435\u043f\u043b\u043e\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c git \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 \u043d\u0430\u0448\u0435\u043c VPS, \u043d\u043e \u0437\u0430\u0447\u0435\u043c, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0418\u0442\u0430\u043a, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 GitHub\/BitBucket (\u0443 BitBucket \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b), \u043d\u043e \u043d\u0435 \u0441\u043f\u0435\u0448\u0438\u043c \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c .gitignore \u0444\u0430\u0439\u043b (\u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f), \u0447\u0442\u043e\u0431\u044b \u0432 \u0440\u0435\u043f\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u043b\u0430 \u043d\u0438\u043a\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0434\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u0440\u0435\u043f\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439), \u0434\u0430 \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043b\u0438\u0448\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0430\u043c \u0442\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b:  <\/p>\n<pre><code>\/config\/database.yml # \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u043c \/Procfile # \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u044f \u0435\u0449\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \/config\/deploy\/ # \u0444\u0430\u0439\u043b\u044b Capistrano \/shared\/ # \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u043f\u043b\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \/public\/system\/ # \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Paperclip <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u043e\u043c\u043c\u0438\u0442 \u0438 \u0437\u0430\u043f\u0443\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 git.   <\/p>\n<pre><code class=\"bash\">git init git remote add origin #\u0410\u0414\u0420\u0415\u0421 \u0420\u0415\u041f\u041e git add -A git commit -m 'first commit' git push -u origin --all <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0443 Github\/BitBucket, \u044d\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0442.\u043a. \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0432 Help\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<h4>gem foreman<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/26d\/932\/db9\/26d932db99bae73a60f9cdfdb865dcb4.jpg\"  alt=\"\u0414\u043e\u043a\u0442\u043e\u0440 \u0424\u043e\u0440\u043c\u0430\u043d \u0438\u0437 \u0441\u0435\u0440\u0438\u0430\u043b\u0430 &#39;\u0414\u043e\u043a\u0442\u043e\u0440 \u0425\u0430\u0443\u0441&#39;\"\/><\/div>\n<p>  <a href=\"https:\/\/github.com\/ddollar\/foreman\">foreman<\/a> \u2014 \u0433\u0435\u043c \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 Procfile, \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">foreman start <\/code><\/pre>\n<p> \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432\u044b\u0432\u043e\u0434.<br \/>  \u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">foreman export upstart <\/code><\/pre>\n<p> \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 upstart \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043b\u0435\u0433\u043a\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434 start\/stop\/restart. \u041d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0442\u043e\u043c. \u041f\u043e\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0433\u043e, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c Procfile \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0423 \u043c\u0435\u043d\u044f \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a.  <\/p>\n<pre><code>web: rails s job1: bundle exec rake resque:work PIDFILE=.\/tmp\/pids\/resque2.pid QUEUES=send_email job2: bundle exec rake resque:work PIDFILE=.\/tmp\/pids\/resque2.pid QUEUES=send_email <\/code><\/pre>\n<p>  Production \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u043e\u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0437\u0430\u0439\u0434\u0435\u0442 \u043e Capistrano.<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Unicorn<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/01b\/a1f\/26f\/01ba1f26f0eeecd3cfe3380416bff98b.png\" \/><\/div>\n<p>  <a href=\"https:\/\/github.com\/defunkt\/unicorn\">Unicorn<\/a> \u2014 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0433\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432  <\/p>\n<pre><code>group :production do   gem 'unicorn' end <\/code><\/pre>\n<p> \u0432 Gemfile. (\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u0440\u043e <code>bundle install<\/code>)<\/p>\n<p>  \u0412 \u043f\u0430\u043f\u043a\u0435 &#8216;\/config\/&#8217; \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b unicon.rb c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Unicorn.rb<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"ruby\">worker_processes 2  working_directory &quot;\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/current&quot; # available in 0.94.0+  # listen on both a Unix domain socket and a TCP port, # we use a shorter backlog for quicker failover when busy listen &quot;\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/socket\/.unicorn.sock&quot;, :backlog =&gt; 64 listen 8080, :tcp_nopush =&gt; true  # nuke workers after 30 seconds instead of 60 seconds (the default) timeout 30  # feel free to point this anywhere accessible on the filesystem pid &quot;\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/run\/unicorn.pid&quot;  # By default, the Unicorn logger will write to stderr. # Additionally, ome applications\/frameworks log to stderr or stdout, # so prevent them from going to \/dev\/null when daemonized here: stderr_path &quot;\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/log\/unicorn.stderr.log&quot; stdout_path &quot;\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/log\/unicorn.stdout.log&quot;  # combine Ruby 2.0.0dev or REE with &quot;preload_app true&quot; for memory savings # http:\/\/rubyenterpriseedition.com\/faq.html#adapt_apps_for_cow preload_app true GC.respond_to?(:copy_on_write_friendly=) and   GC.copy_on_write_friendly = true  # Enable this flag to have unicorn test client connections by writing the # beginning of the HTTP headers before calling the application.  This # prevents calling the application for connections that have disconnected # while queued.  This is only guaranteed to detect clients on the same # host unicorn runs on, and unlikely to detect disconnects even on a # fast LAN. check_client_connection false  before_fork do |server, worker|      # the following is highly recomended for Rails + &quot;preload_app true&quot;   # as there's no need for the master process to hold a connection      defined?(ActiveRecord::Base) and     ActiveRecord::Base.connection.disconnect!    # The following is only recommended for memory\/DB-constrained   # installations.  It is not needed if your system can house   # twice as many worker_processes as you have configured.   #   # # This allows a new master process to incrementally   # # phase out the old master process with SIGTTOU to avoid a   # # thundering herd (especially in the &quot;preload_app false&quot; case)   # # when doing a transparent upgrade.  The last worker spawned   # # will then kill off the old master process with a SIGQUIT.   old_pid = &quot;#{server.config[:pid]}.oldbin&quot;   if old_pid != server.pid     begin       sig = (worker.nr + 1) &gt;= server.worker_processes ? :QUIT : :TTOU       Process.kill(sig, File.read(old_pid).to_i)     rescue Errno::ENOENT, Errno::ESRCH     end   end   #   # Throttle the master from forking too quickly by sleeping.  Due   # to the implementation of standard Unix signal handlers, this   # helps (but does not completely) prevent identical, repeated signals   # from being lost when the receiving process is busy.   # sleep 1 end  after_fork do |server, worker|   # per-process listener ports for debugging\/admin\/migrations   # addr = &quot;127.0.0.1:#{9293 + worker.nr}&quot;   # server.listen(addr, :tries =&gt; -1, :delay =&gt; 5, :tcp_nopush =&gt; true)    # the following is *required* for Rails + &quot;preload_app true&quot;,   defined?(ActiveRecord::Base) and     ActiveRecord::Base.establish_connection     # if preload_app is true, then you may also want to check and   # restart any other shared sockets\/descriptors such as Memcached,   # and Redis.  TokyoCabinet file handles are safe to reuse   # between any number of forked children (assuming your kernel   # correctly implements pread()\/pwrite() system calls) end  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f \u043d\u0430 \u0412\u0430\u0448\u0435 \u0438\u043c\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0412\u044b \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u0434\u0430\u0434\u0438\u0442\u0435 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 Capistrano.<\/p>\n<h4>Capistrano<\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/0a6\/3aa\/2f6\/0a63aa2f640920d345e0d82d27fe3466.jpg\" \/><\/div>\n<p>  <a href=\"https:\/\/github.com\/capistrano\/capistrano\">Capistrano<\/a> \u2014 \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0434\u0435\u043f\u043b\u043e\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u0443\u0441\u0442\u044c \u0438 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u043a\u043e\u0432\u044b\u043c \u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0433\u043e \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 Gemfile:  <\/p>\n<pre><code>group :development do   gem 'capistrano'   gem 'capistrano-rails'   gem 'capistrano-bundler'   gem 'capistrano-rvm' end <\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>bundle exec cap install<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 Capfile:  <\/p>\n<pre><code>require 'capistrano\/deploy' require 'capistrano\/rvm' require 'capistrano\/bundler' require 'capistrano\/rails' <\/code><\/pre>\n<p>  \u0423\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0432 \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u043f\u0430\u043f\u043a\u0443, Capistrano:  <\/p>\n<ul>\n<li>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u043f\u0430\u043f\u043a\u0443 <code>\u0440\u0430\u0431\u043e\u0447\u0430\u044f_\u043f\u0430\u043f\u043a\u0430\/\u0438\u043c\u044f_\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\/releases\/\u0434\u0430\u0442\u0430_\u0440\u0435\u043b\u0438\u0437\u0430\/<\/code>, \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044f \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 5 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439).<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442 bundle install.<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442 db:migrate.<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442 assets:precompile.<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0441\u0442 symlink \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043f\u043a\u0443 <code>\u0440\u0430\u0431\u043e\u0447\u0430\u044f_\u043f\u0430\u043f\u043a\u0430\/\u0438\u043c\u044f_\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\/current<\/code><\/li>\n<\/ul>\n<p>  \u041d\u043e \u043d\u0430\u043c \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<ul>\n<li>\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u043f\u043b\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 nginx, unicorn, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, \u0441\u043e\u0437\u0434\u0430\u0442\u044c upstart \u0441\u043a\u0440\u0438\u043f\u0442 (\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e foreman).<\/li>\n<li>\u041f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0434\u0435\u043f\u043b\u043e\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c git add, git commit, git push (\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043a \u043a\u043e\u043c\u043c\u0438\u0442\u0443 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f). \u041f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u043f\u043b\u043e\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0438\u043c\u043b\u0438\u043d\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c Unicorn.<\/li>\n<\/ul>\n<p>  \u041d\u0443\u0436\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 shared (\u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435), \u043d\u0435 \u0437\u0440\u044f \u043c\u044b \u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 .gitignore. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043c nginx.conf \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">nginx.conf<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>user nginx web;   pid \/var\/run\/nginx.pid; error_log \/var\/www\/log\/nginx.error.log;  events {   worker_connections 1024; # increase if you have lots of clients   accept_mutex off; # &quot;on&quot; if nginx worker_processes &gt; 1   use epoll; # enable for Linux 2.6+   # use kqueue; # enable for FreeBSD, OSX }  http {   # nginx will find this file in the config directory set at nginx build time   include mime.types;   types_hash_max_size 2048;   server_names_hash_bucket_size 64;   # fallback in case we can't determine a type   default_type application\/octet-stream;    # click tracking!   access_log \/var\/www\/log\/nginx.access.log combined;    # you generally want to serve static files with nginx since neither   # Unicorn nor Rainbows! is optimized for it at the moment   sendfile on;    tcp_nopush on; # off may be better for *some* Comet\/long-poll stuff   tcp_nodelay off; # on may be better for some Comet\/long-poll stuff    # we haven't checked to see if Rack::Deflate on the app server is   # faster or not than doing compression via nginx.  It's easier   # to configure it all in one place here for static files and also   # to disable gzip for clients who don't get gzip\/deflate right.   # There are other gzip settings that may be needed used to deal with   # bad clients out there, see http:\/\/wiki.nginx.org\/NginxHttpGzipModule   gzip on;   gzip_http_version 1.0;   gzip_proxied any;   gzip_min_length 0;   gzip_vary on;   gzip_disable &quot;MSIE [1-6]\\.&quot;;   gzip_proxied expired no-cache no-store private auth;   gzip_comp_level 9;   gzip_types text\/plain text\/xml text\/css              text\/comma-separated-values              text\/javascript application\/x-javascript              application\/atom+xml;    # this can be any application server, not just Unicorn\/Rainbows!   upstream app_server {     server unix:\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/socket\/.unicorn.sock fail_timeout=0;   }    server {     # PageSpeed     pagespeed on;     pagespeed FileCachePath \/var\/ngx_pagespeed_cache;     location ~ &quot;\\.pagespeed\\.([a-z]\\.)?[a-z]{2}\\.[^.]{10}\\.[^.]+&quot; {        add_header &quot;&quot; &quot;&quot;;      }     location ~ &quot;^\/ngx_pagespeed_static\/&quot; { }     location ~ &quot;^\/ngx_pagespeed_beacon$&quot; { }     location \/ngx_pagespeed_statistics {        allow 127.0.0.1; allow 5.228.169.73; deny all;      }     location \/ngx_pagespeed_global_statistics {        allow 127.0.0.1; allow 5.228.169.73; deny all;      }     pagespeed MessageBufferSize 100000;     location \/ngx_pagespeed_message {        allow 127.0.0.1; allow 5.228.169.73; deny all;      }     location \/pagespeed_console {        allow 127.0.0.1; allow 5.228.169.73; deny all;      }           charset utf-8;     # enable one of the following if you're on Linux or FreeBSD     listen 80 default deferred; # for Linux     # listen 80 default accept_filter=httpready; # for FreeBSD      # If you have IPv6, you'll likely want to have two separate listeners.     # One on IPv4 only (the default), and another on IPv6 only instead     # of a single dual-stack listener.  A dual-stack listener will make     # for ugly IPv4 addresses in $remote_addr (e.g &quot;:ffff:10.0.0.1&quot;     # instead of just &quot;10.0.0.1&quot;) and potentially trigger bugs in     # some software.     # listen [::]:80 ipv6only=on; # deferred or accept_filter recommended      client_max_body_size 4G;     server_name _;      # ~2 seconds is often enough for most folks to parse HTML\/CSS and     # retrieve needed images\/icons\/frames, connections are cheap in     # nginx so increasing this is generally safe...     keepalive_timeout 5;      # path for static files     root \/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/current\/public;      # Prefer to serve static files directly from nginx to avoid unnecessary     # data copies from the application server.     #     # try_files directive appeared in in nginx 0.7.27 and has stabilized     # over time.  Older versions of nginx (e.g. 0.6.x) requires     # &quot;if (!-f $request_filename)&quot; which was less efficient:     # http:\/\/bogomips.org\/unicorn.git\/tree\/examples\/nginx.conf?id=v3.3.1#n127     try_files $uri\/index.html $uri.html $uri @app;      location ~ ^\/(assets)\/  {       root \/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/current\/public;              expires max;       add_header Cache-Control public;     }     location @app {       # an HTTP header important enough to have its own Wikipedia entry:       #   http:\/\/en.wikipedia.org\/wiki\/X-Forwarded-For       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        # enable this if you forward HTTPS traffic to unicorn,       # this helps Rack set the proper URL scheme for doing redirects:       # proxy_set_header X-Forwarded-Proto $scheme;        # pass the Host: header from the client right along so redirects       # can be set properly within the Rack application       proxy_set_header Host $http_host;        # we don't want nginx trying to do something clever with       # redirects, we set the Host: header above already.       proxy_redirect off;        # set &quot;proxy_buffering off&quot; *only* for Rainbows! when doing       # Comet\/long-poll\/streaming.  It's also safe to set if you're using       # only serving fast clients with Unicorn + nginx, but not slow       # clients.  You normally want nginx to buffer responses to slow       # clients, even with Rails 3.1 streaming because otherwise a slow       # client can become a bottleneck of Unicorn.       #       # The Rack application may also set &quot;X-Accel-Buffering (yes|no)&quot;       # in the response headers do disable\/enable buffering on a       # per-response basis.       # proxy_buffering off;        proxy_pass http:\/\/app_server;     }      # Rails error pages     error_page 500 502 503 504 \/500.html;     location = \/500.html {       root \/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/current\/public;     }   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u042d\u0442\u043e \u043c\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 \u0434\u043b\u044f nginx, \u0442\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c &#8216;\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f&#8217; \u043d\u0430 \u0412\u0430\u0448\u0435 \u0438\u043c\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 config\/deploy.rb (set :application, &#8216;\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f&#8217;).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u043c \u0436\u0435 (\u0432 \/shared\/) \u0444\u0430\u0439\u043b Procfile \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:  <\/p>\n<pre><code>web: bundle exec unicorn_rails -c \/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/current\/config\/unicorn.rb -E production  job1: bundle exec rake resque:work RAILS_ENV=production PIDFILE=\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/run\/resque1.pid QUEUES=* job2: bundle exec rake resque:work RAILS_ENV=production PIDFILE=\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f\/run\/resque2.pid QUEUES=* <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0434\u0432\u0443\u043c\u044f resque worker\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0412\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Resque, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443.<br \/>  \u0422\u0430\u043c \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c database.yml \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 application.yml, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u0433\u0435\u043c\u043e\u043c Figaro.<\/p>\n<p>  \u041d\u0432\u0448 Capistrano \u0441\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\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 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0435\u043c\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <\/p>\n<pre><code class=\"bash\">sudo visudo <\/code><\/pre>\n<p> \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0443:  <\/p>\n<pre><code>deployer ALL=NOPASSWD: \/usr\/sbin\/service, \/bin\/ln, \/bin\/rm, \/bin\/mv, \/sbin\/start, \/sbin\/stop, \/sbin\/restart, \/sbin\/status <\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Capistrano. \u0412 \u0444\u0430\u0439\u043b\u0435 &#8216;config\/deploy\/production&#8217; \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<br \/>  <code>server 'IP \u0441\u0435\u0440\u0432\u0435\u0440\u0430', user: 'deployer', roles: %w{web app db}<\/code><br \/>  \u0412 \u0444\u0430\u0439\u043b &#8216;config\/deploy.rb&#8217; \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u0435\u0440\u0445\u0443:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">deploy.rb<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"ruby\">set :repo_url, '\u0410\u0434\u0440\u0435\u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f' set :application, '\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f' application = '\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f' set :rvm_type, :user set :rvm_ruby_version, '2.0.0-p353' set :deploy_to, '\/var\/www\/apps\/\u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f'  namespace :foreman do   desc 'Start server'   task :start do     on roles(:all) do       sudo &quot;start #{application}&quot;     end   end    desc 'Stop server'   task :stop do     on roles(:all) do       sudo &quot;stop #{application}&quot;     end   end    desc 'Restart server'   task :restart do     on roles(:all) do       sudo &quot;restart #{application}&quot;     end   end    desc 'Server status'   task :status do     on roles(:all) do       execute &quot;initctl list | grep #{application}&quot;     end   end end  namespace :git do   desc 'Deploy'   task :deploy do     ask(:message, &quot;Commit message?&quot;)     run_locally do       execute &quot;git add -A&quot;       execute &quot;git commit -m '#{fetch(:message)}'&quot;       execute &quot;git push&quot;     end   end end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0427\u0442\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442? \u041f\u0435\u0440\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u2014 \u043a\u043e\u043d\u0444\u0438\u0433. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438. \u0415\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430 foreman, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c 4 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: start, stop, restart status. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 &#8216;cap production foreman:start&#8217; \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e &#8216;sudo start \u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f&#8217;, \u043d\u043e \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u0441\u0442, \u0438\u0431\u043e foreman \u0435\u0449\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043b upstart \u0441\u043a\u0440\u0438\u043f\u0442\u044b. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435: \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430 git, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 deploy. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 &#8216;cap production git:deploy&#8217; \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043f\u0440\u043e\u0441\u044f\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a \u043a\u043e\u043c\u043c\u0438\u0442\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e:  <\/p>\n<pre><code class=\"bash\">git add -A git commit -m '\u041a\u041e\u041c\u041c\u0415\u041d\u0422\u0410\u0420\u0418\u0419' git push <\/code><\/pre>\n<p>  \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430? \u041d\u043e \u044d\u0442\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u0438, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043d\u0443\u0442\u0440\u0438 &#8216;namespace :deploy do&#8217; \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">deploy.rb<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"ruby\">  desc 'Setup'   task :setup do     on roles(:all) do       execute &quot;mkdir  #{shared_path}\/config\/&quot;       execute &quot;mkdir  \/var\/www\/apps\/#{application}\/run\/&quot;       execute &quot;mkdir  \/var\/www\/apps\/#{application}\/log\/&quot;       execute &quot;mkdir  \/var\/www\/apps\/#{application}\/socket\/&quot;       execute &quot;mkdir #{shared_path}\/system&quot;       sudo &quot;ln -s \/var\/log\/upstart \/var\/www\/log\/upstart&quot;        upload!('shared\/database.yml', &quot;#{shared_path}\/config\/database.yml&quot;)              upload!('shared\/Procfile', &quot;#{shared_path}\/Procfile&quot;)         upload!('shared\/nginx.conf', &quot;#{shared_path}\/nginx.conf&quot;)       sudo 'stop nginx'       sudo &quot;rm -f \/usr\/local\/nginx\/conf\/nginx.conf&quot;       sudo &quot;ln -s #{shared_path}\/nginx.conf \/usr\/local\/nginx\/conf\/nginx.conf&quot;       sudo 'start nginx'        within release_path do         with rails_env: fetch(:rails_env) do           execute :rake, &quot;db:create&quot;         end       end        end   end    desc 'Create symlink'   task :symlink do     on roles(:all) do       execute &quot;ln -s #{shared_path}\/config\/database.yml #{release_path}\/config\/database.yml&quot;       execute &quot;ln -s #{shared_path}\/Procfile #{release_path}\/Procfile&quot;       execute &quot;ln -s #{shared_path}\/system #{release_path}\/public\/system&quot;     end   end    desc 'Foreman init'   task :foreman_init do     on roles(:all) do       foreman_temp = &quot;\/var\/www\/tmp\/foreman&quot;       execute  &quot;mkdir -p #{foreman_temp}&quot;       # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 current \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b foreman \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b upstart \u0444\u0430\u0439\u043b\u044b \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438       execute &quot;ln -s #{release_path} #{current_path}&quot;        within current_path do         execute &quot;cd #{current_path}&quot;         execute :bundle, &quot;exec foreman export upstart #{foreman_temp} -a #{application} -u deployer -l \/var\/www\/apps\/#{application}\/log -d #{current_path}&quot;       end       sudo &quot;mv #{foreman_temp}\/* \/etc\/init\/&quot;       sudo &quot;rm -r #{foreman_temp}&quot;     end   end     desc 'Restart application'   task :restart do     on roles(:app), in: :sequence, wait: 5 do       sudo &quot;restart #{application}&quot;     end   end    after :finishing, 'deploy:cleanup'   after :finishing, 'deploy:restart'    after :updating, 'deploy:symlink'    after :setup, 'deploy:foreman_init'    after :foreman_init, 'foreman:start'    before :foreman_init, 'rvm:hook'    before :setup, 'deploy:starting'   before :setup, 'deploy:updating'   before :setup, 'bundler:install' <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430 deploy \u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 4 \u043d\u043e\u0432\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: setup (\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430), foreman_init (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 upstart \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f), symlink (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a) \u0438 restart (\u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f). \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\/\u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u043a\u0438\u043c\u0438 \u0441\u0442\u0430\u0434\u0438\u044f\u043c\u0438, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c. <\/p>\n<p>  deploy:setup \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430: \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 shared \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0432 \u043f\u0430\u043f\u043a\u0443 shared \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 nginx, \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u043f\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 deploy:foreman_init, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u0442 upstart \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0447\u0435\u0440\u0435\u0437 foreman \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 \/etc\/init, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 <code> sudo start\/stop\/restart\/status \u0418\u041c\u042f_\u041f\u0420\u0418\u041b\u041e\u0416\u0415\u041d\u0418\u042f<\/code>. \u041f\u0435\u0440\u0435\u0434 deploy:setup \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u0448\u0430\u0433\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0434\u0435\u043f\u043b\u043e\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f <code>bundle install<\/code>. \u041f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u043f\u043b\u043e\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043c\u043b\u0438\u043d\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f Unicorn. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0435\u0446 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>before :deploy, 'git:deploy'<\/code> \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0434\u0435\u043f\u043b\u043e\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043c\u043c\u0438\u0442\u0438\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0415\u0449\u0435 \u0440\u0430\u0437:  <\/p>\n<ul>\n<li>\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>cap production deploy:setup<\/code> \u043f\u0440\u0438 \u0441\u0430\u043c\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u043f\u043b\u043e\u0435 \u0412\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<li>\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>cap production deploy<\/code> \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0434\u0435\u043f\u043b\u043e\u0435 \u0412\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<hr\/>\n<p>  \u0412\u043e\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043f\u043b\u043e\u044e \u0441\u0432\u043e\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 VPS. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u0435\u0441\u0442\u044c \u0438\u0441\u0442\u0438\u043d\u0430 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u043d\u043e \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Capistrano, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u0436\u0435 \u0443 \u043d\u043e\u0432\u0438\u0447\u043a\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u0422\u0430\u043a \u0436\u0435 \u044f \u043d\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043c\u043e\u0438 nginx.conf \u0438 unicorn.rb \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u0441 \u043d\u0438\u043c\u0438 \u0443\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0434 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043d\u0435\u0441\u0438\u043b\u044c\u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0445 VPS \u0438 \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0434\u0430\u0436\u0435 \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/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=\"http:\/\/habrahabr.ru\/post\/213269\/\"> http:\/\/habrahabr.ru\/post\/213269\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/0a6\/3aa\/2f6\/0a63aa2f640920d345e0d82d27fe3466.jpg\" \/><\/div>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435: \u0412\u044b \u2014 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u043b Ruby on Rails. \u0418 \u0442\u0443\u0442 \u0412\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u0442\u0430\u0434\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. <br \/>  \u0412\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 Heroku, \u043d\u043e \u0442\u0430\u043c\u043e\u0448\u043d\u0438\u0435 \u0446\u0435\u043d\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u0430\u044e\u0442\u0441\u044f. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0443\u043f\u0438\u0442\u044c VPS, \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u0438 \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0442\u0443\u0434\u0430. <br \/>  \u00ab\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0449\u0435? \u041d\u0430\u0439\u0434\u0443 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0433\u0430\u0439\u0434, \u0434\u0430 \u0441\u043b\u0435\u0434\u0430\u044e \u0432\u0441\u0451 \u043f\u043e \u043d\u0435\u043c\u0443\u00bb \u2014 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u0412\u044b. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u0430\u0439\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043d\u043e \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0435\u043b\u0430\u044e\u0442, \u2014 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0434\u0430 \u0438 \u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0443\u044e \u0432\u0442\u043e\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Capistrano.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0433\u0430\u0439\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c:   <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 nginx (\u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c PageSpeed), postgresql, redis<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 rvm, rails<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0433\u0435\u043c\u0430 foreman \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0412\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 Unicorn<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0433\u0435\u043c\u0430 Capistrano (v3.1) \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u043f\u043b\u043e\u044f <\/li>\n<\/ul>\n<p>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0433\u0430\u0439\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c, \u043d\u043e \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0441\u043e \u0441\u0442\u0430\u0436\u0435\u043c.<\/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-213269","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/213269","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=213269"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/213269\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}