让 apache 用户使用 shell_exec(); 调用脚本


Have an apache user call a script with shell_exec();

PHP - CentOS - Apache

我正在尝试允许用户加密/解密我网站上的文件。我已经决定使用 gpg 作为我要加密/解密的方式。问题是我需要使用加密命令运行shell_exec,并且从浏览器调用时它似乎没有运行。我已经尝试了我能想到的一切,包括给所有涉及的文件夹和文件777永久,这感觉不对。

我想我可以通过设置 cronjob 和队列来实现这一点,但我希望有人知道更好的解决方案。

这些是不会运行的命令。

gpg --yes --passphrase=[Enter your passphrase here] -c filename.txt
gpg --yes --passphrase=[Enter your passphrase here] filename.txt.gpg

编辑:我回显了我发送给shell_exec的命令,它从命令行运行良好。但是,它不会从浏览器运行。

尝试 gpg 的完整路径,就像shell_exec中的/usr/bin/gpg --yes --passphrase=[Enter your passphrase here] -c absolute_path_to_file