Question

I've made a symfony2 app and I try to deploy it on a shared server, but I get a fatal error.

I've taken the recommended steps here: Deployment-Tools

I've updated the vendor dependencies:

php composer.phar install --optimize-autoloader

I've cleared the cache:

php app/console cache:clear --env=prod --no-debug

I've change the permissions on the server for app/cache and app/logs

But it doesn't work. This is the error:

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/cookieboy/app/logs/prod.log" could not be opened: failed to open stream: No such file or directory' in /homepages/32/d453730371/htdocs/cookieboy/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:71

Stack trace:

#0 /homepages/32/d453730371/htdocs/cookieboy/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)

#1 /homepages/32/d453730371/htdocs/cookieboy/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php(58): Monolog\Handler\AbstractProcessingHandler->handle(Array)

#2 /homepages/32/d453730371/htdocs/cookieboy/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php(101): Monolog\Handler\AbstractHandler->handleBatch(Array)

#3 /homepages/32/d453730371/htdocs/cookieboy/vendor/monolog/monolog/src/Monolog/Logger.php(239): Monolog\Handler\FingersCrossedHandler->handle(Array)

#4 /homepages/32/d453730371/htdocs/cookieboy/vendor/mo in /homepages/32/d453730371/htdocs/cookieboy/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 71

and I was wondering why symfony tries to open this file /var/www/cookieboy/app/logs/prod.log) which is located at locahost and It has nothing to do with the production server.

Any idea about that issue?

Was it helpful?

Solution

I have solved the issue by deleting manually all the content inside app/cache. I don't know why but the command php app/console cache:clear --env=prod --no-debug didn't make its job in the way I was expecting.

Thank you all for the answers.

OTHER TIPS

Did you set up permissions?

$ sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs
$ sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs

If you don't have access to changing the ACL of the directories, you will need to change the umask so that the cache and log directories will be group-writable or world-writable (depending if the web server user and the command line user are in the same group or not). To achieve this, put the following line at the beginning of the app/console, web/app.php and web/app_dev.php files:

umask(0002); // This will let the permissions be 0775

// or

umask(0000); // This will let the permissions be 0777

In any way i recommend you to use capifony for deploy. once you setup it. you'll forget about deployment troubles.

If you open app_dev.php in your favourite text editor you will notice that one line which contain array of ip allowed to access dev envoiromnent. It's commented.

You may edit this file locally and then upload via ftp. Just be sure you will put there your correc public ip. Then you will be able to access dev enveironment while connecting from this ip. It will also allow you to run app_dev.php on your remote host just like you did on your localhost.

Besides you will be able to get more debug informations. It's obviously security lack and shoud never happen in serious application but is really common while learning symfony and missing ssh.

In similar way you may run config.php on your server.

(Please notice in this case everyone connecting from this ip will be able to get access to dev environment.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top