How would I set up a LAMP stack?

I have a feeling I’m just thinking about this the wrong way. I wanted to set up a toolbox container for testing web dev stuff. But all the tutorials I’ve found online and everything I’ve ever known to do in the past is to run systemctl enable httpd after installing to run the web server. But doing that in the toolbox doesn’t work, becuase I just get an error message about the system not having been booted using systemd.

I have a feeling this is just me adjusting to the container based aspect of Silverblue, and not realizing that there’s an even easier way to do it. Unfortunately my searching online up to this point has not been very helpful. What’s the best way to get this set up, or am I just going about this the completely wrong way to start with?

In general, your best bet for anything like this is going to be by using containers via podman, which is a rootless container runner that’s mostly CLI-compatible with Docker. Unfortunately, when I went to do some online hunting to find some guides, I realized pretty much all of the good ones docker-compose, which…is not supported by podman.

Some options you might try:

  • podman does support containers that have their own systemd instance, maybe look into setting up a standard Fedora container that does this and then put everything inside?
  • You could maybe check out running the services with supervisord instead of systemd.
  • If you don’t mind some learning, arguably the best solution would just to be to check out the guides that use docker-compose and manually convert it to the podman CLI instead. (This may actually be easier than the other two options.)
2 Likes

Just as @refi64 mentioned, using containers is the way to go when using silverblue. I don’t quite use php myself, but when with I do webdev on silverblue, I mount the code on the podman container and have it run my webserver of choice. I can then program and get instant feedback.
I suppose you can do the same with php.
If there is a specific tool you wish to use on top of the lamp stack, list it and I can try and use that myself, then guide you through it if I manage to get it running.

If you do wish to stick with toolbox, running httpd manually should also do the trick. Keep one terminal session with httpd running and then you can attach to toolbox multiple times to do whatever.

Learning is always good. I had experience with self hosting some things with docker-compose, and I know docker-compose files are mostly just docker commands written out in yaml form, so it shouldn’t be too high of a learning curve. I must admit I was surprised that there wasn’t a more clear-cut answer for something as common as a LAMP stack. But I suppose this type of thing is just the nature of containers and I just need to get with the program. Thanks for your help!

2 Likes

Part of the reason is probably since the main adopters of containers thus far have been organizations using microservice-style deployments, which usually follow a much different architecture than traditional stacks.

One of the community members has developed a tool that understands docker-compose YAML files and does the same business via podman - https://github.com/muayyad-alsadi/podman-compose

I actually was talking to the podman folks about this yesterday and they are backing the use of Kubernetes YAML files as the replacement for docker-compose. See podman-generate-kube and podman-play-kube for details.

Thanks for showing me that! I’ll definitely keep an eye out if I need it in the future. I was able to pull a php-apache image last night and get it running with a local folder connected to its var/www/html folder. The only other part of the LAMP stack I’m missing at this point is the database, so since it’s just those two containers I’ll probably just write some scripts to manage them for now.