Skip to main content

Cannot get Ruby on Rails application (Redmine) to run after installation

Comments

5 comments

  • benryves
    LiteSpeed seems to be the culprit in all this, I found an option in WHM to switch between LiteSpeed and Apache and after switching to Apache Redmine suddenly started working beautifully. According to Ruby LSAPI Overview - LiteSpeed Technologies LiteSpeed should be able to run Ruby applications however I can't access its control panel (attempting to launch it navigates to :7080 which times out) so haven't figured that part of the puzzle out yet.
    0
  • cPanelLauren
    I'm glad at least you got the issued identified. When attempting to access their panel do you have the port open in your firewall? It's not something that's normally opened.
    0
  • benryves
    I'm glad at least you got the issued identified. When attempting to access their panel do you have the port open in your firewall? It's not something that's normally opened.

    Hi Lauren, Thank you for getting back to me, our hosting provider opened port 7080 and sent over the admin password for LiteSpeed so I was able to log in to its admin panel but was still unable to get the application to run (it still produced a 404 error) so I gave up and reverted to Apache. It was then pointed out that we were paying extra for LiteSpeed so I needed to get it working... :) In case it helps, this is how I got it working (there seems to be a lot of outdated or misleading information out there, so hopefully I'm not adding to that pile...) After restarting the LiteSpeed server it would display a message about the Ruby Path being undefined, so I first determined the correct Ruby path from the terminal: redmine@example.com [~]# which ruby /opt/cpanel/ea-ruby24/root/usr/bin/ruby
    I then copied /opt/cpanel/ea-ruby24/root/usr/bin/ruby
    into the "Ruby Path" field in Server?App Server?Rack/Rails Default Settings of the LiteSpeed admin panel and restarted the server. After this attempting to access the Ruby application produced a 503 error instead of a 404 error, which seemed to be a good indication that at least it was trying (albeit failing) to run the application. I looked in the Apache error log: redmine@example.com [~]# tail /usr/local/apache/logs/stderr.log 2020-06-23 00:46:02.525 [STDERR] /opt/cpanel/ea-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory 2020-06-23 00:46:03.036 [STDERR] /opt/cpanel/ea-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory 2020-06-23 00:46:04.039 [STDERR] /opt/cpanel/ea-ruby24/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.4: cannot open shared object file: No such file or directory
    As far as I can see this can be caused by a missing/incorrect LD_LIBRARY_PATH
    environment variable, so I found the value from the terminal: redmine@example.com [~]# echo $LD_LIBRARY_PATH /opt/cpanel/ea-ruby24/root/usr/bin/../local/bin:/opt/cpanel/ea-ruby24/root/usr/lib64:/opt/cpanel/ea-openssl/lib64
    ...and then appended this to the "Environment" field under Server?App Server?Rack/Rails Default Settings in the LiteSpeed settings, which in my case made it this: LSAPI_MAX_REQS=1000 LSAPI_MAX_IDLE=60 LD_LIBRARY_PATH=/opt/cpanel/ea-ruby24/root/usr/bin/../local/bin:/opt/cpanel/ea-ruby24/root/usr/lib64:/opt/cpanel/ea-openssl/lib64
    After restarting the server the Ruby on Rails application could be accessed and there were no more errors appearing in the logs, so fingers crossed this is what it took! There is information out there for LiteSpeed about configuring Virtual Hosts or Virtual Host Templates to determine the appropriate application paths which I didn't touch so I can only assume it's pulling the requisite information from the application configuration set up in cPanel. Other places mention a file called ~/.ls_rails_config
    that needs to be set up to configure the application, I did briefly have this set up too but it didn't seem to do anything and after deleting the file (and restarting the server several times) the application is still running fine so I don't think that's necessary either. As an aside, when setting up the cron job in cPanel to handle incoming emails to the application I ran into similar path issues but was able to resolve that by configuring the cron job to run with bash: /bin/bash -l -c 'cd ~/redmine && rake --silent redmine:email:receive_imap RAILS_ENV="production" host= username= password='
    Hopefully this might help someone in future if they're also having difficulty with Ruby on Rails and LiteSpeed. (At least until a new version comes out that completely changes how everything is set up, of course)!
    0
  • benryves
    Sorry to bump my own thread after so long but in case this helps anyone else, I recently upgraded Redmine from 4.1.1 to 4.2.4 on the server (not touching any of the server configuration directly, just going through the usual Redmine installation/upgrade procedure) and it worked fine for three days and then started returning HTTP 503 errors from LiteSpeed. The site ran fine when switching the web server to Apache, but switching to LiteSpeed brought back those HTTP 503 errors. Rebooting the server or removing and reconfiguring the application didn't seem to help. The errors in the Apache log were like the following: 2022-03-09 01:19:48.178697 [INFO] [7027] [T0] [127.0.0.1:59780:HTTP2-17#APVH_redmine.example.com:443] connection to [uds://tmp/lshttpd/APVH_redmine.example.com:443:_.sock] on request #0, confirmed, 0, associated process: 0, running: 0, error: Connection refused! 2022-03-09 01:19:48.178701 [INFO] [7027] [T0] [uds://tmp/lshttpd/APVH_redmine.example.com:443:_.sock] Connection refused, restart! 2022-03-09 01:19:48.178706 [INFO] [7027] [T0] [Rack:APVH_redmine.example.com:443:/] kill current detached process: 8200, started at: 1646788788 2022-03-09 01:19:48.178708 [INFO] [7027] [T0] [Rack:APVH_redmine.example.com:443:/] remove unix socket for detached process: /tmp/lshttpd/APVH_redmine.example.com:443:_.sock 2022-03-09 01:19:48.178750 [NOTICE] [7027] [T0] sendKillCmdToWatchdog: 'extappkill:8200:-3:1646788788'. 2022-03-09 01:19:48.178765 [NOTICE] [7027] [T0] [127.0.0.1:59780:HTTP2-17#APVH_redmine.example.com:443] Max retries has been reached, 503! 2022-03-09 01:19:48.178784 [NOTICE] [7027] [T0] [127.0.0.1:59780:HTTP2-17#APVH_redmine.example.com:443] oops! 503 Service Unavailable
    According to /usr/local/lsws/admin/misc/enable_ruby_python_selector.sh
    I ran that script as root (it produced a few "You need to be root to perform this command" errors when run under the application's own account) but this did not help, however I mention it for completeness in case it is part of the solution. After a bit more digging I found
    gem install ruby-lsapi
    After running that command under the application's own account the Redmine installation instantly started working again and I've rebooted the server as a test and it's still up and running fine, so that appears to have been the incantation to get it working. Touch wood it'll run for more than three days before falling over again. :)
    0
  • benryves
    I've just upgraded to Redmine 5.0.2 and this brought some additional challenges with it so once again I'm bumping this old thread in case it helps anyone else! Redmine 5 requires Ruby 2.5 or later, which means the old 2.4 version of Ruby needs to be upgraded. This can be done by using EasyApache 4 in WHM, customising your list of installed packages under "Ruby via Passenger" to install Ruby 2.7 (in my case I installed the same ruby27-* packages as I previously had selected for ruby24-*). Once you have provisioned the changes, log into the shell of the user that your application runs under. In my case I needed to update the .bashrc file to use the new Ruby 2.7 installation instead of Ruby 2.4, this was done with nano ~/.bashrc
    and changing source /opt/cpanel/ea-ruby24/enable
    to source /opt/cpanel/ea-ruby27/enable
    The file was then saved and I logged back out then in again to the shell. At this point I was able to install the Ruby application on the command-line normally with bundle install
    etc as per the Redmine installation instructions (previously doing this would produce a host of version-related error messages). To make life a little easier for myself I then disabled LiteSpeed and tried to load the application under Apache; I got a Phusion Passenger error page and looking at the error log I could see it was still attempting to use Ruby 2.4 (and clicking on the "Ensure dependencies" button in the application manager would bring up an error with ea-ruby24 in the path). Unregistering and re-registering the application switched it to use the new Ruby 2.7 installation and Redmine reappeared and the "Ensure dependencies" button also started working again. I then switched back to LiteSpeed, which required some additional work:
    • In the LiteSpeed WebAdmin Console, go into Configuration, App Server, and change:
      • "Ruby Path" to /opt/cpanel/ea-ruby27/root/usr/bin/ruby
      • "Environment" to include an appropriate LD_LIBRARY_PATH
        e.g. LD_LIBRARY_PATH=/opt/cpanel/ea-ruby27/root/usr/bin/../local/bin:/opt/cpanel/ea-ruby27/root/usr/lib64:/opt/cpanel/ea-openssl/lib64
    • In a shell as the root user edit the .bashrc to ensure the root user is using the Ruby 2.7, log out then in again, then run /usr/local/lsws/admin/misc/enable_ruby_python_selector.sh
    • In a shell as the application user run gem install ruby-lsapi
      in the application folder.
    At this point the application should be running under LiteSpeed. The one outstanding issue I have is that rake seems unable to find bundler, as running it always produces the following error: Gem::GemNotFoundException: Could not find 'bundler' (2.3.19) required by your /home/redmine/redmine/Gemfile.lock. To update to the latest version installed on your system, run `bundle update --bundler`. To install the missing version, run `gem install bundler:2.3.19`
    bundler is installed, running gem list ^bundler$
    shows that 2.3.19 was installed and which rake
    shows that it's running from the ea-ruby27 directory so I'm not sure what's going on there. Fortunately, I found a roundabout way to run it - instead of rake
    , using bundle exec rake
    does the job. The cron job to process incoming email is therefore: /bin/bash -l -c 'cd ~/redmine && bundle exec rake --silent redmine:email:receive_imap RAILS_ENV="production" host= username= password='
    I am still unable to upload files larger than 10MB under LiteSpeed (Apache is unaffected), I did
    0

Please sign in to leave a comment.