{"id":1138,"date":"2020-02-06T15:07:18","date_gmt":"2020-02-06T12:07:18","guid":{"rendered":"https:\/\/blog.5flor.ru\/?p=1138"},"modified":"2020-02-06T15:22:45","modified_gmt":"2020-02-06T12:22:45","slug":"%d0%b7%d0%b0%d0%bf%d1%83%d1%81%d0%ba-%d0%b4%d0%b2%d1%83%d1%85-%d0%bd%d0%be%d0%b4-%d0%b4%d0%bb%d1%8f-web-%d0%ba%d0%bb%d0%b0%d1%81%d1%82%d0%b5%d1%80%d0%b0-nginx","status":"publish","type":"post","link":"https:\/\/blog.5flor.ru\/?p=1138","title":{"rendered":"\u0417\u0430\u043f\u0443\u0441\u043a \u0434\u0432\u0443\u0445 \u043d\u043e\u0434 \u0434\u043b\u044f web \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 nginx"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">\u0437\u0430\u043f\u0443\u0441\u043a \u0434\u0432\u0443\u0445 \u043d\u043e\u0434 \u0434\u043b\u044f web \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 nginx (\u0441\u0430\u043c \n\u043f\u0440\u043e\u043a\u0441\u0438-\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435)\n\n\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c docker\n#yum install docker\n\n\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441:\n#systemctl enable docker.service\n#systemctl start docker.service\n\n\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u0434 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0430\u043f\u043a\u0443 \u0438 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u0435:\n#mkdir \/site (\u043f\u0430\u043f\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e)\n#cd \/site\n\n\u0414\u0430\u043b\u044c\u0448\u0435 \u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0430\u043f\u043e\u043a \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:\n#mkdir mysql nginx php\n\n\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0434\u043b\u044f nginx:\n#cd nginx\n#mkdir core html logs www\n\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f Nginx:\n#cd \/core\n#mkdir node1 node2\n\u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u043e \u0444\u0430\u0439\u043b\u0443 test.conf\n\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:\n\n server {\n listen 81; ## listen for ipv4; this line is default and implied\n root \/var\/www\/html\/test.ru;\n  index index.php index.html index.htm;\n # Make site accessible from http:\/\/localhost\/\n  server_name test.ru;\n Disable sendfile as per https:\/\/docs.vagrantup.com\/v2\/synced-folders\/virtualbox.html\n sendfile off;\n Add stdout logging\n error_log \/var\/log\/nginx\/test.ru-error.log info;\n access_log \/var\/log\/nginx\/test.ru-access.log;\n Add option for x-forward-for (real ip when behind elb)\n real_ip_header X-Forwarded-For;\n set_real_ip_from 172.16.0.0\/12;\n block access to sensitive information about git\n location \/.git {\n deny all;\n return 403;\n }\nlocation \/ {\n First attempt to serve request as file, then\n as directory, then fall back to index.html\n try_files $uri $uri\/ =404;\n }\n error_page 404\n \/404.html;\n location = \/404.html {\n root \/var\/www\/errors;\n internal;\n              }\n location ^~ \/sad.svg {\n alias \/var\/www\/errors\/sad.svg;\n access_log off;\n           }\n location ^~ \/twitter.svg {\n alias \/var\/www\/errors\/twitter.svg;\n access_log off;\n }\n location ^~ \/gitlab.svg {\n alias \/var\/www\/errors\/gitlab.svg;\n access_log off;\n }\n pass the PHP scripts to FastCGI server listening on socket\n #\n location ~ .php$ {\n try_files $uri =404;\n fastcgi_split_path_info ^(.+.php)(\/.+)$;\n                                                                                                                                                                                                                              fastcgi_pass\n unix:\/var\/run\/php-fpm.sock;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n fastcgi_param SCRIPT_NAME $fastcgi_script_name;\n fastcgi_index index.php;\n# fastcgi_param GEOIP2_LONGITUDE $geoip2_data_longitude;\n# fastcgi_param GEOIP2_LATITUDE $geoip2_data_latitude;\n# fastcgi_param GEOIP2_CONTINENT_CODE $geoip2_data_continent_code;\n# fastcgi_param GEOIP2_CONTINENT_NAME $geoip2_data_continent_name;\n# fastcgi_param GEOIP2_COUNTRY_CODE $geoip2_data_country_code;\n# fastcgi_param GEOIP2_COUNTRY_NAME $geoip2_data_country_name;\n# fastcgi_param GEOIP2_STATE_CODE $geoip2_data_state_code;\n# fastcgi_param GEOIP2_STATE_NAME $geoip2_data_state_name;\n# fastcgi_param GEOIP2_CITY_NAME $geoip2_data_city_name;\n# fastcgi_param GEOIP2_POSTAL_CODE $geoip2_data_postal_code;\ninclude fastcgi_params;\n       }\n location ~* .(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {\n expires           5d;\n      }\n deny access to . files, for security\n #\n location ~ \/. {\n log_not_found off;\n deny all;\n }\n location ^~ \/.well-known {\n allow all;\n auth_basic off;\n }\n }\n\n\u0438 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0444\u0430\u0439\u043b \u0432 node2 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u043e\u0440\u0442\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0435\u0442 nginx\n\u0412 \u043f\u0430\u043f\u043a\u0435 \/site\/nginx\/logs \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0434\u0432\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438\n#cd \/site\/nginx\/logs\n#mkdir node1 node2\n\n\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0437 \u0441 nginx+php-fpm\n#docker pull richarvey\/nginx-php-fpm:latest\n\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b\n#docker run -d --net=host -v \/site\/nginx\/www\/:\/var\/www\/html -v \/site\/nginx\/core\/node1:\/etc\/nginx\/sites-enabled -v \/site\/nginx\/Logs\/node1:\/var\/log\/nginx --name node1 richarvey\/nginx-php-fpm\n#docker run -d --net=host -v \/site\/nginx\/www\/:\/var\/www\/html -v \/site\/nginx\/core\/node2:\/etc\/nginx\/sites-enabled -v \/site\/nginx\/Logs\/node2:\/var\/log\/nginx --name node2 richarvey\/nginx-php-fpm\n\n--name node2 \u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u0442\u0430\u043a \u0441 \u043d\u0438\u043c \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c\n\n\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u00a0<strong>-d<\/strong>\u00a0\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0432\u044f\u0437\u0430\u0442\u044c \n\u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u043e\u0442 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u0442.\u0435. \n\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0434\u0435\u043c\u043e\u043d\u0430 \n\n\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 --net=host \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e\u0442 \u0442\u043e\u043c, \n\u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0445\u043e\u0441\u0442\u0435, \n\u0430 \u043d\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0434\u0441\u0435\u0442\u0438(\u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e). \n\u0442\u0430\u043a \u043f\u0440\u043e\u0449\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u043e\u0440\u0442\u0430\u043c.\n\n-v \u043f\u0440\u043e\u0431\u0440\u043e\u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0445\u043e\u0441\u0442.\n\n\u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \n\u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.\n\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:\n<a href=\"https:\/\/docs.docker.com\/config\/containers\/start-containers-automatically\/\">https:\/\/docs.docker.com\/config\/containers\/start-containers-automatically\/<\/a> \n\u043d\u043e \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \ndocker run  --restart=always\n\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b update:\n#docker update --restart=always node1\n#docker update --restart=always node2 \n\n\u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:\n#docker ps -a\n\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432\n#docker rm \u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438\u043b\u0438 id\n\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\n#docker stop site\n#docker start site\n\n#docker exec --tty --interactive \"\u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\" bash\n\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434.\n\n<code>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c (\u043f\u043e\u0441\u043b\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438) <\/code>\n#<code>docker run --rm -ti my_container my_image <\/code>\n<code>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u0440\u0430\u0437\u043e\u0432 <\/code>\n#<code>docker images <\/code>\n<code>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043d\u0435\u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b <\/code>\n#<code>docker container prune -f <\/code>\n<code>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u044b <\/code>\n#<code>docker image prune -fa <\/code>\n<code>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 <\/code>\n#<code>docker logs my_container -f<\/code> <\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0437\u0430\u043f\u0443\u0441\u043a \u0434\u0432\u0443\u0445 \u043d\u043e\u0434 \u0434\u043b\u044f web \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 nginx (\u0441\u0430\u043c \u043f\u0440\u043e\u043a\u0441\u0438-\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435) \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c docker #yum install docker \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441: #systemctl enable docker.service #systemctl start docker.service \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u0434 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0430\u043f\u043a\u0443 \u0438 \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u0435: #mkdir \/site &hellip; <a href=\"https:\/\/blog.5flor.ru\/?p=1138\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,1],"tags":[],"class_list":["post-1138","post","type-post","status-publish","format-standard","hentry","category-docker","category-1"],"_links":{"self":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/posts\/1138"}],"collection":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1138"}],"version-history":[{"count":7,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/posts\/1138\/revisions"}],"predecessor-version":[{"id":1145,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=\/wp\/v2\/posts\/1138\/revisions\/1145"}],"wp:attachment":[{"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.5flor.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}