0
votes

I'm a beginner in Symfony. I build a very simple project using Symfony that works correctly work in localhost. I upload all content of project folder expect 'web' in the root of my shared hosting and upload 'web' folder to 'public_html' folder. Import MySQL to my created database in host correctly and change 'parameters.yml' and change database connection details. Change chmod of '/var/logs/' and '/var/cache' to 777. But when going to website get an internal error.

Errors detail :

[24-Apr-2016 05:02:09 UTC] PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Session Storage was not able to create directory "D:\eventcalendar\app/../var/sessions/prod"' in /home/emusummit/var/cache/prod/classes.php:292
Stack trace:

#0 /home/emusummit/var/cache/prod/appProdProjectContainer.php(1898): Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler->__construct('D:\\eventcalenda...')
#1 /home/emusummit/var/bootstrap.php.cache(2107): appProdProjectContainer->getSession_HandlerService()
#2 /home/emusummit/var/cache/prod/appProdProjectContainer.php(1937): Symfony\Component\DependencyInjection\Container->get('session.handler')
#3 /home/emusummit/var/bootstrap.php.cache(2107): appProdProjectContainer->getSession_Storage_NativeService()
#4 /home/emusummit/var/cache/prod/appProdProjectContainer.php(1885): Symfony\Component\DependencyInjection\Container->get('session.storage...')
#5 /home/emusummit/var/bootstrap.php.cache(2107): appProdProjectContainer->getSessionService()
#6 /home/emusummit/var/cache/prod/c in /home/emusummit/vendor/twig/twig/lib/Twig/Loader/Filesystem.php on line 94

What is the problem? Please help me. Thanks

2
thoses dont look like paths a host would use.user557846
@Dagon // i see that, but i dont know change 'D:\\eventcalendar' from where ?Vahid Moghadam
has to be in your code somewhereuser557846

2 Answers

5
votes

You probably didn't clear the cache.

Try to clear the cache by running command:

php bin/console cache:clear --env=prod

Or if you use dev-environment (it is not right for production server) you shoud use:

php bin/console cache:clear

If you have no access to shell you can clear the cache manually by removing whole folder with the name of your environment from var/cache. For prod environment you should remove var/cache/prod folder.

0
votes

you need to add rwx permission to the webserver user that is www-data on the session directory through act package if you don't have it install by

$ sudo apt-get install acl

if you do have it just type

$ sudo setfacl -R -m u:www-data:rX project-symfony/var/sessions
$ sudo setfacl -dR -m u:www-data:rX project-symfony/var/sessions

the second line is to give permissions rwx to files under that dir Best practices are to give rx permission to the project itself rwx to var/cache var/logs and var/sessions ,rwx to its derivate (respectively as i did above ).

after that you need to clear cache [delete the --env=prod if you are in development mode] and you're good to go !

php bin/console cache:clear --env=prod