1

I've setup Apache + Rails + Passenger and the app loads correctly (for the most part). The application uses Tesseract and GS to convert PDFs into images and then take their text and insert it into the database.

When I test the application using rails s, everything functions normally, but when I try to run some of the functions from the passenger instance, I get the following error in my apache log:

App 14107 stderr: sh: tesseract: command not found

The error occurs for the following code:

%x(gs -dNOPAUSE -dBATCH -sDEVICE=pngalpha -r300 -sOutputFile="page%03d".png #{self.doc.path})
%x(for f in page*.png ; do tesseract $f $f.out; done)

There is nothing in my rails production.log file that indicates any errors.

I'm running CentOS 6 and I built my tesseract using this guide: https://www.simpleservers.co.uk/clients/whmcs/knowledgebase/600/Install-Tesseract-OCR-libs-from-sources-in-Centos.html

The user that passenger runs as can also run the command tesseract. I checked in its console, but for some reason, passenger can't run it. Do I need to enable it for the apache user somehow?

Thanks

  • 'command not found' is 99% an indicator that /path/to/tesseract needs to be added to the PATH variable that is visible Apache. Good luck. – shellter Aug 12 '14 at 15:23
  • Thanks, that was exactly what I needed! So following your advice, I went into /etc/sysconfig/httpd and added this line: export PATH= and it ran the command :) (I found the location from this page: [link](http://stackoverflow.com/questions/2837697/how-do-i-add-paths-to-the-apache-path-variable)) – user2714286 Aug 12 '14 at 16:50
  • you can post this as an answer (add how you determined what the correct path value was). and then you can accept your answer after 48 hrs (I believe), and you'll gain valuable reputation points! Good luck. – shellter Aug 12 '14 at 18:40

1 Answers1

2

Thanks to shellter for pointing me in the right direction. This is what fixed the issue for me:

Apache couldn't call tesseract, so I had to add it to its path. Based on this answer (How to add path to Apache), I went to /etc/sysconfig/httpd (this is CentOS specific) and added the line:

export PATH=<the path>

To get the path, I just ran this in the console:

env

And took the output for the PATH.

Community
  • 1
  • 1