{"id":284,"date":"2025-05-22T07:43:33","date_gmt":"2025-05-22T07:43:33","guid":{"rendered":"https:\/\/blog.chaiyakul.com\/?p=284"},"modified":"2025-05-22T10:28:21","modified_gmt":"2025-05-22T10:28:21","slug":"docker-php5-6-centos9-permission-root","status":"publish","type":"post","link":"https:\/\/blog.chaiyakul.com\/index.php\/2025\/05\/22\/docker-php5-6-centos9-permission-root\/","title":{"rendered":"\u0e43\u0e2b\u0e49 Docker PHP5.6 \u0e43\u0e19 CentOS9 \u0e23\u0e31\u0e19\u0e14\u0e49\u0e27\u0e22\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e02\u0e2d\u0e07 root \u0e41\u0e25\u0e30\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e44\u0e1f\u0e25\u0e4c"},"content":{"rendered":"\n<p>\u0e43\u0e0a\u0e49 flag <code>--privileged<\/code> (\u0e44\u0e21\u0e48\u0e41\u0e19\u0e30\u0e19\u0e33\u0e16\u0e49\u0e32\u0e44\u0e21\u0e48\u0e08\u0e33\u0e40\u0e1b\u0e47\u0e19)<\/p>\n\n\n\n<p>\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49 container \u0e21\u0e35\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e23\u0e30\u0e14\u0e31\u0e1a\u0e2a\u0e39\u0e07\u0e2a\u0e38\u0e14 \u0e40\u0e2b\u0e21\u0e37\u0e2d\u0e19 root \u0e41\u0e1a\u0e1a\u0e40\u0e15\u0e47\u0e21<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker run -d \\\n  --name php56-fpm \\\n  -p 9006:9000 \\\n  -v \/var\/www\/html\/old-chaiyakul.com:\/var\/www\/html\/old-chaiyakul.com \\\n  -v \/opt\/php56\/php.ini:\/usr\/local\/etc\/php\/php.ini \\\n  --privileged \\\n  --restart unless-stopped \\\n  php:5.6-fpm\n<\/pre><\/div>\n\n\n<p>\u0e16\u0e49\u0e32\u0e43\u0e0a\u0e49 <code>--privileged<\/code> \u0e41\u0e25\u0e49\u0e27\u0e43\u0e19 CMS \u0e22\u0e31\u0e07\u0e02\u0e36\u0e49\u0e19\u0e27\u0e48\u0e32 Directory Permissions \u0e40\u0e1b\u0e47\u0e19 <strong>Unwritable<\/strong> \u0e41\u0e1b\u0e25\u0e27\u0e48\u0e32:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0e15\u0e31\u0e27 container \u0e23\u0e31\u0e19\u0e14\u0e49\u0e27\u0e22\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e2a\u0e39\u0e07\u0e41\u0e25\u0e49\u0e27<\/li>\n\n\n\n<li>\u0e41\u0e15\u0e48\u0e1b\u0e31\u0e0d\u0e2b\u0e32\u0e2d\u0e22\u0e39\u0e48\u0e17\u0e35\u0e48 <strong>permission \u0e2b\u0e23\u0e37\u0e2d ownership \u0e02\u0e2d\u0e07\u0e44\u0e1f\u0e25\u0e4c\/\u0e42\u0e1f\u0e25\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e17\u0e35\u0e48\u0e41\u0e21\u0e1b\u0e40\u0e02\u0e49\u0e32\u0e21\u0e32<\/strong> \u0e44\u0e21\u0e48\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07 (\u0e1a\u0e19 host)<\/li>\n<\/ul>\n\n\n\n<p>\u0e2a\u0e32\u0e40\u0e2b\u0e15\u0e38\u0e2b\u0e25\u0e31\u0e01 \u0e46 \u0e17\u0e35\u0e48 cms \u0e41\u0e08\u0e49\u0e07\u0e27\u0e48\u0e32 Unwritable<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Owner\/Group \u0e02\u0e2d\u0e07\u0e44\u0e1f\u0e25\u0e4c\u0e44\u0e21\u0e48\u0e15\u0e23\u0e07\u0e01\u0e31\u0e1a user \u0e43\u0e19 container<\/strong><br>cms \u0e43\u0e19 container \u0e21\u0e31\u0e01\u0e23\u0e31\u0e19\u0e14\u0e49\u0e27\u0e22 user \u0e40\u0e0a\u0e48\u0e19 <code>www-data<\/code> (UID 33)<br>\u0e41\u0e15\u0e48 folder \u0e1a\u0e19 host \u0e2d\u0e32\u0e08\u0e40\u0e1b\u0e47\u0e19\u0e40\u0e08\u0e49\u0e32\u0e02\u0e2d\u0e07\u0e42\u0e14\u0e22 user \u0e2d\u0e37\u0e48\u0e19 (\u0e40\u0e0a\u0e48\u0e19 root \u0e2b\u0e23\u0e37\u0e2d user \u0e1b\u0e01\u0e15\u0e34) \u0e17\u0e33\u0e43\u0e2b\u0e49 PHP-FPM \u0e40\u0e02\u0e35\u0e22\u0e19\u0e44\u0e21\u0e48\u0e44\u0e14\u0e49<\/li>\n\n\n\n<li><strong>Permission \u0e02\u0e2d\u0e07\u0e44\u0e1f\u0e25\u0e4c\/\u0e42\u0e1f\u0e25\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e44\u0e21\u0e48\u0e2d\u0e19\u0e38\u0e0d\u0e32\u0e15\u0e43\u0e2b\u0e49\u0e40\u0e02\u0e35\u0e22\u0e19<\/strong><\/li>\n<\/ol>\n\n\n\n<p><u><strong>\u0e27\u0e34\u0e18\u0e35\u0e41\u0e01\u0e49\u0e44\u0e02<\/strong><\/u><\/p>\n\n\n\n<p>\u0e27\u0e34\u0e18\u0e35\u0e14\u0e39 user \u0e02\u0e2d\u0e07\u0e42\u0e1b\u0e23\u0e40\u0e0b\u0e2a php-fpm<\/p>\n\n\n\n<p>1.\u0e40\u0e02\u0e49\u0e32 container<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker exec -it php56-fpm bash\n<\/pre><\/div>\n\n\n<p>2.\u0e14\u0e39 user \u0e1b\u0e31\u0e08\u0e08\u0e38\u0e1a\u0e31\u0e19\u0e17\u0e35\u0e48\u0e2d\u0e22\u0e39\u0e48\u0e43\u0e19 shell (\u0e19\u0e48\u0e32\u0e08\u0e30 root \u0e2d\u0e22\u0e39\u0e48\u0e41\u0e25\u0e49\u0e27)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwhoami\n<\/pre><\/div>\n\n\n<p>3.\u0e25\u0e2d\u0e07\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e44\u0e1f\u0e25\u0e4c\u0e42\u0e1b\u0e23\u0e40\u0e0b\u0e2a php-fpm (\u0e16\u0e49\u0e32\u0e21\u0e35) \u0e14\u0e49\u0e27\u0e22 <code>ls -l<\/code> \u0e14\u0e39 owner<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nls -l \/usr\/local\/sbin\/php-fpm\n<\/pre><\/div>\n\n\n<p>4.\u0e25\u0e2d\u0e07\u0e14\u0e39\u0e44\u0e1f\u0e25\u0e4c config \u0e02\u0e2d\u0e07 php-fpm \u0e27\u0e48\u0e32\u0e01\u0e33\u0e2b\u0e19\u0e14 user \u0e44\u0e27\u0e49\u0e17\u0e35\u0e48\u0e44\u0e2b\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncat \/usr\/local\/etc\/php-fpm.d\/www.conf | grep &#039;^user\\|^group&#039;\n<\/pre><\/div>\n\n\n<p>\u0e2b\u0e23\u0e37\u0e2d<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncat \/usr\/local\/etc\/php-fpm.conf | grep &#039;^user\\|^group&#039;\n<\/pre><\/div>\n\n\n<p>\u0e42\u0e14\u0e22\u0e1b\u0e01\u0e15\u0e34 php-fpm \u0e21\u0e31\u0e01\u0e08\u0e30\u0e23\u0e31\u0e19\u0e14\u0e49\u0e27\u0e22 user \u0e40\u0e0a\u0e48\u0e19 <code>www-data<\/code> \u0e2b\u0e23\u0e37\u0e2d <code>php-fpm<\/code><\/p>\n\n\n\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nroot@7dc62a95d4b7:\/var\/www\/html# cat \/usr\/local\/etc\/php-fpm.d\/www.conf | grep &#039;^user\\|^group&#039;\nuser = www-data\ngroup = www-data\n<\/pre><\/div>\n\n\n<p>\u0e16\u0e49\u0e32\u0e2d\u0e22\u0e32\u0e01\u0e40\u0e0a\u0e47\u0e04 UID \u0e02\u0e2d\u0e07 user \u0e17\u0e35\u0e48 php-fpm \u0e23\u0e31\u0e19<\/p>\n\n\n\n<p>\u0e1e\u0e2d\u0e23\u0e39\u0e49\u0e0a\u0e37\u0e48\u0e2d user \u0e08\u0e32\u0e01 config \u0e41\u0e25\u0e49\u0e27 \u0e25\u0e2d\u0e07<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nid www-data\n<\/pre><\/div>\n\n\n<p>\u0e40\u0e0a\u0e48\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nroot@7dc62a95d4b7:\/var\/www\/html# id www-data\nuid=33(www-data) gid=33(www-data) groups=33(www-data)\n<\/pre><\/div>\n\n\n<p><u><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e01\u0e32\u0e23\u0e41\u0e01\u0e49\u0e44\u0e02\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e4c\u0e43\u0e19\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07\u0e43\u0e2b\u0e49\u0e15\u0e23\u0e07\u0e01\u0e31\u0e1a Docker<\/strong><\/u><\/p>\n\n\n\n<p>\u0e16\u0e49\u0e32 config php-fpm \u0e1a\u0e2d\u0e01\u0e27\u0e48\u0e32<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nuser = www-data\ngroup = www-data\n<\/pre><\/div>\n\n\n<p>\u0e01\u0e47\u0e43\u0e2b\u0e49 <code>chown<\/code> \u0e42\u0e1f\u0e25\u0e40\u0e14\u0e2d\u0e23\u0e4c\u0e43\u0e19 host \u0e43\u0e2b\u0e49\u0e40\u0e1b\u0e47\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo chown -R 33:33 \/var\/www\/html\/old-chaiyakul.com\n<\/pre><\/div>\n\n\n<p>(\u0e40\u0e1e\u0e23\u0e32\u0e30 <code>www-data<\/code> \u0e21\u0e35 UID=33)<\/p>\n\n\n\n<p>\u0e01\u0e25\u0e31\u0e1a\u0e44\u0e1b\u0e17\u0e35\u0e48 host \u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07\u0e2b\u0e25\u0e31\u0e01 (\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07\u0e17\u0e35\u0e48\u0e25\u0e07 Docker)<\/p>\n\n\n\n<p>\u0e15\u0e31\u0e49\u0e07 permission \u0e02\u0e2d\u0e07\u0e42\u0e1f\u0e25\u0e40\u0e14\u0e2d\u0e23\u0e4c CMS \u0e43\u0e2b\u0e49\u0e15\u0e23\u0e07\u0e01\u0e31\u0e1a UID:GID \u0e19\u0e31\u0e49\u0e19<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo chown -R 33:33 \/var\/www\/html\/old-chaiyakul.com\nsudo chmod -R 755 \/var\/www\/html\/old-chaiyakul.com\n<\/pre><\/div>\n\n\n<p>\u0e23\u0e35\u0e2a\u0e15\u0e32\u0e23\u0e4c\u0e17 container<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker restart php56-fpm\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0e43\u0e0a\u0e49 flag &#8211;privileged (\u0e44\u0e21\u0e48\u0e41\u0e19\u0e30\u0e19\u0e33\u0e16\u0e49\u0e32\u0e44\u0e21\u0e48\u0e08\u0e33\u0e40\u0e1b\u0e47\u0e19) \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49 c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","footnotes":""},"categories":[105,9],"tags":[],"class_list":["post-284","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/comments?post=284"}],"version-history":[{"count":5,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/284\/revisions"}],"predecessor-version":[{"id":294,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/posts\/284\/revisions\/294"}],"wp:attachment":[{"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/media?parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/categories?post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chaiyakul.com\/index.php\/wp-json\/wp\/v2\/tags?post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}