所以我一直在閱讀上的WordPress正確的權限各個崗位最引人注目的是以下正確的權限:創造的.bash_profile別名爲獲得WordPress的
[1] [1]:Correct file permissions for WordPress
[1] [1]:https://codex.wordpress.org/Hardening_WordPress
有人可以解釋是否將我的用戶添加到www數據組是一個好主意。爲什麼我需要這樣做,因爲我不完全明白這一點,我是否需要這樣做...
我剛剛花了大量的時間更新我所有的WordPress網站,並開始保護他們在更高的水平。我想要麼建立一個單一的命令或腳本,這樣我可以快速設置
- 之間正確的權限設置的WordPress
- 更新插件和WordPress的
- 普通淬火的WordPress,用戶仍然可以編輯和上傳的媒體,但它被安全地鎖定。
所以最好在.bash_profile中創建一個.sh文件或創建一個別名。我有大約14個wordpress網站,我剛剛花時間更新和保護現在我需要清理權限。很顯然,我正在尋求以最有效的方式來做到這一點。
的.bash_profile文件選項迄今:
建立Wordpress和更新
alias suwpchn='sudo chown -R www-data:www-data *; find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; ls -la;'
但我得到的錯誤是
發現:路徑必須先表達:找到
但我也想有一個bash腳本,我可以叫,它會一一設置這是我從邁克爾科尼利亞羅發現WordPress網站權限:
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro (https://gist.github.com/macbleser/9136424)
#
WP_ROOT=${1:-.} # <-- wordpress root directory, current directory by default
[ -e "$WP_ROOT/wp-config.php" ] || { echo "Usage: $0 /path/to/wordpress"; exit; } # <-- detect that the directory is a wordpress root
WP_OWNER=$(id -u $(logname)) # <-- wordpress owner (This assumes the wordpress owner is the logged in user)
WP_GROUP=$(id -g $(logname)) # <-- wordpress group (This assumes the wordpress owner is the logged in user)
WS_GROUP=$(
source /etc/apache2/envvars 2>/dev/null && # This works on debian-based systems at least
echo "$APACHE_RUN_GROUP" ||
echo nobody
) # <-- webserver group
echo "Fixing permissions on $WP_ROOT"
echo "Wordpress owner.group: $WP_OWNER.$WP_GROUP"
echo "Web Server group: $WS_GROUP"
echo 'reset to safe defaults'
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
find ${WP_ROOT} -type d -exec chmod 755 {} \;
find ${WP_ROOT} -type f -exec chmod 644 {} \;
echo 'allow wordpress to manage wp-config.php (but prevent world access)'
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 660 ${WP_ROOT}/wp-config.php
echo 'allow wordpress to manage .htaccess'
touch ${WP_ROOT}/.htaccess
chgrp ${WS_GROUP} ${WP_ROOT}/.htaccess
chmod 664 ${WP_ROOT}/.htaccess
echo 'allow wordpress to manage wp-content'
find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \;
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \;
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \;
當我運行此腳本我的WordPress網站去白色的屏幕。我在Debian GNU/Linux 8上\ n \ l
我能看到的WS_GROUP是錯誤的,因爲它打印出沒有人作爲apache在我的服務器上作爲www數據運行。但我不確定如何解決,如在 源/ etc/apache2/envvars它說出口APACHE_RUN_GROUP = www數據,所以不知道爲什麼該部分不工作。
任何人都可以幫助我看看如何修復腳本,以及如何添加一個WordPress網站的數組,所以我可以運行腳本,它會設置所有網站的權限,所以我可以自動更新網站.. 。
由於 Ĵ
謝謝你的擡頭。所以這就是我迄今爲止的情況。 '別名hwp ='sudo查找。 -type d -exec chmod -R 775 {} \ ;; sudo找到。 -type f -exec chmod 644 {} \ ;; sudo chown admin:www-data -R wp-content/*; sudo chmod 400 wp-config.php .htaccess;'' – Jamie