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.)

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!


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 -

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.

In case this helps anyone else, I got the containers up and running and started working through this tutorial, with a few differences here and there. I wrote a script to automatically pull down images I prepared with buildah and uploaded to, set up a pod, and start all the containers with mounted persistent volumes and such. I put all this in a GitHub repository if it would be helpful to anyone else. In the interest of this being a potentially helpful example, if there are any best practices regarding podman or containers I’m violating here, feel free to let me know, I’d be happy to do whatever I can to fix those.

EDIT: Immediately I already see that I have absolute paths specific to my folder setup in the init script! I’ll have to figure a way around that. Perhaps something to do with $PWD since the volumes flag does not work with ./ notation.

You’d do:

dnf install mariadb mariadb-server httpd mod_ssl php php-common

And then you would install each module you need.

That would work in a standard Fedora installation, but it won’t work that way in the default toolbox containers on Silverblue, as those don’t come with systemd by default so you can’t start the httpd service. You would have to either do what I did and combine different containers together or get a Fedora container with systemd instead and then run the commands and start the services. I ended up managing to combine nginx, php-fpm, and mariadb containers in a pod and get that working. I did have a working configuration with php-apache and mariadb before hand though. Even if its not the most optimal way to do it, I did get plenty of experience with OCI containers that I didn’t have before.

If that doesn’t work, I have no idea what has gone wrong with your system. I
have no idea how you even booted without systemd, unless there’s another init
system present. Regardless, there are other ways to start Apache’s httpd than
through the systemd unit.

I’m not sure how this is really related to booting… The toolbox relies on the host systemd instance, so any units you install inside can’t be used from the host.

Out of curiosity, would you be able to share this online, e.g. through a gist? I suspect this type of question is going to be asked pretty often!

This is actually really easy.

There is an official Docker image for MariaDB that you should use for your DB:

Then all you need is Apache + PHP. You could create your own Dockerfile, but you could also look at pre-built options. For example:

The official PHP one uses mod_php which is not the way to go in production if you want performance. That’s where running PHP in FPM comes in. The same way Nginx does it, also making Apache HTTPD just as fast running PHP as Nginx :wink:

You could combine these two (mariadb & apache+php) in a compose file for easy starting and stopping…

I’ve set up a LAMP stack (for Wordpress, but it’s so generic it should work for other setups) using the generic MariaDB docker image and a PHP+Apache docker image. I’m using two podman containers that share networking and namespace through a podman pod. Very easy to set up, I guess I could make a script for it or even generate a kube yaml file, but it’s just three commands, so I didn’t bother.

I posted instructions in another thread: Why don't toolbox containers include sytemd?

Since this is the Silverblue forum, I would advise against using Docker and docker-compose.yml files. podman-compose is promising, but not quite there yet, you’re better off using podman pods.

Do podman pods have network namespaces when running rootless?

I’m using docker-compose in a dev environment, because it’s super duper easy but want to switch to using podman.

I haven’t seen it mentioned on here, but you should give Fedora CoreOS a try if you want to set up a LAMP stack. It seems to be the server equivalent of Silverblue, which is more focused on the desktop. I’m sure the devs for CoreOS would absolutely love your feedback and you’d likely get better support for what you are trying to accomplish as well!

For webservers (e.g. testing and production) maybe, but the question was about running a local stack for development. This can easily be done by running MariaDB and Apache+PHP in containers :slight_smile:

I’m running rootless. I’m a noob, though, so I could be confused on the terminology.

Try the commands I linked to above, and find out for yourself. :wink:


# PHP with Apache in a new pod:
podman run --security-opt label=disable -it --name wp_apache --pod=new:wp -p 8080:80 -v "$PWD":/app/ -d webdevops/php-apache:latest
# MariaDB (attaching itself to the pod created in the last step):
podman run --security-opt label=disable -it --name wp_maria --pod=wp -e MARIADB_ROOT_PASSWORD=strongpassword -e MARIADB_DATABASE=wp -e MARIADB_USER=username -e MARIADB_PASSWORD=password -d mariadb/server:latest
# I then need to manually USE the new db. Connect to the container:
podman exec -it wp_maria bash -lc mysql
# Then inside the container:
USE wp;

My wp-config.php then uses the pod name (“wp”, in my case) instead of localhost in the DB_HOST line, i.e. define('DB_HOST', 'wp');

This setup can also be saved in a kube yaml file (or a shell script for that matter) if you need to run this setup several times. I don’t bother since it’s just three commands.


That makes sense, so there’s no service discovery (everything is attached to wp)? So I couldn’t have two services running inside the pod using port 80 for example.