Sunday, April 10, 2022

[SOLVED] Hosting with OpenShift RedHat get 500 errors when access the website

Issue

I have this website. The problem I have is

The freelancer-ngohungphuc.rhcloud.com page isn’t working

freelancer-ngohungphuc.rhcloud.com is currently unable to handle this request.

500

I develop this website using Laravel 5.1. So what I have to do to fix this error.


Solution

Although you can usually check logs to see why you are getting a 500 error, it would appear that this is due to insufficient permissions - which need to be set on the storage and bootstrap/cache folders (as per the docs).

The folders both need to be writeable by your web server, so whilst 777 permissions will definitely work 775 should be fine (and more secure).

Doing this via a command line can be done with the following command (run it with sudo if you need to elevate to root permissions) chomd 777 -R storage bootstrap/cache or chomd 775 -R storage bootstrap/cache.

Doing this via an FTP client is doable, generally speaking you can just right click on the folder and choosing to edit permissions from there.

In some instances, vendor may need to be done too - from my experiences anyway.

These folders are all inside the root project directory for your Laravel application.

Edit

Excerpt from bottom of error log:

PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE)

This would indicate that the PHP version you are running is not >= 5.5.9 (one of the Laravel requirements).

This is confirmed in the screenshot shown of the OpenShift configuration. The version of PHP needs to be updated for Laravel to work - this wasn't just a permission issue.



Answered By - James
Answer Checked By - David Goodson (WPSolving Volunteer)