laravel No supported encrypter found. The cipher and / or key length are invalid

前端 未结 14 582
后悔当初
后悔当初 2020-11-29 19:58

I am building a project using Laravel. It was working fine on localhost, but when I upload it to the server (the server has comodo ssl installed), I receive the following er

相关标签:
14条回答
  • 2020-11-29 20:34

    You only type in console:

    php artisan key:generate
    

    And if your app.php not change this Key, change manually.


    Next if you should then happen to get this error message:

    [ErrorException]
    file_get_contents(/path/to/my/project/.env): failed to open stream: No such file or directory

    Then make a copy of the .env.example file and try again:

    cp .env.example .env
    php artisan key:generate
    
    0 讨论(0)
  • 2020-11-29 20:37

    Do you have all the necessary extensions installed on the server?

    • PHP >= 5.5.9
    • OpenSSL PHP Extension
    • PDO PHP Extension
    • Mbstring PHP Extension
    • Tokenizer PHP Extension

    It could be that you're missing the OpenSSL extension. Also, do you have the key set in .env file?


    Try running:

    php artisan key:generate


    Answer: the 'cipher' => '' was not set.

    0 讨论(0)
  • 2020-11-29 20:39

    I managed to solve deployment to live Ubuntu server, here is all the steps

    Ensure PHP >= 5.5.9

    Ensure, OpenSSL, Mbstring, Tokenizer and mcrypt is installed.

    To Install mcrypt in PHP (Ubuntu):

    sudo apt-get install php5-mcrypt,
    sudo php5enmod mcrypt
    

    Make storage folder writable:

    chmod -R 0777 storage
    

    Make Apache use the Lavarel /public folder as home:

    DocumentRoot /home/code2/public_html/Laravel-Project/public
        <Directory "/home/code2/public_html/Laravel-Project/public”> 
             AllowOverride all 
        </Directory>
    

    Major gotcha for me is FTP might not copy hidden files by default: .env and /public/.htaccess need to be there!

    After completing the tasks above, it worked on Ubuntu server

    0 讨论(0)
  • 2020-11-29 20:40

    I just fix error.

    1. Shift+Click right mouse to "open commend window here" from your root project.
    2. In console write: "php artisan key:generate".
    3. Get 32 character 'Mark' to config/app.php like 'key' => env('APP_KEY', 'insert get 32 char key'),//line number 81
    0 讨论(0)
  • 2020-11-29 20:40

    write in console php artisan key:generate

    you will get message like: Application key [get 32 char key] set successfully.

    replace app key in config/app.php like 'key' => env('APP_KEY', 'insert get 32 char key'),//line number 81

    0 讨论(0)
  • 2020-11-29 20:46

    Please make sure you have this requirements in your machine.

    1. PHP >= 5.6.4
    2. OpenSSL PHP Extension
    3. PDO PHP Extension
    4. Mbstring PHP Extension
    5. Tokenizer PHP Extension
    6. XML PHP Extension

    Then after install or updating your project by

    composer update

    After this you have--

    .env.example

    Make a duplicate and rename it to--

    .env

    and make changes according to your database configuration or any other modifications you need.

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=your db name
    DB_USERNAME=username if any otherwise root
    DB_PASSWORD= your password if not set leave blank
    

    Finally generate your application key by--

    php artisan key:generate

    For Someone may be only last step is enough. But I have this problem every time I clone any laravel project. This whole step makes this with any hazard.

    0 讨论(0)
提交回复
热议问题