【发布时间】:2018-10-09 15:39:30
【问题描述】:
基本上我想通过 PHP ssh2_connect 函数将不同的命令传递给服务器。但是我需要通过使用不同的按钮来执行不同的命令,但无法做到。
下面是我的按钮代码:
<?php
$connection = ssh2_connect('ipaddress', 22);
ssh2_auth_password($connection, 'root', 'password');
if (isset($_POST['button'])) ssh2_exec($stream = ssh2_exec($connection, 'systemctl stop apache2'));
?>
<form action="" method="post">
<button type="submit" name="button">Apache2</button
没有按钮的代码:
<?php
$connection = ssh2_connect('ipaddress', 22);
ssh2_auth_password($connection, 'root', 'password');
$stream = ssh2_exec($connection, 'systemctl stop apache2');
【问题讨论】: