Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Using Symfony2 in a PHP-FPM chroot-ed environment. #6484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mishunika opened this issue Dec 26, 2012 · 7 comments
Closed

Using Symfony2 in a PHP-FPM chroot-ed environment. #6484

mishunika opened this issue Dec 26, 2012 · 7 comments

Comments

@mishunika
Copy link

I am using Nginx + PHP-FPM chroot in my projects. Since CLI PHP is out of PHP-FPM chroot, the generated directories may differ, so it breaks Twig includes. (i.e. it generates templates.php using absolute non-chrooted path)

We need to trick the console script, so it may think that we are in chroot ;o)
Can we somehow manipulate the base path for the cache warmup?

@mishunika
Copy link
Author

It seems like not a lot of people uses the php-fpm chroot feature ;o)

I've managed a little workaround for this issue.
First of all I'm deleting the old cache manually: rm -rf app/cache/*
Then I'm doing all stuff that I need (Assetic dump etc), and the last thing is a cache:clear with --no-warmup, just to be sure that anything is allright.
php app/console cache:clear --env=prod --no-warmup

I've set up these in a post-receive git hook, and for the moment it works like a charm after any git push %)

@imunhatep
Copy link

Have the same problem here with running PHPUnit tests from console.

@jakzal
Copy link
Contributor

jakzal commented Dec 23, 2013

re #3079

@johnrivelt
Copy link

I have met same problem.

  1. SAPI is CLI (console), path is like "/var/www/htdocs/~"
  2. SAPI is php-fpm(web server), path is like /htdocs/~

I found solution without coding in php side.

NGINX is using chroot as default and it indicate folder like "/var/www".
PHP-FPM has option like chroot="/var/www" to fit NGINX default chroot.

Steps

  1. When start NGINX server, use -u option to disable chroot function.
  2. Comment chroot="/var/www" line in php-fpm.conf
  3. restart nginx, php-fpm

Then path will be changed to absolute path.

@mishunika
Copy link
Author

@johnrivelt No! Disabling the chroot is not at all a solution. We need chroot + working symfony. And my workaround is written above.

@johnrivelt
Copy link

If you have to use chroot, just simply manipulate cached php code. Like
If SAPI is CLI , do nothing
Else SAPI is php-fpm, add prefix path to twig path

fabpot added a commit that referenced this issue May 17, 2014
…tainer (fabpot)

This PR was merged into the 2.3 branch.

Discussion
----------

[HttpKernel] removed absolute paths from the generated container

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | first step to resolve #6484, #3079, and #9238
| License       | MIT
| Doc PR        | n/a

This PR converts absolute paths to relative ones in the dumped container. The code is a bit "ugly", but it gets the job done and I'm not sure that there is a more elegant way without breaking everything.

Commits
-------

c1450b4 [HttpKernel] removed absolute paths from the generated container
@fabpot fabpot closed this as completed May 17, 2014
fabpot added a commit that referenced this issue Dec 2, 2014
…e generated container (nicolas-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[DependencyInjection] make paths relative to __DIR__ in the generated container

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6484, #3079, partially #9238, #10894, #10999
| License       | MIT
| Doc PR        | n/a

This is an alternative approach to #10999 for removing absolute paths from the generated container:
instead of trying to fix the container file after it has been dumped, telling to the PhpDumper where its output will be written allows it to replace parts of strings by an equivalent value based on `__DIR__`.
This should be safe, thus the PR is on 2.3.

Commits
-------

edd7057 [DependencyInjection] make paths relative to __DIR__ in the generated container
@nicolas-grekas
Copy link
Member

Fixed by #12784

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants