简体   繁体   English

共享主机中的symfony项目出现一些错误

[英]I have some error on symfony project in shared host

I'm a beginner in Symfony. 我是Symfony的初学者。 I build a very simple project using Symfony that works correctly work in localhost. 我使用Symfony构建了一个非常简单的项目,该项目可以在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. 我在共享主机的根目录中上载了项目文件夹预期为“ web”的所有内容,并将“ web”文件夹上载至“ public_html”文件夹。 Import MySQL to my created database in host correctly and change 'parameters.yml' and change database connection details. 将MySQL正确导入到我在主机中创建的数据库中,并更改“ parameters.yml”并更改数据库连接详细信息。 Change chmod of '/var/logs/' and '/var/cache' to 777. But when going to website get an internal error. 将“ / var / logs /”和“ / var / cache”的chmod更改为777。但是在访问网站时出现内部错误。

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 谢谢

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 . 如果您无权使用Shell,则可以通过从var/cache删除整个环境名称的文件夹来手动清除var/cache For prod environment you should remove var/cache/prod folder. 对于prod环境,应删除var/cache/prod文件夹。

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 您需要通过act包向会话目录中的www-data的Web服务器用户添加rwx权限(如果没有通过以下方式安装):

$ 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 ). 第二行是给权限RWX的文件根据该目录的最佳做法是给RX权限本身RWX到项目var/cache var/logsvar/sessions ,RWX其衍生物(分别正如我上面所做的那样)。

after that you need to clear cache [delete the --env=prod if you are in development mode] and you're good to go ! 之后,您需要清除缓存(如果处于开发模式,请删除--env=prod ),您就可以开始了!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM