doude2635 2019-02-22 06:37
浏览 84

将httpd作为不同的用户运行?

I am running httpd on aws ec2 instance on Amazon Linux 2.

For installing LAMP stack I used this link. The instance is running perfectly.

I need to execute a shell command from php using shell_exec('sh somescript'). The script then intern creates a folder using sudo mkdir foldername. This folder never gets created. So, I directly write shell_exec('sudo mkdir foldername'). Doesn't work.

I tried shell_exec('whoami'). This outputs apache(because of the group I had created from the installation.)

Other things I tried :

  • Changing permission and ownership of the folder and subfolder of the directory. (Didn't work).
  • Changing the user & group in httpd.conf.(Give Error 503, if I use ec2-user and doesn't start if I use root, which btw the comments asks.)

My question :

  1. Why am I not able to create folder from php when httpd is running as apache user/group, when ec2-user is a user of the apache group?

  2. Is it safe to use httpd with ec2-user as the user and group? If so how? If not what is the alternate?

  • 写回答

1条回答 默认 最新

  • dongyao9762 2019-02-23 06:04
    关注

    I was able to resolve this on my own. For future reference, all I did was restart the instance and all the services.

    I did not had to change the user or group for httpd. Although I'm still not sure if it is safe to do, but I was able to get around without it.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器