1

I'm using Symfony 4 and Hostgator's shared hosting.

I'm trying to deploy my app to the site. I have uploaded the app to the server and then moved and configured the index.php to the public_html folder. When I ran the site I got this error on the .env file.

Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "/home4/xxx/public_html/yyy/../.env" environment file. in /home4/xxx/yyy/vendor/symfony/dotenv/Dotenv.php:54 Stack trace: #0 /home4/xxx/public_html/yyy/index.php(15): Symfony\Component\Dotenv\Dotenv->load('/home4/xxx/pu...') #1 {main} thrown in /home4/xxx/yyy/vendor/symfony/dotenv/Dotenv.php on line 54

I have read that the environmental file should only be use on development stage, that's probably why the exception. But then what exactly I need to do next?

syam
  • 799
  • 1
  • 12
  • 30
reddy
  • 1,721
  • 3
  • 16
  • 26

1 Answers1

2

Based on your error it looks like a permissions issue. Double check your folders have (drwxr-xr-x)/(755) and files have (-rw-r--r--)/(644).

This may also help you in your setup: http://symfony.com/doc/current/setup/file_permissions.html

Additional Information:

Symfony uses the .env in any environment other than production. Production environment is set using server variables APP_ENV=prod. If it is not set, it is loading from the .env file. public/index.php will give you a little more insight.

Sean Bahrami
  • 161
  • 3
  • I checked, all the folders are 755 permission and all the files are 644 permission. And I don't understand what you mean by server variable, where do I set this? – reddy Mar 19 '18 at 06:42
  • 1
    Here is a good link, if your using Apache. https://stackoverflow.com/a/10902492/9191229. Do you have console access? – Sean Bahrami Mar 19 '18 at 06:50
  • So basically I will need to have access to the console on the server in order to change environment setting? I don't see anything in my control panel about console. – reddy Mar 19 '18 at 07:05
  • I found the problem. it was in the index.php that I forgot to update the path for the .env file, I only changed the one for the autoload – reddy Mar 20 '18 at 06:03
  • @reddy nice job! – Sean Bahrami Mar 20 '18 at 15:03