69

I installed Laravel 5.0 properly by cloning in git, and composer install, when I ran it to browser http://localhost/laravel/public/, it says

"Whoops, looks like something went wrong."

I did not make any changes after composer install.

Update after copy the env.example to .env this is result

RuntimeException in compiled.php line 5599: OpenSSL extension is required.

SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
jemz
  • 4,987
  • 18
  • 62
  • 102
  • 1
    Have you checked any logs? If it's giving you a message, it means the server is up, but something is wrong. Post those details in the question, and we'll be able to help you. – mjuarez Mar 06 '15 at 07:01
  • @mjuarez where to see the logs ? – jemz Mar 06 '15 at 07:03
  • 4
    Then you'll have to install the openssl extension. – majidarif Mar 06 '15 at 07:26
  • @majidarif I give you points. can you post your answer so that i can accept it. – jemz Mar 06 '15 at 07:29
  • @jemz I don't even know what platform and server you're using. Please provide details. Windows? Apache? Ubuntu? NginX? – majidarif Mar 06 '15 at 07:33
  • @majidarif, sorry if you mis understood my reply..I mean it works now,just installing the openssl,I want to post your answer so that i can accept it as answer. Thank you – jemz Mar 06 '15 at 07:38
  • 1
    I'm sorry but I didn't give you an answer. The guy @kylehyde215 did. His answer led you to find the actual issue and fix it. You should accept his answer. Good day. – majidarif Mar 06 '15 at 07:48

19 Answers19

113

The logs are located in storage directory. If you want laravel to display the error for you rather than the cryptic 'Whoops' message, copy the .env.example to .env and make sure APP_ENV=local is in there. It should then show you the detailed error messaging.

kylehyde215
  • 1,216
  • 1
  • 11
  • 18
70

This is happening because there is a field in .env file named, APP_KEY, which is blank now, we need some random key for this variable.

Follow these steps to get rid of this problem.

  1. Rename .env.example to .env

  2. Go to your root directory in your command prompt (If you are using windows)/terminal (If you are using MAC or LINUX) where you have installed laravel project/files and run following command

    php artisan key:generate

and then run your project. It's all done.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Tausif Anwar
  • 1,237
  • 1
  • 10
  • 21
  • 1
    Have been searching for an answer for so long. Got this problem when my team put the Laravel-project on GitHub. The Vendor-folder is ignored by GitHub and we have to reinstall Composer. The .env-folder is renamed to .env.example and no-one got a clue what went wrong. Thank you for the solution! – Steffo Dimfelt May 07 '18 at 20:25
  • I had also found it very strange... and then I went through the documentation and found the solution.... – Tausif Anwar May 10 '18 at 10:35
  • 2
    guys, this is the answer – vishalknishad Jul 17 '18 at 06:35
23
  • Give write permission to storage and bootstrap/cache directories
  • Rename .env.example file to .env
  • If you get "RuntimeException... No supported encrypter found. The cipher and / or key length are invalid." error, stop the application and generate key from command line "php artisan key:generate"
  • If your get "OpenSSL extension is required" error, enable the openssl extension by opening php.ini in php installation folder and uncommenting the line extension=php_openssl.dll by removing the semicolon at the beginning
Yoseph
  • 2,356
  • 1
  • 13
  • 18
10

Follow these steps to this problem for all versions of your laravel like laravel 5.5

Step: 1

Rename file .env.example to .env

Step: 2

Go to your Command prompt/terminal and change path to project directory. Generate key for your application. This is unique for every application so don't make copy paste.

Just run the following command. Key will automatically save to your .env file

php artisan key:generate
Rahul Hirve
  • 1,109
  • 13
  • 20
6

Try to type in cmd: php artisan key:generate the problems will be solved

3

Simply type in terminal in your command prompt go to laravel directory path and type php artisan key:generate then key will be generated. Paste that key in config/app.php key variable. Your problem will be solved. I also did like that inorder to solve the problem...

YakovL
  • 7,557
  • 12
  • 62
  • 102
pavani
  • 41
  • 4
3

Please, try to find something like:

./website/config/app.php and set 'debug' => env('APP_DEBUG', false) as 'true' 'debug' => env('APP_DEBUG', true)
Hristo Eftimov
  • 13,845
  • 13
  • 50
  • 77
2

Try this:

sudo chown -R www-data pathto/.env

BECAUSE IF After Creating the .env file or/and Generating the Key by

php artisan key:generate

just as explained previously by others, and it still persists Try the following:

ls path/.env -al

if apache doesn't have access to it by displaying

www-data

as one one of the users i mean like

-rw-rwx--- 1 www-data rootuser 575 Nov 4 06:34 pathto/.env

This as stated above should resolve it. Especially when your laravel.log file keeps complaining that the key hasn't been generated or added.

sudo chown -R www-data pathto/.env

lightup
  • 634
  • 8
  • 18
1

In Laravel 5.5, I had the same issue

.env

was added to .gitignore.

So Either remove ".env" it from .gitignore file.

or add it forcefully

git add .env -f

And Deploy it. It will work.

If above does not help. Try generating the Key Again

php artisan key:generate
user7762065
  • 47
  • 1
  • 2
  • 1
    this is not a best practice to remove the env from a gitignore file as it can contain sensitive informations... – Nicolas D Sep 25 '17 at 18:38
1

Check, which PHP version is running on your WAMP,XAMPP or LARAGAN server. It should be greater than 7.0.

  1. Go to project folder like "C:\wamp\www\laravel".
  2. Open the file name of .env.example. (By using any editor like sublime, notepad++ and so on).
  3. Save as a .env

Then run your LARAVEL program. Hope it will work.

You can check whether how to change the PHP version in your current server. xampp, wamp

1

I renamed the .env.example to .env and ensure

APP_ENV=local 

which showed me the actual error. It was related to key. Then I issued

php artisan key:generate 

command and it worked

Nava Bogatee
  • 1,465
  • 13
  • 15
1

For windows users, make sure apache's ssl_module is checked.

Please see image below:

enter image description here

maqs
  • 414
  • 4
  • 5
1

First run command composer install

Then check for .env.example and .env files in your project folder.

.env file is your main configuration file for database and .env.example is backup file for .env file.

.env.example file will always be there but sometimes .env file can be missing. just copy the .env.example file and paste in the same project folder with filename .env .

now run php artisan key:generate command. this will generate key for your application.

0

You can copy these files from template "blog" laravel

enter image description here

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
  • I see 2 files with the same empty name, how can this be valid? Not even a link is provided to copy them files. My flag has been disputed, this needs a removal unless the OP updates, which is very unlikely. – Xorifelse Apr 20 '17 at 00:46
0

make sure app/storage dir permission is set to 755 and owner is set to admin. and also check permission and owner of files and dir in app/storage too

user889030
  • 4,353
  • 3
  • 48
  • 51
0

Create a new .env file and copy the code of .env.example and run the command -> php artisan key:gen

Ajay Makwana
  • 2,330
  • 1
  • 17
  • 32
Hari Pudyal
  • 91
  • 1
  • 3
0
  1. Rename the .env.example to .env
  2. Go to bootstrap=>app.php and uncomment $app->withEloquent();
  3. Make sure that APP_DEBUG=true in .env file. Now it will work.
0

This worked for me:

  1. Go to the .env file and be sure APP_DEBUG=true
  2. Here (in .env file) change reemplace 127.0.0.1 for localhost for check if your DB credential are corrects.
  3. Go to the config folder and do. the step #2.
SherylHohman
  • 16,580
  • 17
  • 88
  • 94
  • 1
    Please review [how to Ask](https://stackoverflow.com/help/how-to-ask) before your next post.. Grammar, Spelling, etc are *IMPORTANT*. While I fixed most of the egregious grammatical errors, typos, and formatting, parts of this post are still unclear and need to be corrected. – SherylHohman Apr 30 '20 at 03:45
-1

in process of uploading env file to cpanel,

sometimes the dot is taken out and this may raised the error.

this solution worked for me.

go to your cpanel and rename env file to .env

Abilogos
  • 4,777
  • 2
  • 19
  • 39