Laravel shows blank page on ubuntu, apache and php 7.0

When I tried to migrate one of my sites to the new cloud hosting, the blank page occurred. The new hosting had clean new ubuntu, apache 2 and PHP 7.0 installed.
Even after setting debug to true in app configuration file there was still blank screen. Laravel error log was also empty, so there was no information what was wrong.

The first step to fix this problem is to find some error information. To do this add the I added the following setting in Laravel index.php file.

ini_set('display_errors', 1);

After that the error messages finally showed up.

Now the first error message showed:
Call to undefined function Illuminate\Foundation\Bootstrap\mb_internal_encoding()

The fix for this was:

sudo apt-get install php7.0-mbstring

And after that restart of apache service

After this was fixed the next error showed up:

Use of undefined constant MCRYPT_RIJNDAEL_128

This was fixed by the following steps:

sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade

The next problem was that all routes except home resulted in 404 error.

Two most common causes of this behavior are:

1. mod_rewrite not enabled

2. AllowOverride is set to None

The next steps fixed the first issue

sudo a2enmod rewrite 
sudo service apache2 restart

For the second issue do the following:

Set it to All, assuming Apache2.4

    sudo nano /etc/apache2/apache2.conf

search for and change AllowOverride None to AllowOverride All, then save the file and restart apache

After those fixes everything was finally working fine.

Leave a Reply

Your email address will not be published. Required fields are marked *