duanqian3464 2012-08-17 10:09
浏览 22
已采纳

mkdir拒绝许可

I use mkdir() to create a directory on my server:

// $var_name is equal to an md5() hash
$path = "/var/www/publish/" . $var_name;
if(mkdir($path)) {
  echo "success";
} else {
  echo "error";
}

This will yield an error due to a permission denied. Looking up on my server, by doing ls -lh

drwxr-xr-x  2 root     root   4.0K Aug 17 09:05   publish

But if my $path is equal to $path = "/var/www/" . $var_name; it will create the folder I expected. What seems to be the issue in here.

  • 写回答

3条回答 默认 最新

  • douhuan1497 2012-08-17 10:12
    关注

    The permissions for the /var/www/publish folder are wrong. You need to make sure the apache user has the required permissions to create a directory.

    You are able to create directories in /var/www/ as it will have different permissions.

    Check the name of the user that the httpd process is running as and chown -R user:group /var/www/publish to that user/group. On debian, this appears to be www-data/www-data, so you need to run the following command chown -R www-data:www-data /var/www/publish.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度