WordPress中"无法将上传的文件移动至"错误的解决方法
<p>今天在网页上传图片到博客,结果提示:“无法将上传的文件移动至 /home/wwwroot/wp-content/uploads/2013/”,郁闷了,认为是权限问题,修改了文件,都改成了777的权限,但是还是不可以写入,图片无法上传。<br>
索性,我查看了我的网站根目录文件夹的权限,显示是www ,www ,而用ps aux|grep nginx 显示的是nobody 的身份运行nginx的子程序,ps aux|grep php-fpm,显示的也是nobody。同时发现,我网站里的其他的文件和文件夹的权限却是root,root。这可能是因为我上次直接用root身份拷贝导致的,所以,无法用nobody的身份修改root的文件。<br>
方法如下:<br><strong>第一步:</strong><br>
先分别将nginx和php-fpm子程序的运行身份变成www,用户组group也变成www。<br>
修改nginx.conf文件,将user nobody nobody;改成user www www;<br>
运行命令:</p>
<div>
<div>
<div id="highlighter_486134">
<div>
<span>?</span>
</div>
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td>
<div>
1</div>
</td>
<td>
<div>
<div>
<code>service nginx restart </code><code>//</code><code>重启nginx</code>
</div>
</div>
</td>
</tr></tbody></table>
</div>
</div>
<div id="codetool">
<div>
<textarea></textarea>
</div>
</div>
</div>
<p>
修改php-fpm.conf,将其中的</p>
<div>
<div>
<div id="highlighter_110391">
<div>
<span>?</span>
</div>
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td>
<div>
1</div>
<div>
2</div>
</td>
<td>
<div>
<div>
<code>user = nobody</code>
</div>
<div>
<code>group = nobody</code>
</div>
</div>
</td>
</tr></tbody></table>
</div>
</div>
<div id="codetool">
<div>
<textarea></textarea>
</div>
</div>
</div>
<p>
改成:</p>
<div>
<div>
<div id="highlighter_991124">
<div>
<span>?</span>
</div>
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td>
<div>
1</div>
<div>
2</div>
</td>
<td>
<div>
<div>
<code>user = www</code>
</div>
<div>
<code>group =www</code>
</div>
</div>
</td>
</tr></tbody></table>
</div>
</div>
<div id="codetool">
<div>
<textarea></textarea>
</div>
</div>
</div>
<p>
运行命令:service php-fpm reload //重启php-fpm<br><strong>第二步:</strong><br>
修改所有文件夹和文件为www,www</p>
<div>
<div>
<div id="highlighter_683638">
<div>
<span>?</span>
</div>
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td>
<div>
1</div>
</td>
<td>
<div>
<div>
<code>#chown -R www:www /wwwroot</code>
</div>
</div>
</td>
</tr></tbody></table>
</div>
</div>
<div id="codetool">
<div>
<textarea></textarea>
</div>
</div>
</div>
<p>
再次上传图片,提示成功上传了,问题解决了。<br>
网上还有一些其他的方法,比如将图片修改成英文名,或者修改文件夹为777。其实很多情况下权限是777了,但是依旧不能上传,可以考虑是不是文件属主的问题。</p>
頁:
[1]