Skip to content
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

php-fpm executing php-scripts as root #373

Open
psy0rz opened this issue Oct 24, 2024 · 1 comment
Open

php-fpm executing php-scripts as root #373

psy0rz opened this issue Oct 24, 2024 · 1 comment

Comments

@psy0rz
Copy link

psy0rz commented Oct 24, 2024

See https://github.com/magento/magento-cloud-docker/blob/develop/images/php/8.3-fpm/etc/php-fpm.conf#L6

There is no user directive, so by default php-fpm will try to run as root, which is allowed since the -R flag is used: https://github.com/magento/magento-cloud-docker/blob/develop/images/php/8.3-fpm/Dockerfile#L151

This in turn can create files as root, like stuff in /app/generated/...

Then when trying to switch to and from developer mode from the cli container (as user www), you will get permission issues.

Very strange that this is the default for an official magento container, is has to be a bug right?

@psy0rz
Copy link
Author

psy0rz commented Oct 24, 2024

So the correct file should have the user = www directive, like this:



[global]

error_log = /proc/self/fd/2
daemonize = no

[www]

user = www

; if we send this to /proc/self/fd/1, it never appears
access.log = /proc/self/fd/2

listen = [::]:9000

pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.status_path = /status

clear_env = no

env[MAGE_MODE] = $MAGENTO_RUN_MODE

; Ensure worker stdout and stderr are sent to the main error log.
catch_workers_output = yes

@psy0rz psy0rz changed the title php-fpm executing as root php-fpm executing php-scripts as root Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant