下面由WordPress教程欄目給大家介紹WordPress中無法將上傳的文件移動至wp-content/uploads的解決辦法,希望對需要的朋友有所幫助!
解決WordPress中無法將上傳的文件移動至wp-content/uploads
搭建lnmp環(huán)境,放一個wordpress建站系統(tǒng)
lnmp環(huán)境很快就搭建完成了,但是在放wordpress的時候出現(xiàn)了一些問題
最主要的問題:
1.第一個是wp-content/uploads沒有權限創(chuàng)建,
這個自己手動創(chuàng)建一下,給個777權限就好了。
2.無法將上傳的文件移動至wp-content/uploads。
這是個主要的問題,也是比較麻煩的問題,百度的答案都是千篇一律的設置777權限,不要中文用戶名,
沒有一點用。
在獲得解決辦法之前首先描述一下背景
裝lnmp環(huán)境的時候全部是使用root用戶安裝的,但是當我放程序的時候是新創(chuàng)建了一個morequ用戶,程序全部放到這個用戶下,然后用nginx代理。
這就出現(xiàn)了權限問題。
翻遍了百度,一點用都沒有,最后用bing搜索得到了一個答案。
按照他的方法改了之后,連http都過不去,直接500了,經(jīng)過多番努力,最終得到答案。
a)修改nginx.conf
在這個文件的最開始,有個設置user的地方,修改為:
user root root; worker_processes 1;
b)修改php-fpm.conf
在這個文件里看到這么一句話:
; Include one or more files. If glob(3) exists, it is used to include a bunch of ; files from a glob(3) pattern. This directive can be used everywhere in the ; file. include=/etc/php-fpm.d/*.conf
可以進入這個文件夾看一下,其中有一個www.conf文件
修改這個文件的:
; Set permissions for unix socket, if one is used. In Linux, read/write ; permissions must be set in order to allow connections from a web server. Many ; BSD-derived systems allow connections regardless of permissions. ; Default Values: user and group are set as the running user ; mode is set to 0666 ;listen.owner = morequ ;listen.group = morequ ;listen.mode = 0666 ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. ; RPM: apache Choosed to be able to access some dir as httpd user = morequ ; RPM: Keep a group allowed to write in log dir. group = morequ
將本來的www用戶改為我當前的用戶。
結果成功。