Laravel Installation Issues

Oct 09, 2017 Laravel Framework
Laravel installation issues | learn2torials

No application encryption key has been specified

If you are a new Laravel developer and trying to install a fresh laravel framework. Sometime you might come across different kinds of errors. In this tutorial, I will address commonly known error: No application encryption key has been specified.

After Laravel installation if you seeing this error in your browser:

RuntimeException No application encryption key has been specified.

This error happens due to copying .env.example file to .env. If you take a look at your .env file you will see that APP_KEY variable is set to blank. You need to generate unique has in order to run laravel application for security purpose.

You can easily fix this error by running following command on your terminal while being in root directory of laravel project:

$ php artisan key:generate

This will generate a encryption key, add this key to your .env file and then run your application.

Laravel framework file permission

I have noticed that Laravel developers quite often times come across the issue with cache folder permissions required by webserver. In order to assign correct folder permissions use following commands in your terminal window:

cd /var/www/your-laravel-project-dir
HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`;
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX storage
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX storage
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX bootstrap
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX bootstrap

Hope this tutorial will help some of the laravel developers facing similar issues.

Rate This Article

How to resolve issues with laravel framework installation. No application encryption key has been specified or permissions

4.13

About Author