LNMP Stack Creation
In order to run WordPress, LNMP (Linux, Nginx, MariaDB and PHP) will be installed inside a container using podman.
Podman allows a regular user to manage their pods (containers) without the need for root user privileges. Podman is free, open source and cross-platform (Mac, Windows and Linux) for use as a replacement for Docker.
By default, Podman stores containers in your home folder. This could be an issue if the home folder is on a smaller drive or partition (common for smaller faster SSD Drives). It is possible to move the container storage to another location.
Podman was originally used to compile PHP for the Learning PHP eBook.
This tutorial will create a container that uses Fedora Linux as the operating system, Nginx Web Server, MariaDB for the database and PHP to run a simple WordPress installation.
For this example, I will assume that Podman is installed on your platform of choice. The latest version of WordPress will be downloaded and placed in the default Nginx web root folder. Podman can use any name for the reference and I will called it a Dockerfile so that Docker fans can follow along by replacing “podman” with “docker”.
Requirements For LNMP Podman
Glossary:
Container
Software unit that packages code and all its dependencies for different computing environments.
Image
Container that is standalone and executable.
Docker
Platform that builds, shares and runs container applications.
Dockerfile
Text file without a file extension contains a script of instructions for building an image.
Open source
Freely available for possible modification and redistribution.
Test Tools
Name | Description |
---|---|
CPU | Intel(R) i7 2600 @ 3.40GHz. |
Memory | 16GB DDR3. |
Storage | 400GB SSD. |
Operating System | Fedora Linux Workstation 41. |
Desktop Environment | Gnome 47. |
Name | Description |
Generate Services Script
# Create Start Services File # cat > startservices.sh << 'EOF' #!/bin/sh nohup /usr/sbin/php-fpm -c /etc/php.ini -y /etc/php-fpm.conf & mysqld --datadir='/var/lib/mysql/' --user=mysql & EOF
Generate Dockerfile
# Create Dockerfile # cat > Dockerfile << 'EOF' FROM fedora:latest RUN dnf -y update && dnf -y install nginx mariadb-server php php-common php-fpm php-mysqlnd php-gd wget && dnf clean all RUN wget https://wordpress.org/latest.tar.gz -P /usr/share/nginx/html/ && \ tar -xvzf /usr/share/nginx/html/latest.tar.gz -C /usr/share/nginx/html/ && \ mv /usr/share/nginx/html/wordpress/* /usr/share/nginx/html && \ rm /usr/share/nginx/html/latest.tar.gz && rm -rf /usr/share/nginx/html/wordpress RUN mysql_install_db RUN chown -R mysql:mysql /var/lib/mysql && chown -R mysql:mysql /var/log/mariadb RUN mkdir -p /run/php-fpm && chown -R nginx:nginx /run/php-fpm && chmod 755 /run/php-fpm COPY startservices.sh /startservices.sh RUN chmod +x /startservices.sh && /startservices.sh ENTRYPOINT /usr/sbin/nginx -g 'daemon off;' EOF
Build And Run
podman build --tag mynginx -f ./Dockerfile podman run -p 8080:80 -p 3307:3306 --name mynginxwp -d mynginx
Enter Pod
podman exec -it mynginxwp /bin/bash mysqld_safe & mysql -u root
Generate WordPress Database
-- Change Root Password -- ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword'; -- Create WordPress Db -- CREATE DATABASE dbname; CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost';
View
Open your web browser and point it to http:localhost:8080 or the internal intranet IP address and then wait for the HTML page to load.
Explanation:
- Create an script that will be used to start PHP-FPM and MariaDB.
- Generate a Dockerfile that will be used to build the container image.
- Use podman to build the container.
- Use podman to run the specified container and make it accessible via a specific mapped port number.
- Enter the pod container to change the root database password and create a WordPress database.
- Open your workstation web browser and navigate to the localhost and the assigned port number.
- For other devices such as phones and tablets, use the local workstation IP address and assigned port number in the web browser.




Usage
You can use any Dockerfile and Docker command arguments with Podman. For this tutorial, a custom Dockerfile was created to build a Fedora Linux based container running the LNMP stack (Linux + Nginx + MariaDB + PHP) for WordPress. Podman can be downloaded from Podman.
Open Source
Podman is licensed under the Apache License version 2.0. The permissive license requires the preservation of the copyright notice and disclaimer. It allows commercial use, modification, distribution, and allows making derivatives proprietary, consult the license for more specific details.
Conclusion:
Podman can be used a Docker alternative to create a LNMP stack fo WordPress. Podman uses the same commands as Docker and is daemon-less, allowing a regular user to manage containers.
Podman can manage multiple containers as a single unit, providing a more flexible and powerful way to manage containerized applications. WordPress was completely managed from a single container, but it can also be managed from grouped containers for the individual Linux, Nginx, MariaDB and PHP stack.
If you enjoy this article, consider supporting me by purchasing one of my WordPress Ojambo.com Plugins or programming OjamboShop.com Online Courses or publications at Edward Ojambo Programming Books or become a donor here Ojambo.com Donate
References:
- Podman Container Management Tool
- WordPress Content Management System
- Nginx HTTP Web Server, Reverse Proxy, Load Balancer, Mail Proxy And HTTP Cache
- MariaDB Relational Database Management System
- PHP Scripting Language Focused On Web Development
- Customer Sets Price Plugin for WooCommerce on Ojambo.com
- Learning JavaScript Course on OjamboShop.com
- Learning Python Course on OjamboShop.com
- Learning PHP Course on OjamboShop.com
- Learning JavaScript Paperback on Amazon
- Learning JavaScript Ebook on Amazon
- Learning Python Ebook on Amazon
- Learning PHP Ebook on Amazon
- OjamboServices.com For Custom Websites, Applications & Tutorials