Ubuntu + Apache 環境下Wordpress 更新失敗無法創建文件夾的解決辦法

我在Linode下的主機運行的是Ubuntu 16.04 + apache2,在wordpress更新時出現無法創建文件夾的錯誤。

而更改wp-content的權限爲775等辦法並沒有效果。注意:不要將你的文件夾權限改爲777,因爲這樣一來會有很大的安全隱患。

這種情況下,我們需要將wordpress文件夾所屬的用戶更換爲apache所屬用戶:

$ sudo chown -R www-data /var/www/path-to-your-wordpress-root

請將path-to-your-wordpress-root替換爲你的wp根目錄地址,運行命令。這樣一來再更新,就不會出錯了。

以上解決方案根據
https://www.tipsandtricks-hq.com/how-to-fix-the-unable-to-create-directory-error-in-wordpress-5264
實驗所得

The webserver (Apache) runs as user www-data and group www-data by
default on a Ubuntu system. If the files/folders are not owned by this
user (www-data) then the webserver will be unable to write changes to
them.

Change the filesystem permission on the folder (where the web
application wants to write to) to the “parent directory” as mentioned
in the error message.

For example, do (prepend with sudo if you’re not the current owner and need to elevate your own permissions in order to do it):

chown www-data /path/to/directory 

to make www-data the owner which makes it writeable usually, or another approach via groups:

> chgrp www-data /path/to/directory 
> chmod g+w /path/to/directory
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章