{"id":718,"date":"2025-11-10T15:40:44","date_gmt":"2025-11-10T08:40:44","guid":{"rendered":"https:\/\/nbvps.anhtuanlqd.com\/?p=718"},"modified":"2025-11-10T15:40:45","modified_gmt":"2025-11-10T08:40:45","slug":"fix-permision-cho-folder-wordpress-tren-synology-voi-user-httphttp-2","status":"publish","type":"post","link":"https:\/\/nbvps.anhtuanlqd.com\/?p=718","title":{"rendered":"Fix Permision Cho Folder WordPress Tr\u00ean Synology V\u1edbi User Http:Http"},"content":{"rendered":"\n<p>Nh\u1edb ch\u1ea1y d\u01b0\u1edbi quy\u1ec1n \u201csudo -i\u201d<\/p>\n\n\n\n<p>File n\u00e0y ch\u1ea1y cho folder \u201c\/volume1\/web\/nbhome\/\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\nset -euo pipefail\n\n# === C\u1ea4U H\u00ccNH ===\nWEBROOT=\"\/volume1\/web\/nbhome\"\n\n# Th\u1eed \u0111o\u00e1n user\/group web tr\u00ean Synology\nWS_USER=\"\"\nfor u in http nginx www-data apache; do\n  if id \"$u\" &gt;\/dev\/null 2&gt;&amp;1; then WS_USER=\"$u\"; break; fi\ndone\nWS_USER=\"${WS_USER:-http}\"\nWS_GROUP=\"$WS_USER\"\n\necho \"Using web server user\/group: ${WS_USER}:${WS_GROUP}\"\necho \"Target root: ${WEBROOT}\"\nread -p \"Ti\u1ebfp t\u1ee5c? (y\/N) \" yn\n&#91;&#91; \"${yn:-N}\" =~ ^&#91;Yy]$ ]] || { echo \"H\u1ee7y.\"; exit 1; }\n\n# 1) Chuy\u1ec3n quy\u1ec1n s\u1edf h\u1eefu to\u00e0n b\u1ed9 site v\u1ec1 user\/group web\nchown -R \"${WS_USER}:${WS_GROUP}\" \"$WEBROOT\"\n\n# 2) CHMOD m\u1eb7c \u0111\u1ecbnh: th\u01b0 m\u1ee5c 755, file 644\nfind \"$WEBROOT\" -type d -not -path \"*\/\\.git\/*\" -exec chmod 755 {} \\;\nfind \"$WEBROOT\" -type f -not -path \"*\/\\.git\/*\" -exec chmod 644 {} \\;\n\n# 3) T\u0103ng quy\u1ec1n ghi cho khu v\u1ef1c WordPress c\u1ea7n ghi (wp-content)\nif &#91; -d \"$WEBROOT\/wp-content\" ]; then\n  chmod 775 \"$WEBROOT\/wp-content\"\n  find \"$WEBROOT\/wp-content\" -type d -exec chmod 775 {} \\;\n  find \"$WEBROOT\/wp-content\" -type f -exec chmod 664 {} \\;\n\n  # setgid \u0111\u1ec3 th\u01b0 m\u1ee5c con k\u1ebf th\u1eeba group (gi\u1eef ${WS_GROUP})\n  find \"$WEBROOT\/wp-content\" -type d -exec chmod g+s {} \\;\nfi\n\n# 4) B\u1ea3o v\u1ec7 file nh\u1ea1y c\u1ea3m\n&#91; -f \"$WEBROOT\/wp-config.php\" ] &amp;&amp; chmod 640 \"$WEBROOT\/wp-config.php\"\n&#91; -f \"$WEBROOT\/.htaccess\" ] &amp;&amp; chmod 644 \"$WEBROOT\/.htaccess\"\n&#91; -f \"$WEBROOT\/nginx.conf\" ] &amp;&amp; chmod 644 \"$WEBROOT\/nginx.conf\"\n\n# 5) (Tu\u1ef3 ch\u1ecdn) c\u1ea5p quy\u1ec1n ghi cho c\u00e1c th\u01b0 m\u1ee5c th\u01b0\u1eddng \u0111\u01b0\u1ee3c plugin d\u00f9ng\nfor d in uploads cache upgrade languages; do\n  if &#91; -d \"$WEBROOT\/wp-content\/$d\" ]; then\n    chmod 775 \"$WEBROOT\/wp-content\/$d\"\n    find \"$WEBROOT\/wp-content\/$d\" -type d -exec chmod 775 {} \\;\n    find \"$WEBROOT\/wp-content\/$d\" -type f -exec chmod 664 {} \\;\n  fi\ndone\n\n# 6) (Tu\u1ef3 ch\u1ecdn) n\u1ebfu d\u00f9ng WP-CLI trong cron v\u1edbi user kh\u00e1c, cho ph\u00e9p group ghi root site\n# chmod 775 \"$WEBROOT\"\n# find \"$WEBROOT\" -maxdepth 1 -type f -name \"*.php\" -exec chmod 664 {} \\;\n\necho \"Ho\u00e0n t\u1ea5t. Ki\u1ec3m tra l\u1ea1i quy\u1ec1n v\u00e0 th\u1eed c\u1eadp nh\u1eadt plugin\/theme trong WP.\"<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nh\u1edb ch\u1ea1y d\u01b0\u1edbi quy\u1ec1n \u201csudo -i\u201d File n\u00e0y ch\u1ea1y cho folder \u201c\/volume1\/web\/nbhome\/\u201d<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[2,5,23],"tags":[227,226,145],"class_list":["post-718","post","type-post","status-publish","format-standard","hentry","category-linux","category-synology","category-tips-and-trick","tag-fix-permission","tag-permission","tag-wordpress"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=718"}],"version-history":[{"count":1,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/718\/revisions"}],"predecessor-version":[{"id":719,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/718\/revisions\/719"}],"wp:attachment":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}