简体   繁体   English

Symfony2:在chroot环境中生产?

[英]Symfony2: prod in a chroot environment?

As a learning exercise I used Symfony to update an existing application for a local non-profit. 作为学习练习,我使用Symfony更新了本地非营利组织的现有应用程序。 Development was in a Windows environment. 开发是在Windows环境中进行的。 Now that the application has been installed on their ISP's shared host I start to learn about chroot on a FastCGI server. 现在,该应用程序已安装在其ISP的共享主机上,我开始学习FastCGI服务器上的chroot。 There are errors such as this: 有这样的错误:

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/home/projectmana/www2.projectmana.org/app/logs/prod.log" could not be opened: failed to open stream: No such file or directory' in /www2.projectmana.org/app/cache/prod/classes.php:4823 PHP致命错误:无法打开消息为“流或文件“ /home/projectmana/www2.projectmana.org/app/logs/prod.log”的未捕获异常'UnexpectedValueException':无法打开流:没有此类文件或目录”,位于/www2.projectmana.org/app/cache/prod/classes.php:4823

The ISP responds with: ISP回应:

Bad path. 不好的路。 PHP is chrooted in /home/projectmana/. PHP的根目录位于/ home / projectmana /。

OK. 好。 I get it that this is the problem. 我知道这是问题所在。 Web searches so far have not provided a clue as to how to proceed. 到目前为止,网络搜索尚未提供有关如何进行的线索。 (I've gained greater appreciation for Symfony wanting to avoid shared hosting.) Is there a solution that I, a relative novice and a volunteer, can implement in my code, or does the application have to find a new home? (我对Symfony希望避免共享主机有了更大的赞赏。)是否有我相对亲的新手和志愿者可以在我的代码中实现的解决方案,或者该应用程序必须找到新家?

You've got to set the doc_root variable according to your chrooted directory: 您必须根据您的chroot目录设置doc_root变量:

doc_root = "/home/projectmana"
cgi.fix_pathinfo = 0

You do this in the php.ini file - which seems to be not an option for you since you're on a shared server environment. 您可以在php.ini文件中执行此操作-由于您使用的是共享服务器环境,因此这似乎不是您的选择。 When using Apache as a webserver, you can use a .htaccess file and set the proper PHP directives there via php_value . 将Apache用作网络服务器时,可以使用.htaccess文件,并通过php_value在其中设置适当的PHP指令。

The solution in this instance was to override the locations of the cache and logs directories according to the cookbook . 这种情况下的解决方案是根据菜谱覆盖缓存的位置并记录目录。 This, however, by itself causes the cache:clear command to fail. 但是,这本身会导致cache:clear命令失败。 The answer to that problem will have to appear in another question if I can't find it on my own. 如果我自己找不到,该问题的答案将不得不出现在另一个问题中。

Update 更新

The other solution here cannot work because any php setting in .htaccess when Apache server is running FastCGI will cause a server error. 这里的另一个解决方案无法正常工作,因为Apache服务器运行FastCGI时.htaccess中的任何php设置都会导致服务器错误。 Clearing the cache was never solved so the site was moved to a non-CGI host. 清除缓存从未解决,因此站点已移至非CGI主机。

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

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