How to resolve the error “[ErrorException] file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory”?

后端 未结 6 2060
终归单人心
终归单人心 2020-12-14 16:53

I\'m using Ubuntu 14.04 on my machine. I installed composer and then laravel in the document root i.e. /var/www

I

6条回答
  •  盖世英雄少女心
    2020-12-14 17:18

    If, like me, you did have a .env file, you may find it has permissions that are too tight to allow your current user to write to it (and by implication the php artisan command your current user is attempting to run). I had changed all my Laravel files to be owned by www-data:www-data and made my current user a member of the www-data group, and was thus a little stumped by this error.

    However, I soon realised that my .env file has the following permissions:

    -rw-r--r--

    ...meaning the user which owns the file gets read-write, but the group and world can only read. Since my current user is a member of the group www-data, it can only read, not write.

    (You can check your file permissions by doing $ ls -la)

    If you have the same situation, you have two choices; loosen the file permissions on that file (with chmod) or use sudo to run your php artisan commands. I chose the latter, since this is a production server for me and I like the tight permissions.

提交回复
热议问题