composer版本:2.4.4
php版本:8.1.2
宝塔面板版本:7.9.5
服务器所在地址:腾讯云轻量(广州)

composer install --no-dev --optimize-autoloader

宝塔安装完后出现 不管输

php artisan key:generate --force

还是输啥 都是这个报错 .env后缀也改过了

In EncryptionServiceProvider.php line 79:

No application encryption key has been specified.

建议先更换web目录用户为www之后设置755权限,然后在ssh中cd到web根目录

然后输入php artisan key:generate --force

先试试,然后看看有没有报错

设置权限:

chmod -R 755 /path/to/web

chown -R www:www /path/to/web

    Lonely 在输入 php artisan key:generate --force 后将控制太提示的所有内容都复制下来发帖,我看下报错内容

      飒爽师叔

      就只报这个错误 这两三天都在研究 不知道问题出在哪 实在没找到解决方法 只能求助你们了

      root@VM-8-14-ubuntu:/www/wwwroot/mb.cenxxx.cn# php artisan key:generate –force

      In EncryptionServiceProvider.php line 79:

      No application encryption key has been specified.

        Lonely.env 手动删除,或改名,当然你可以输入以下指令

        mv .env .env.old
        cp .env.example .env

        然后不要动 .env 直接输入以下命令后再编辑

        composer install --no-dev --optimize-autoloader
        php artisan key:generate --force

          飒爽师叔

          试过了 还是一样的报错

          root@VM-8-14-ubuntu:/www/wwwroot/mb.centurxx.cn# composer install –no-dev –optimize-autoloader

          Do not run Composer as root/super user! See https://getcomposer.org/root for details

          Continue as root/super user [yes]? y

          Installing dependencies from lock file

          Verifying lock file contents can be installed on current platform.

          Nothing to install, update or remove

          Generating optimized autoload files

          Illuminate\Foundation\ComposerScripts::postAutoloadDump

          @php artisan package:discover || true

          In EncryptionServiceProvider.php line 79:


          No application encryption key has been specified.


          70 packages you are using are looking for funding.

          Use the `composer fund` command to find out more!

          root@VM-8-14-ubuntu:/www/wwwroot/mb.centuryidc.cn# php artisan key:generate –force

          In EncryptionServiceProvider.php line 79:


          No application encryption key has been specified.

            Lonely 手动将 .env里的 APP_KEY 变量手动设置一个,例如:APP_KEY=base64:XZ9VAN0t/LHiXpbrtAJbuo5GkKlDhToGpzdDFSovfX0=

            当然我不建议这么干。会导致安全性降低

              飒爽师叔

              root@VM-8-14-ubuntu:/www/wwwroot/mb.centuryidc.cn# php artisan key:generate –force

              [WARNING] It appears you have already configured an application encryption key. Continuing with this process with

                     overwrite that key and cause data corruption for any existing encrypted data. DO NOT CONTINUE UNLESS YOU KNOW
              
                     WHAT YOU ARE DOING.                                                                                          

              I understand the consequences of performing this command and accept all responsibility for the loss of encrypted data. (yes/no) [no]:

              INFO Application key set successfully.

                Lonely 你翻译下也能知道啊,我刚才那波操作就是让你手动设置一个key,这个指令可以不用输了,当然如果能够不报错的运行,并能替换,那还是执行下,这样你就有属于你的加密密钥了

                  飒爽师叔

                  我知道他的意思 我现在已经全部弄过了

                  主要是你不是说不太安全么

                  这个我也不知道该去怎么解决

                    Lonely 那你输入 y还是n呢,y的话有正常执行吗?

                    还有就是你是宝塔吧?命令行的php版本是多少呢

                    不安全指的是,我在这里公开的情况下给你的这个密钥,你如果使用这个密钥保不准有哪个人会搞你,但一般来说,没有太大的事

                    将公开密钥填写到env里后再用php artisan key:generate --force命令就会随机给你生成一个新的密钥替换,该方法仅限于第一次使用该命令后无法生成密钥的时候。