我能够通过命令行终端通过php执行shell脚本。但是当我通过浏览器单击HTML按钮时,我无法使用php执行相同的脚本(.sh)。无法在php中执行shell脚本
以下是我的PHP脚本(wettyload.php) -
<?php
shell_exec('/var/www/html/wettyload.sh');
?>
以下是我的shell脚本(wettyload.sh) -
#!/bin/bash
cd /root/wetty
node app.js -p 8080
以下是我的HTML代码(url.html) -
<html>
<body>
<form name="form2" method="post" action="http://127.0.0.1/wettyload.php">
<input type="submit" id="url" name="url" value="Connect terminal">
</form>
</body>
</html>
你什么错误?也许你的网络服务器没有root权限? – colburton
你的shell脚本将在默认的web用户下执行。确保用户具有执行权限。 – Webomatik