Apache作为ubuntu上的root [英] Apache as root on ubuntu

查看:105
本文介绍了Apache作为ubuntu上的root的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我需要以 root 身份运行我的Apache Web服务器.为此,我在终端中输入了 whoami; .它给了我输出: root .但是,当我通过执行以下php-script检查我的apache服务器是否以root用户身份运行时:< php echo whoami; ?> 它给我输出:没人.那么关于以root用户身份以root用户身份执行/登录的任何建议?

Ok I need to run my Apache web server as root. For this I typed whoami; in terminal. It gives me output: root. But when I check my apache server running as a root user or not by executing following php-script: < ?php echo whoami; ?> It gives me output: nobody. So any suggestions to execute/login as a root user in apache??

推荐答案

我建议在您的服务器上创建一个外部PHP文件,以处理与此扩展相关的所有内容.然后,您可以将shell_execsudo结合使用来调用此脚本.

I would suggest creating an external PHP file on your server that would handle everything related with this extension. And then, you could call this script with shell_exec in combination with sudo.

这样,您可以将Web服务器用户放在sudoers文件中,并使其以root身份运行php-cli.

This way, you could put your webserver user in your sudoers file and let it run php-cli as root.

然后,您可以在脚本中简单地使用:

Then, in your script you could simply use:

$output = shell_exec("sudo /bin/php /yourscript.php");

与以root用户身份运行Apache相比,这将是一个更多安全的解决方案,我认为这是一个非常糟糕的主意,即使您知道自己在做什么.

This would be a much more secure solution than running Apache as root, which in my opinion, is a verry bad idea, even if you know what you are doing.

这篇关于Apache作为ubuntu上的root的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆