Score:0

Podman rootless mode to install multiple php_cli versions on a server

sd flag

I have a Debian server with multiple users. I would like to enable them to use multiple versions of PHP-CLI.

I know I could use ondrej PPA, but I am not very comfortable adding unofficial apt sources.

I was thinking to use podman in rootless mode to achieve this. This way I would have to install and run each php version container for each user.

I could make each php version container a service but to do this, the container needs to be installed on root.

What it would your suggested approach?

pt flag
Why does the container need to be "installed" as root? Running podman in rootless mode, your users can run whatever containerized version of php they want; you don't need to "install" anything.
sd flag
@larsks I believe that [handling container as a service](https://podman.io/blogs/2018/09/13/systemd.html) required the container to be own by the root user, is this believe wrong?
Score:0
br flag

If your base system is Debian, then you need the DPA, not PPA. Ondrej has a DPA with basically the same packages:
https://deb.sury.org/
https://packages.sury.org/php/README.txt

If you're making your own images, you can choose whether to use Debian or something else as their base, but you'll need to adjust the PHP source accordingly. There is also an official PHP image from Docker Hub, but it's missing a lot of extensions, so you'll likely need to derive from it to install more.

For PHP-CLI, you don't need to set up the container as a service. You mount the host folder where you want to run the command onto the container's workdir, and invoke the command. Something like this:

podman run --rm -it -w /mnt -v .:/mnt php-image php --version

Replace php --version with whatever command you want to run in the container. The container runs the command and immediately stops right after. The --rm switch then deletes the container, which is not needed anymore (a new one will be created the next time you need it).

You can wrap this in a helper script to make it more convenient.

For PHP-FPM, to run the container as a service, you can write a custom SystemD .service file (or just some scripts) to start/stop the container as needed. You then connect to it via the exposed port on the container.

You don't need root to do any of this with Podman.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.