Now all issues are solved and localhost is running, right? If not follow the installation steps from the beginning with the help of this blog:
How To Install Laravel Framework in Ubuntu?Laravel5.7, PHP7.1.26
We followed all necessary steps but the link where our application is deployed is showing 500 Internal Server Error. What’s causing this? Even there aren’t any error logged in the console, right?
So here are a few things to keep in mind.
- Isn’t the log written somewhere in the framework?
- If yes, why are we not able to see the error?
Answer to the first question is “Yes”. Laravel logs the errors in its logger file. Log file is located inside storage folder. Check the file inside log folder of storage. Files are stored with name laravel-yyyy-mm-dd.log.
Now you can see the 500 Internal Server Error in log folder.
Answer to the second question is that the debug mode is set as false by default.
In your app’s config folder, you will find app.php . This is where all application configs are stored. There you will find the debug mode
‘debug’ => env(‘APP_DEBUG’, false)
Change the debug mode to true. Than you will now find our reason behind the 500 Internal Server Error
Now that we have enabled the debug mode, the error is displayed in our browser. So reason behind our 500 Internal Server Error is the encryption key. Key hasn’t been generated.
How to Generate Key?
Key Generation is easy. Keys are generated with this command:
php artisan key:generate
Try that and you will get another error which is expected during the fresh installation of Larvel Framework:
ErrorException : file_get_contents(/blog/.env): failed to open stream: No such file or directory
The Zen of Log, It speaks
So we will need a .env file inside your application folder. blog is my application name for the instance so I am looking for a .env file. We don’t actually need to create a new .env file. Laravel does the job for us.
There exists a .env.example file, rename it as .env
Do this and again generate the key with php artisan key:generate. Keys will be generated successfully. And now try to run php artisan serve
Now finally without any issue you will get your laravel application successfully deployed in the url: http://127.0.0.1:8000