参考网上经验,写了个WP文件权限设置脚本。方便部署迁移只用。
#!/bin/bash # $1 => wp_path if [ 0 -eq $# ]; then exit fi if [ ! -d "${1}" ]; then echo invalid path. exit fi cd ${1} if [ ! -d "./wp-content/" ]; then echo wordpress not found. exit fi chgrp www-data ./ -R chmod 644 ./ -R chmod 755 ./ find ./ -type d -exec chmod 755 {} \; find ./ -iname "*.php" -exec chmod 644 {} \; chmod 775 ./wp-content/ chmod 775 ./wp-content/plugins/ chmod 775 ./wp-content/themes/ find ./wp-content/themes/ -iname "*.php" -exec chmod 664 {} \; find ./wp-content/themes/ -iname "*.css" -exec chmod 664 {} \; chmod 644 ./wp-content/themes/index.php if [ -d "./wp-content/uploads" ]; then chmod 664 ./wp-content/uploads/ -R chmod 775 ./wp-content/uploads/ find ./wp-content/uploads/ -type d -exec chmod 775 {} \; fi if [ -d "./wp-content/upgrade" ]; then chmod 775 ./wp-content/upgrade/ fi echo done.