This repository provides Docker images for LNMP stack (L
inux, N
ginx, M
ariaDB, and P
HP-FPM), commonly referred to as LEMP.
It is designed to simplify the deployment of PHP applications with a robust and modern environment, offering both Development and Production versions to meet different deployment needs.
The images are built on top of other modular images from the fbraz3
ecosystem, ensuring flexibility, maintainability, and ease of use.
💡 For a complete list of available images, please visit the PHP System Docs page.
This project provides two distinct versions for different use cases:
- Purpose: Designed for local development and testing
- Features:
- MariaDB with no root password (empty password)
- phpMyAdmin accessible at
/pma/
endpoint - Relaxed security settings for ease of development
- Direct database access without authentication
- Purpose: Optimized for production environments
- Features:
- MariaDB with mandatory root password configuration
- Enforced password security: Container will fail to start if using default password
- Custom SQL scripts support: Execute custom SQL files at startup
- No phpMyAdmin included for security
- Secure database configuration
- Root password configurable via environment variables
- Anonymous users and test databases removed
- Enhanced security settings
The image follows a consistent tagging scheme:
- Production:
fbraz3/lnmp:{php_version}
(e.g.,8.2
,8.3
,8.4
) - Development:
fbraz3/lnmp:{php_version}-dev
(e.g.,8.2-dev
,8.3-dev
)
- Production:
fbraz3/lnmp:{php_version}-phalcon
(e.g.,8.2-phalcon
,8.3-phalcon
) - Development:
fbraz3/lnmp:{php_version}-phalcon-dev
(e.g.,8.2-phalcon-dev
)
fbraz3/lnmp:latest
- Latest production versionfbraz3/lnmp:latest-dev
- Latest development versionfbraz3/lnmp:latest-phalcon
- Latest Phalcon production versionfbraz3/lnmp:latest-phalcon-dev
- Latest Phalcon development version
- All images support both
amd64
andarm64
architectures - LEMP variants are also available as
fbraz3/lemp:{tag}
This image supports multiple flavors to cater to different use cases:
- Vanilla: A standard LNMP stack with no additional frameworks
- Phalcon: Includes the Phalcon PHP framework pre-installed
Perfect for local development with easy database access and debugging tools.
# docker-compose.yml
services:
web:
image: fbraz3/lnmp:8.4-dev # or fbraz3/lnmp:8.4-phalcon-dev
volumes:
- ./:/app/public/
ports:
- "127.0.0.1:80:80"
- "127.0.0.1:3306:3306"
Access Points:
- Application:
http://localhost/
- phpMyAdmin:
http://localhost/pma/
- Database:
localhost:3306
(user:root
, password: empty)
Secure configuration suitable for production environments.
# docker-compose.yml
services:
web:
image: fbraz3/lnmp:8.4 # or fbraz3/lnmp:8.4-phalcon
environment:
- MYSQL_ROOT_PASSWORD=your_secure_password_here
- MYSQL_APP_DATABASE=my_application # Optional: create app database
- MYSQL_APP_USER=app_user # Optional: create app user
- MYSQL_APP_USER_PASSWD=app_password # Optional: app user password
volumes:
- ./:/app/public/
- mysql_data:/var/lib/mysql
ports:
- "80:80"
restart: unless-stopped
volumes:
mysql_data:
Access Points:
- Application:
http://your-domain/
- Database: Internal access only (user:
root
, password: set via environment)
Important: Always set a strong MYSQL_ROOT_PASSWORD
in production!
The production images support executing custom SQL scripts during container startup. This feature allows you to initialize your database with custom schema, data, or configuration.
- Create your SQL files: Place your
.sql
files in a directory on your host system - Mount the directory: Bind-mount your SQL scripts directory to
/sql-scripts
in the container - Automatic execution: All
.sql
files in the directory will be executed automatically during first startup
# docker-compose.yml
services:
web:
image: fbraz3/lnmp:8.4
environment:
- MYSQL_ROOT_PASSWORD=your_secure_password_here
volumes:
- ./:/app/public/
- ./sql-scripts:/sql-scripts # Mount your custom SQL scripts
- mysql_data:/var/lib/mysql
ports:
- "80:80"
restart: unless-stopped
# Directory structure example
project/
├── sql-scripts/
│ ├── 01-create-users.sql
│ ├── 02-create-tables.sql
│ └── 03-insert-data.sql
└── docker-compose.yml
- SQL scripts are executed only on first startup (when database is initialized)
- Scripts are executed in alphabetical order
- Use numeric prefixes (e.g.,
01-
,02-
) to control execution order - All scripts run with root privileges
- This feature is only available in production images for security reasons
⚠️ Never use development images in production- Database has no root password
- phpMyAdmin is publicly accessible
- Intended for local development only
- ✅ Secure by default
- Mandatory root password
- No phpMyAdmin interface
- Anonymous users removed
- Test databases removed
- Database binds to localhost only
Variable | Required | Default | Description |
---|---|---|---|
MYSQL_ROOT_PASSWORD |
Yes | defaultrootpassword |
Root password for MariaDB |
MYSQL_APP_DATABASE |
No | - | Create application database |
MYSQL_APP_USER |
No | - | Create application user |
MYSQL_APP_USER_PASSWD |
No | - | Password for application user |
Example:
docker run -e MYSQL_ROOT_PASSWORD=mySecurePassword123 \
-e MYSQL_APP_DATABASE=my_app \
-e MYSQL_APP_USER=app_user \
-e MYSQL_APP_USER_PASSWD=app_secure_password \
fbraz3/lnmp:8.4
Note:
- When
MYSQL_APP_USER
andMYSQL_APP_USER_PASSWD
are provided, the user will be granted full privileges on the database specified byMYSQL_APP_DATABASE
(if provided). - Important:
MYSQL_APP_USER
andMYSQL_APP_USER_PASSWD
must be used together. Creating a user without a password is a security risk and is not supported.
Development images don't require any specific environment variables and work out of the box.
This image allows you to customize PHP directives using environment variables.
For detailed instructions, refer to the php-fpm-docker documentation.
Cronjobs can be configured by binding a file to /cronfile
in the container. The system will automatically install and execute the jobs.
For more details, see the php-fpm-docker documentation.
To enable email sending, this image relies on the configuration provided in the php-base-docker
project.
Follow the instructions in the php-base-docker documentation to set up email functionality.
Contributions are welcome! Feel free to open issues or submit pull requests to improve the project.
Please visit the CONTRIBUTING.md file for guidelines on how to contribute to this project.
I spend a lot of time and effort maintaining this project. If you find it useful, consider supporting me with a donation:
This project is licensed under the Apache License 2.0, so you can use it for personal and commercial projects. However, please note that the images are provided "as is" without any warranty or guarantee of any kind. Use them at your own risk.