skip to Main Content

I’ve uploaded my Laravel app to a cpanel host .
The problem is that Laravel does not read the contents of the .env file and show me a “Whoops, looks like something went wrong.” page ( twice In one page )
This error is displayed because the program can not receive the APP_KEY variable . can not read .env file at all . I searched a little for this problem, but the solutions did not work . I tried all these:

  • ‘php artisan cache:clear’ command
  • ‘php artisan config:clear’ command
  • ‘php artisan config:cache’ command
  • change permission for .env file (755)
  • run all ‘composer update’ , ‘composer install’ , ‘composer dump-autoload’ commands
  • I did not use env function anywhere
  • There are no spaces in the values stored in the env file

But none of the above did not work out.
However, My program runs well in local ( windows ) and there is no problem But it does not run on the server ( cpanel )

note : I realized that when I execute the ‘php artisan config:cache’ command on server , all cache files are made in ‘bootstrap/cache’ folder, except for the config.php file
note2 : I uploaded several times in different ways. Once all the files in the folder in the root and the public files in the public_html folder . and once all the files in the public_html folder. Both not working

Does anyone know where the problem is?

in this time i put all my app files in public_html folder

3

Answers


  1. That always happens to me on new sites, so I usually run:

    chmod 777 storage/ storage/app/ storage/framework/ storage/logs/
    chmod 777 storage/ storage/app/ storage/framework/ storage/logs/
    chmod 777 storage/framework/cache/ storage/framework/sessions/ storage/framework/views/
    chmod 777 bootstrap/cache/
    chmod 777 bootstrap/cache/*
    chmod 777 storage/logs/laravel.log
    

    Note: The last one (laravel.log) does not exist the first time, bun then it is created.

    Instead of 777 you could use a more recommended ug+rwx if you first run:
    chgrp -R www-data storage bootstrap/cache
    chgrp -R www-data storage storage

    where www-data is the web server user, it could be apache or httpd

    Login or Signup to reply.
  2. Take a look at the storage/logs/laravel.log file to get more accurate information.

    Make sure the putenv() and getenv() functions are not disabled In php.ini

    Login or Signup to reply.
  3. You should not use .env file for production, it is only for development purpose.

    Create environment variables for your production(on server not .env).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search