Z
Z
zaytcevcom2018-08-23 09:47:01
Yii
zaytcevcom, 2018-08-23 09:47:01

How to fix "Unable to generate a random key" error when installing Yii2 on hosting?

An exception occurs "Unable to generate a random key" at basic/vendor/yiisoft/yii2/base/Security.php 5b7e5624b4f0b627188625.png
If you remove the line in layouts/main.php, everything is displayed, but the problem already occurs on pages with forms. What could be causing this problem? <?= Html::csrfMetaTags() ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2018-08-23
@kimono

Most likely, the legs grow from the check in line 515:

/*510*/            // urandom is a symlink to random on FreeBSD
/*511*/            $device = PHP_OS === 'FreeBSD' ? '/dev/random' : '/dev/urandom';
/*512*/            // Check random device for special character device protection mode. Use lstat()
/*513*/            // instead of stat() in case an attacker arranges a symlink to a fake device.
/*514*/            $lstat = @lstat($device);
/*515*/            if ($lstat !== false && ($lstat['mode'] & 0170000) === 020000) {
/*516*/                $this->_randomFile = fopen($device, 'rb') ?: null;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question