duanjiao6730 2014-09-05 21:12
浏览 487

PHP:fopen导致“Permission Denied” - 给PHP写入权限?

I've implemented a simple caching system that loads a static HTML if the database says no updates are available, and re-generates/writes the file when the database says there is an update.

Initial tests suggest that this works, however, the actual writing of the file does not operate:

Warning: fopen(/var/www/html/cache/en/item_4.php):
failed to open stream: Permission denied

The php script that attempts to write said file is located at /var/www/html/src/p/view_item.php

Every solution thus far assumes that I know how to fully operate the server and uses complicated terminology and reasoning; this is my first go with my own server, several things still aren't clear.

I've seen it said on multiple occasions that you should give the the user "nobody" write access to said folder (On a fresh PHP installation), while others say the file itself need some form of ownership over the directory or Apache itself needs write access.

Overall: Nothing's worked, ranging setting the directory to 777 and running the operation as another user (Whom I can only assume has write access there, too).

How exactly can I allow PHP to write to /var/www/html/cache/en/ and sub-folders?

I'm running LAMP, I have shell access and all that.

  • 写回答

1条回答 默认 最新

  • dqwh1203 2014-09-06 20:10
    关注

    How exactly can I allow PHP to write to /var/www/html/cache/en/ and sub-folders?
    PHP runs under www-data

    chown -R www-data.www-data /var/www/html/cache/en/
    
    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真