通过http请求启动远程服务

通过http请求启动远程服务,http,authentication,debian,systemd,Http,Authentication,Debian,Systemd,我有一个系统服务“myservice”,作为用户www数据运行。我想通过http请求启动/停止/重新启动此服务。问题是,由于缺少身份验证,我收到了一个错误: 无法重新启动myservice.service:需要交互式身份验证。 有关详细信息,请参阅系统日志和“systemctl status myservice.service” 首先,我请求一个php脚本,调用restartService.sh: $exec_command = "../restartService.sh"; restartS

我有一个系统服务“myservice”,作为用户www数据运行。我想通过http请求启动/停止/重新启动此服务。问题是,由于缺少身份验证,我收到了一个错误:

无法重新启动myservice.service:需要交互式身份验证。 有关详细信息,请参阅系统日志和“systemctl status myservice.service”

首先,我请求一个php脚本,调用restartService.sh:

$exec_command = "../restartService.sh";
restartService.sh只是一个命令:

systemctl restart myservice.service
restartService.sh的所有者和组是ww数据:

-rwxr-xr-x 1 www-data  www-data    41 Aug 24 12:42 restartService.sh
有解决方案的建议吗?

您可以使用配置授予
www-data
用户运行
systemctl重新启动服务的权限,而无需授予其以root用户身份运行任何其他命令的权限

请看一看或链接到那里的问题。