3

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?

Community
  • 1
  • 1
Abraham
  • 101
  • 1
  • 5
  • But have you cleared cache for production? cache:clear --env=prod --no-debug clears only dev cache. Are you getting this error on app_dev.php? – takwlasnie Aug 28 '13 at 19:40
  • I get this error on app.php, but, How could I clear the prod cache? I thought --env=prod means production environment. – Abraham Aug 28 '13 at 19:56
  • So have you cleared cache with just cache:clear without any additional parameters? – takwlasnie Aug 28 '13 at 19:58
  • I use this: php app/console cache:clear --env=prod --no-debug – Abraham Aug 28 '13 at 20:01
  • Have you changed all configuration files or run app_dev.php/config.php on server? – takwlasnie Aug 28 '13 at 20:13
  • I have changed parameters.yml. If I run app_dev.php on the production server I get this message: You are not allowed to access this file. Check app_dev.php for more information. If I run config.php on the production server I get this message: This script is only accessible from localhost. But If I run this files on Localhost there is no problem at all. – Abraham Aug 28 '13 at 20:33

3 Answers3

7

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.

Abraham
  • 101
  • 1
  • 5
0

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.

hd.deman
  • 1,268
  • 12
  • 17
  • 1
    Sadly it doesn't work. I set up permissions on localhost in that way (ACL) but I don't have the command line on the shared server. I tried umask but I get the same error message, so I'm gonna try **capifony**. I really like Symfony but after all my app works only at localhost. :-( – Abraham Aug 29 '13 at 11:18
0

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.)

takwlasnie
  • 99
  • 4