我正在尝试在我的 aws linux 服务器上将文件从 doc 转换为 pdf。在我以前的机器上它运行良好,但现在我在我的新机器上遇到了问题。唯一的区别是我已经从 PHP 7.0 升级到 PHP 7.2。和自由办公室版本
LibreOffice 6.0.1.1 00m0(内部版本:1)
我曾尝试为 libreoffice 和执行命令的包授予 root 权限,但没有成功。
这是我正在使用的包 https://github.com/szonov/libreoffice-converter
我在 laravel 5.4 中使用它。这是执行操作的包中的代码
$replacement = array(
'bin' => $this->bin,
'convert_to' => $convert_to,
'outdir' => $outdir,
'source' => $this->source
);
$cmd = $this->makeCommand($replacement);
$cmd = "sudo ".$cmd;
shell_exec($cmd);
$result = false;
if (file_exists($outfile)) {
$this->mkdir(dirname($this->destination));
$result = rename($outfile, $this->destination);
}
// remove temporary sub directory
rmdir($outdir);
return $result;
我尝试附加 sudo 因为当我 dd 命令并执行时使用 sudo 它在命令行中工作..
最佳答案
所以你需要使用类似下面的东西
或者您应该允许登录到www-data
用户
sudo usermod -s /bin/bash www-data
然后您应该使用该用户登录并修复所有权限问题,以便您可以运行命令
sudo su www-data
完成此操作后,请确保使用以下方法重置登录
sudo usermod -s /bin/nologin www-data
在用户终端中解决问题后,您也可以在 apache 中正常运行命令
关于php - 找不到 Libreoffice 源 aws linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48974697/