普通网友 2013-07-17 19:18
浏览 24

我需要授予我的“网络浏览器用户”权限才能运行代码

I am writing web pages using PHP and would like to "require" code that I have written (in the future I would also like to be able to run python code).

whoami gives: www-data 
require '/fullpath/code.php';

The error I get is:

 require(/fullpath/code.php): failed to open stream: Permission denied

So the user www-data doesn't have permission to run my code. How do I give it permission? Also, how do I do this without opening up the can of worms giving hackers access to my web programs?

I have sudo privileges but I've never heard of the user www-data I do sudo find . | grep www-data (from the "/" directory) and I get nothing. So I'm not even sure where to find this "user" to change its permissions.

Thanks

  • 写回答

1条回答 默认 最新

  • duanhuang7591 2013-07-17 19:30
    关注

    www-data is one of the users that web servers run as. You don't need to change its permissions for it to access your code - you need to change your code's.

    The easiest way to do that is to make your code world-readable - something like:

    chmod -R 644 /fullpath
    

    will do it.

    chmod changes permissions; -R makes it run recursively; 644 sets the permissions to readable for Group and World (and you get Read, Write privileges); and the final parameter is the path to run this on.

    You'll need to check that you don't have anything in that directory that you need Execute permission for, as the code as written will remove that permission and you'll need to add it back in.

    评论

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元