2

On my Ubuntu server, I run Apache 2 with a php8.2-fpm pool, and I have changed the PHP user, which is not www-data anymore.

I've changed the php-fpm.conf (/etc/php/8.2/fpm/pool.d/www.conf), so that the user is my new user.

My problem is that every time the server gets rebooted, the folder /run/php always changes back to www-data ownership, so I have to manually chown the folder to get PHP running as it should.

Where can I permanently change the ownership of this folder?

3
  • 2
    Why do you do this? You will probably have to update the systemd unit... Commented Oct 10, 2023 at 6:52
  • Almost answered here: serverfault.com/questions/1131404/… Commented Oct 10, 2023 at 6:55
  • @vidarlo "Why do you do this?" - Because running PHP and the webserver under the same user is a terrible idea for security. Commented Oct 10, 2023 at 16:04

1 Answer 1

2

/run uses tmpfs, a volatile memory-only filesystem whose contents is lost when the system is rebooted. It's not possible to set anything "permanently" there. It's recreated anew during system boot and startup of services.

The directory is created by systemd according to the settings of the service unit. You need to adjust your unit for systemd to create a directory with correct permissions.

Run the editor to start an override file:

systemctl edit php8.2-fpm 

It will open your default editor with the current state of the unit for reference. You need to add User and Group options (look at comments to see where to put this):

[Service] User=youruser Group=yourgroup 

That said, better leave it running as www-data and add your user to the group of www-data as needed instead.

1
  • I have already changed the user and group in the php8.2-fpm service. This server is only a development server, so there are some other reasons for having another user than www-data. Commented Oct 10, 2023 at 7:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.