your programing

laravel 지원되는 암호화기를 찾을 수 없습니다.

lovepro 2020. 10. 13. 08:22
반응형

laravel 지원되는 암호화기를 찾을 수 없습니다. 암호 및 / 또는 키 길이가 잘못되었습니다.


Laravel을 사용하여 프로젝트를 만들고 있습니다. localhost에서 제대로 작동했지만 서버에 업로드하면 (서버에 comodo ssl이 설치되어 있음) 다음 오류가 발생합니다.

RuntimeException in EncryptionServiceProvider.php line 29:
No supported encrypter found. The cipher and / or key length are invalid
in EncryptionServiceProvider.php line 29
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 733
at Container->build(object(Closure), array()) in Container.php line 626
at Container->make('encrypter', array()) in Application.php line 674
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in Container.php line 837
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 800
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 771
at Container->build('SahraSalon\Http\Middleware\EncryptCookies', array()) in Container.php line 626
at Container->make('SahraSalon\Http\Middleware\EncryptCookies', array()) in Application.php line 674
at Application->make('SahraSalon\Http\Middleware\EncryptCookies') in Pipeline.php line 123
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 118
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 86
at Kernel->handle(object(Request)) in index.php line 54

누구든지이 오류를 해결할 수 있습니까?


필요한 모든 확장이 서버에 설치되어 있습니까?

  • PHP> = 5.5.9
  • OpenSSL PHP 확장
  • PDO PHP 확장
  • Mbstring PHP 확장
  • Tokenizer PHP 확장

OpenSSL 확장이 누락되었을 수 있습니다. 또한 .env파일에 키가 설정되어 있습니까?


다음을 실행 해보십시오.

php artisan key:generate


답변 : 'cipher' => ''설정되지 않았습니다.


콘솔에만 입력합니다.

php artisan key:generate

app.php가이 키를 변경하지 않으면 수동으로 변경하십시오.


다음으로이 오류 메시지가 발생하면 다음을 수행하십시오.

[ErrorException]
file_get_contents (/path/to/my/project/.env) : 스트림을 열지 못했습니다. 해당 파일 또는 디렉토리가 없습니다.

그런 다음 .env.example파일 사본을 만들고 다시 시도하십시오.

cp .env.example .env
php artisan key:generate

나는 전에 같은 문제가 있었고 다음과 같이 수정했습니다 : config / app.php로 이동 "cipher" => "anything"하여

'cipher' => MCRYPT_RIJNDAEL_128,

나는 단지 오류를 수정합니다.

  1. Shift+Click 루트 프로젝트에서 "여기에서 명령 창을여십시오".
  2. 콘솔에서 "php artisan key:generate".
  3. config/app.php좋아하는 32 자 '마크'가져 오기 'key' => env('APP_KEY', 'insert get 32 char key'), // 행 번호 81

이것을 실행하여 수정했습니다.

php artisan config:cache

루트 디렉토리에 .env.example파일 있으면로 변경 .env한 다음 php artisan key:generate. 이것은 나를 위해 일했습니다.


제 경우에는 mcrypt 확장을 활성화해야합니다.

그러나 먼저 이미 가지고 있는지 확인하십시오.

$ sudo apt-get install -y mcrypt php5-mcrypt

mcrypt 모듈이로드되었는지 확인하십시오.

$ php -m | grep mcrypt

아무것도 표시되지 않으면은로드되지 않았기 때문입니다.하지만 이미 위의 설치를 완료 했습니까? 이렇게하세요 :

$ php5enmod mcrypt
$ sudo service apache2 restart

다시 확인하면 아무것도 아닌 mcrypt가 표시됩니다. 좋은 징조입니다. 앱을 다시로드하고 다음 오류를 수정하세요.)

$ php -m | grep mcrypt
mcrypt

콘솔에 쓰기 php artisan key:generate

다음과 같은 메시지가 표시됩니다. Application key [get 32 char key] set successfully.

config/app.php같은 앱 키 교체'key' => env('APP_KEY', 'insert get 32 char key'),//line number 81


해결 방법 :

PHP 장인 키 : 생성


.env 파일에서 키를 읽는 대신 app.php 구성 파일을 사용하는 경우 키 변수에서 env () 함수를 제거 할 수 있습니다. 예 :

'key' = env('someRandom36CharsString'),

...에

'key' = 'someRandom36CharsString',

라이브 Ubuntu 서버에 대한 배포를 해결했습니다. 여기에 모든 단계가 있습니다.

PHP가 5.5.9 이상인지 확인하십시오.

OpenSSL, Mbstring, Tokenizer 및 mcrypt가 설치되어 있는지 확인하십시오.

PHP (Ubuntu)에서 mcrypt를 설치하려면 :

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

스토리지 폴더를 쓰기 가능하게 설정 :

chmod -R 0777 storage

Apache가 Lavarel / public 폴더를 홈으로 사용하도록합니다.

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


I was suffering with this problem for a few too many hours before I discovered that the key was being cached in the bootstrap\cache\config.php. Deleted the file and my site loaded fine (i.e. there was otherwise no problem with my config).

I discovered this by adding some debug output to boostrap\cache\compiled.php to make it spit out the cipher and key (somewhere around line 7010). Then dug around to see how it was picking up the config and found it uses a cache config file.


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.


Add "illuminate/html": "~5.0" to require section of your composer.json file. Just like this:

...
"require": {
    ...
    "illuminate/html": "~5.0"
    ...
},
...

Then run composer install command. When composer install gets complete. run php artisan key:generate. You will get a message like this:

Application key [get 32 char key] set successfully.

참고URL : https://stackoverflow.com/questions/31512970/laravel-no-supported-encrypter-found-the-cipher-and-or-key-length-are-invalid

반응형