写了一个规范网站目录的权限脚本:

#!/bin/sh
#
#desc:change wwwroot permission
#auther:luohui@forchina.com
#date:2009.01.17

#网站目录
wwwroot=’/var/www/newihompy’

#排除的目录
exclude=(“/var/www/newihompy/attachment” “/var/www/newihompy/uc/data” “/var/www/newihompy/theme” “/var/www/newihompy/pet/images” “/var/www/newihompy/data” “/var/www/newihompy/uc_client/data”)

#文件所有者
proguser=’root.root’


foreachd(){
    for file in 1/*
    do
            if [ -d file ]
            then
            isexclude=’0’
            for exfile in {exclude[*]}
            do
                if [[ exfile file ]]
                then
                    isexclude=’1’
                fi
            done

            if [[ isexclude ‘0’ ]]
            then
                echo “chown proguser file”
                chown proguser file
                echo “chmod 755 file”
                chmod 755 file
                foreachd file
            fi
        else
            echo “chown proguser file”
            chown proguser file
            echo “chmod 644 file”
            chmod 644 file
            fi
    done
}

echo “chown proguser wwwroot”
chown proguser wwwroot
echo “chmod 755 wwwroot”
chmod 755 wwwroot

foreachd wwwroot

执行完后所以目录为755,文件为644。