6

I have moved my laravel project from local to production server which is centos vps. Strange thing I'm facing is laravel can't read from .env file, And I have tested everything to make it work but no success.

I have set it's permission to 777 and it's owner to the owner of vps.

still no success.

FYI : it is in gitignore but I have created .env file on server so this problem has nothing to do with gitignore.

Can someone walk me through step by step running laravel on production server? Exactly what should be done and what commands do I need to execute, where should I put project and where should put public directory files ?

please help me out.

Mohammad_Hosseini
  • 2,481
  • 3
  • 30
  • 53

3 Answers3

4

Maybe you could try to clear config cache:

php artisan config:clear
rap-2-h
  • 30,204
  • 37
  • 167
  • 263
2

In production environments you should never have a .env file. Instead, create the appropriate environment variables and PHP will read them from there.

Taken from the official DotEnv docs:

phpdotenv is made for development environments, and generally should not be used in production. In production, the actual environment variables should be set so that there is no overhead of loading the .env file on each request. This can be achieved via an automated deployment process with tools like Vagrant, chef, or Puppet, or can be set manually with cloud hosts like Pagodabox and Heroku.

Dan H
  • 3,524
  • 3
  • 35
  • 46
0

Have you tried this-

Copied from the official Documentation

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.

Sunny Kumar
  • 534
  • 12
  • 35
  • My storage directory permission is 777 and is writable by server owner, but problem still is there. – Mohammad_Hosseini Feb 08 '17 at 16:11
  • You may try installing laravel using softaculous installer and then copy all your views, models, controllers and routes to the corresponding directory. – Sunny Kumar Feb 08 '17 at 16:21