WordPress 文件权限设置脚本

参考网上经验,写了个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.

wordpress 迁移后,上传文件失败的问题解决

本来一路顺风,环境搭建有点轻车熟路的感觉,中途还优化了一些配置文件结构(nginx+spawn-fcgi),没想到测试的时候,发现插件更新失败,提示:

Could not create directory. /www/blog/wp-content/upgrade/akismet.tmp

同时上传图片也失败,提示:

The uploaded file could not be moved to /www/blog/wp-content/uploads/2011/01/

个杯具的,经排查:

继续阅读wordpress 迁移后,上传文件失败的问题解决