{"id":78,"date":"2016-09-02T19:45:59","date_gmt":"2016-09-02T16:45:59","guid":{"rendered":"https:\/\/qwertys.ru\/?p=78"},"modified":"2017-03-23T00:06:41","modified_gmt":"2017-03-22T21:06:41","slug":"php-fpm-%d0%b2-chroot-%d0%be%d0%ba%d1%80%d1%83%d0%b6%d0%b5%d0%bd%d0%b8%d0%b8","status":"publish","type":"post","link":"https:\/\/qwertys.ru\/?p=78","title":{"rendered":"PHP-FPM \u0432  chroot \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438."},"content":{"rendered":"<p>\u041e\u0434\u043d\u0430 \u0438\u0437 &#171;\u0444\u0438\u0447&#187; PHP-FPM &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 chroot \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438. \u0412 \u0442\u0435\u043e\u0440\u0438\u0438, \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0437\u0430\u0441\u0447\u0435\u0442 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442, \u0442. \u0435. \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c PHP, \u0442\u043e \u043e\u043d \u0432\u044b\u0448\u0435 \u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 PHP-FPM, \u043e\u043d \u043d\u0435 \u0443\u0439\u0434\u0435\u0442.<\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432\u0441\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0440\u0430\u0434\u0443\u0436\u043d\u043e.<br \/>\n<!--more--><\/p>\n<p>\u0421\u0432\u044f\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u0441 \u0442\u0435\u043c, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, CMS Drupal 8) \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u043c \u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 \u043a\u0430\u043a-\u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0442\u043e \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0442. \u043a. \u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>\/dev\/urandom<\/code><\/p>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e \u0433\u0440\u0430\u0431\u043b\u044f\u043c, \u044f \u0432\u0441\u0435 \u0436\u0435 \u0441\u0443\u043c\u0435\u043b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Drupal \u0432 PHP-FPM \u0432 chroot \u0438 NGINX, \u0441\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u043e\u043d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439. \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043b\u044f \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c.<\/p>\n<p>1. \u0421\u043f\u0435\u0440\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0443. \u042d\u0442\u043e \u043f\u0430\u043f\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c PHP-FPM.<\/p>\n<p>\u0412 \u043d\u0435\u0439 \u043f\u0430\u043f\u043a\u0430 tmp \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0439, logs \u0434\u043b\u044f \u043b\u043e\u0433\u043e\u0432 PHP-FPM (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e), \u043f\u0430\u043f\u043a\u0430 htdocs &#8212; \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0441\u0430\u0439\u0442\u0430. \u0412 etc, usr \u0438 dev \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0430\u043f\u043a\u0438 \u0441 \u0441\u0430\u043c\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b.<\/p>\n<pre class=\"code_block\">mkdir -p \/path\/to\/chrooted\/folder\/{tmp,etc,dev,usr\/share\/zoneinfo,logs,htdocs}\r\ntouch \/path\/to\/chrooted\/folder\/dev\/random \/path\/to\/chrooted\/folder\/dev\/urandom \\\r\n\/path\/to\/chrooted\/folder\/etc\/localtime \/path\/to\/chrooted\/folder\/etc\/hosts \\\r\n\/path\/to\/chrooted\/folder\/etc\/resolv.conf\r\nmount -o bind,ro,noexec \/dev\/random \/path\/to\/chrooted\/folder\/dev\/random\r\nmount -o bind,ro,noexec \/dev\/urandom \/path\/to\/chrooted\/folder\/dev\/urandom\r\nmount -o bind,ro,noexec \/etc\/localtime \/path\/to\/chrooted\/folder\/etc\/localtime\r\nmount -o bind,ro,noexec \/etc\/hosts \/path\/to\/chrooted\/folder\/etc\/resolv.conf\r\nmount -o bind,ro,noexec \/usr\/share\/zoneinfo \/path\/to\/chrooted\/folder\/usr\/share\/zoneinfo\r\nchown -R www-data:www-data \/path\/to\/chrooted\/folder\/htdocs\r\nchmod 1777 \/path\/to\/chrooted\/folder\/tmp<\/pre>\n<p>2. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0443\u043b PHP-FPM. \u0414\u043b\u044f Debian-based \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432 <code>\/etc\/php5\/fpm\/pool.d<\/code>:<\/p>\n<pre class=\"code_block\">[myawesomesite.ru]\r\nuser = www-data\r\ngroup = www-data\r\n\r\nprefix = \/path\/to\/chrooted\/folder\r\nchroot = $prefix\r\nchdir = \/htdocs\r\n\r\nlisten = php5-fpm.sock\r\nlisten.owner = www-data\r\nlisten.group = www-data\r\nlisten.mode = 0660\r\n\r\naccess.log = logs\/$pool.access.log\r\n\r\npm = static\r\npm.max_children = 1<\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0443\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 nginx. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0430 \u0440\u044f\u0434 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0435.<\/p>\n<p>3. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c nginx.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre class=\"code_block\">server {\r\n        listen 11.22.33.44:80;\r\n        server_name myawesomesite.ru;\r\n\r\n        root \/path\/to\/chrooted\/folder\/htdocs;\r\n\r\n        location ~* (\\.php(\\?.(.)*)?|\/)$ {\r\n                fastcgi_index index.php;\r\n                include \/etc\/nginx\/conf.d\/http_fastcgi.conf;\r\n                fastcgi_pass unix:\/path\/to\/chrooted\/folder\/php5-fpm.sock;\r\n        }\r\n\r\n        location \/ {\r\n                index index.php;\r\n                try_files $uri =404;\r\n        }\r\n}<\/pre>\n<p>\/etc\/nginx\/conf.d\/http_fastcgi.conf:<\/p>\n<pre class=\"code_block\">fastcgi_param  SCRIPT_FILENAME    \/htdocs$fastcgi_script_name;\r\nfastcgi_param  QUERY_STRING       $query_string;\r\nfastcgi_param  REQUEST_METHOD     $request_method;\r\nfastcgi_param  CONTENT_TYPE       $content_type;\r\nfastcgi_param  CONTENT_LENGTH     $content_length;\r\n\r\nfastcgi_param  SCRIPT_NAME        $fastcgi_script_name;\r\nfastcgi_param  REQUEST_URI        $request_uri;\r\nfastcgi_param  DOCUMENT_URI       $document_uri;\r\nfastcgi_param  DOCUMENT_ROOT      \/htdocs;\r\nfastcgi_param  SERVER_PROTOCOL    $server_protocol;\r\nfastcgi_param  HTTPS              $https if_not_empty;\r\n\r\nfastcgi_param  GATEWAY_INTERFACE  CGI\/1.1;\r\nfastcgi_param  SERVER_SOFTWARE    nginx\/$nginx_version;\r\n\r\nfastcgi_param  REMOTE_ADDR        $remote_addr;\r\nfastcgi_param  REMOTE_PORT        $remote_port;\r\nfastcgi_param  SERVER_ADDR        $server_addr;\r\nfastcgi_param  SERVER_PORT        $server_port;\r\nfastcgi_param  SERVER_NAME        $server_name;<\/pre>\n<p>4. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre class=\"code_block\">php5-fpm -t\r\nnginx -t\r\nservice nginx start\r\nservice php-fpm start<\/pre>\n<p>\u0418 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0441\u0430\u0439\u0442 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041e\u0434\u043d\u0430 \u0438\u0437 &#171;\u0444\u0438\u0447&#187; PHP-FPM &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 chroot \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438. \u0412 \u0442\u0435\u043e\u0440\u0438\u0438, \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0437\u0430\u0441\u0447\u0435\u0442 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442, \u0442. \u0435. \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c PHP, \u0442\u043e \u043e\u043d \u0432\u044b\u0448\u0435 \u0442\u043e\u0439 \u043f\u0430\u043f\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 PHP-FPM, \u043e\u043d \u043d\u0435 \u0443\u0439\u0434\u0435\u0442. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432\u0441\u0435 \u0434\u0430\u043b\u0435\u043a\u043e [&#8230;] <\/p>\n<p class=\"more-link-container\"><a href=\"https:\/\/qwertys.ru\/?p=78\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#171;PHP-FPM \u0432  chroot \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438.&#187;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[17,5],"tags":[21,15,20,16],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/78"}],"collection":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78"}],"version-history":[{"count":2,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/qwertys.ru\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qwertys.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}