Libreoffice source not found aws linux

I am trying to convert files from doc to pdf on my aws linux server. On my previous machine, it worked fine, but now I have problems with my new machine. The only difference is that I upgraded from PHP 7.0 to PHP 7.2. and version for office libre

LibreOffice 6.0.1.1 00m0 (Build: 1)

I tried to give root permissions to libreoffice and a package that executes the command but does not succeed.

This is the package I'm using https://github.com/szonov/libreoffice-converter

I use it with laravel 5.4. This is the code in the package that performs the action.

$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; 

I tried adding sudo since when it runs the dd and sudo command it works on the command line.

+8
php amazon-ec2 laravel libreoffice
source share
3 answers

So you need to either use something like below

Run root commands via PHP

Or you should enable login for www-data user

 sudo usermod -s /bin/bash www-data 

Then you must log in with this user and fix all permissions problems so that you can run the command

 sudo su www-data 

Once you do this, make sure to reset your username

 sudo usermod -s /bin/nologin www-data 

Once the problem is fixed in the user terminal, you can also run commands without problems in apache

+1
source share

You must change the ownership of your directory where the files are stored. Please try the following command on aws ubuntu machine.

sudo chown -R www-data: www-data / var / www / my-project /

0
source share

This problem has only 2 scenarios.

  • The user does not have permission.
  • The problem is with the code.

I assume that Laravel works well with you, except for this part

This means that you have access to the storage files, why don't you save them?

If you can save it, compare the folders and your problem will be solved.

If you cannot save there, the problem arises from the code, which I doubt, since you stated that everything works well earlier.

0
source share

All Articles