donglv7097 2010-10-08 10:42
浏览 75

使用php写入属于不同用户的目录中的文件

I have a server that hosts several domains. From one of the domains, using a php script I want to be able to append a few lines to the .htaccess of other domains.

For example from masterdomain.com I want to append some lines to the .htaccess of otherdomain.com. So from a php file in /home/masterdomain/www/ I want to append a few lines to the .htaccess located at /home/otherdomain/www.

To do this I have written a shell script, when I run the shell script as root, it works but when running it via php, exec('./write_htaccess.sh') it's not working, nothing happends. I checked and there are no errors returned.

I have tried chmod u+s on write_htaccess.sh to try and make it run as root each time but that didn't work either, I might have set the s bit wrongly though.

How could I achieve this? Do I have to give php root priviledges, what would be the best way to do this?

  • 写回答

6条回答 默认 最新

  • duan1443 2010-10-08 10:46
    关注

    How about adding php to sudoers and allow it to do just the one thing.

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)