查看apache运行的用户和组:
vi ../../../../apache2/conf/httpd.conf
User nobody
Group nogroup
一般不是fast cgi模式的时候,应该似乎apache的权限,但这儿,我们的apache是noboey nogroup,而
vi /etc/group
nogroup:x:65534:nobody
vi /etc/passwd
nobody:x:65534:65533:nobody:/var/lib/nobody:/bin/bash
jackxiang:/etc # ps aux|grep httpd
root 9910 0.0 0.1 149460 11896 ? Ss Aug25 0:33 /usr/local/httpd-2.0.59/bin/httpd -k restart
nobody 852 0.0 0.2 149848 23692 ? S 15:13 0:03 /usr/local/httpd-2.0.59/bin/httpd -k restart
nobody 886 0.0 0.2 149828 23624 ? S 15:14 0:03 /usr/local/httpd-2.0.59/bin/httpd -k restart
nobody 892 0.0 0.3 149880 25092 ? S 15:14 0:03 /usr/local/httpd-2.0.59/bin/httpd -k restart
结合php代码:
if (is_dir ( $directory )) {
var_dump(is_writable ( $directory ));
exit;
if (is_writable ( $directory )) {
if (@move_uploaded_file ( $filename, $newfile )) {
// chmod our file
@chmod ( $newfile, $fileMode );
return $newfile;
}
}
}
$adlog = new TMLog ( );
$adlog->ll ( "Handle upload file Error" );
结果:
bool(false)
查看上传目录权限:
Jackxiang:/data/jackxiang/henganxy/htdocs/view # ls -lart|grep data
drwxr-xr-x 2 jackxiang users 4096 Oct 27 18:20 data
是jackxiang 不是nobody nogroup组,于是得修改:
chown -R nobody:nogroup data/
chmod -R 755 data/
755 是拥有的可以写入,其余有执行和读取权限,没有写入权限。
然后在上传,后查看目录如下:
Jackxiang:/data/jackxiang/henganxy/htdocs/view # ls data/
2009_10_27_19_38_50_1.jpg mini_2009_10_27_19_38_50_1.jpg
成功!!!
vi ../../../../apache2/conf/httpd.conf
User nobody
Group nogroup
一般不是fast cgi模式的时候,应该似乎apache的权限,但这儿,我们的apache是noboey nogroup,而
vi /etc/group
nogroup:x:65534:nobody
vi /etc/passwd
nobody:x:65534:65533:nobody:/var/lib/nobody:/bin/bash
jackxiang:/etc # ps aux|grep httpd
root 9910 0.0 0.1 149460 11896 ? Ss Aug25 0:33 /usr/local/httpd-2.0.59/bin/httpd -k restart
nobody 852 0.0 0.2 149848 23692 ? S 15:13 0:03 /usr/local/httpd-2.0.59/bin/httpd -k restart
nobody 886 0.0 0.2 149828 23624 ? S 15:14 0:03 /usr/local/httpd-2.0.59/bin/httpd -k restart
nobody 892 0.0 0.3 149880 25092 ? S 15:14 0:03 /usr/local/httpd-2.0.59/bin/httpd -k restart
结合php代码:
if (is_dir ( $directory )) {
var_dump(is_writable ( $directory ));
exit;
if (is_writable ( $directory )) {
if (@move_uploaded_file ( $filename, $newfile )) {
// chmod our file
@chmod ( $newfile, $fileMode );
return $newfile;
}
}
}
$adlog = new TMLog ( );
$adlog->ll ( "Handle upload file Error" );
结果:
bool(false)
查看上传目录权限:
Jackxiang:/data/jackxiang/henganxy/htdocs/view # ls -lart|grep data
drwxr-xr-x 2 jackxiang users 4096 Oct 27 18:20 data
是jackxiang 不是nobody nogroup组,于是得修改:
chown -R nobody:nogroup data/
chmod -R 755 data/
755 是拥有的可以写入,其余有执行和读取权限,没有写入权限。
然后在上传,后查看目录如下:
Jackxiang:/data/jackxiang/henganxy/htdocs/view # ls data/
2009_10_27_19_38_50_1.jpg mini_2009_10_27_19_38_50_1.jpg
成功!!!
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/2124/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2009-10-27 19:30
评论列表