WordPress 文件权限设置脚本

参考网上经验,写了个WP文件权限设置脚本。方便部署迁移只用。

01#!/bin/bash
02# $1 => wp_path
03if [ 0 -eq $# ]; then
04exit
05fi
06if [ ! -d "${1}" ]; then
07echo invalid path.
08exit
09fi
10cd ${1}
11if [ ! -d "./wp-content/" ]; then
12echo wordpress not found.
13exit
14fi
15chgrp www-data ./ -R
16chmod 644 ./ -R
17chmod 755 ./
18find ./ -type d -exec chmod 755 {} \;
19find ./ -iname "*.php" -exec chmod 644 {} \;
20chmod 775 ./wp-content/
21chmod 775 ./wp-content/plugins/
22chmod 775 ./wp-content/themes/
23find ./wp-content/themes/ -iname "*.php" -exec chmod 664 {} \;
24find ./wp-content/themes/ -iname "*.css" -exec chmod 664 {} \;
25chmod 644 ./wp-content/themes/index.php
26if [ -d "./wp-content/uploads" ]; then
27chmod 664 ./wp-content/uploads/ -R
28chmod 775 ./wp-content/uploads/
29find ./wp-content/uploads/ -type d -exec chmod 775 {} \;
30fi
31if [ -d "./wp-content/upgrade" ]; then
32chmod 775 ./wp-content/upgrade/
33fi
34echo done.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注