Deploy a secure and minimal PHP-FPM container image built by Minimus to optimize security
PHP-FPM (FastCGI Process Manager) is an alternative FastCGI daemon for PHP that optimizes performance and scalability and can support strenuous loads by managing a pool of PHP worker processes.While PHP is tightly coupled with Apache, PHP-FPM has its own process manager and is typically coupled with a web server like NGINX or Nginx Proxy Manager.
The following tutorial will guide you through the first steps of deploying the Minimus PHP-FPM container image. In this scenario, we will run the PHP-FPM server with Nginx Proxy Manager for SSL certificates.To begin, authenticate to the Minimus registry:
Create a php folder and save the following code to a Dockerfile in the /php directory:
Dockerfile
Copy
Ask AI
FROM reg.mini.dev/php:fpm# Install any PHP extensions if needed# Set working directoryWORKDIR /app# Copy application filesCOPY ./src /var/www/html
If you want to enable additional extensions then you can create a private image in Image Creator with the appropriate additional extensions.Create an nginx folder and save the following code to a Dockerfile in the /nginx directory:
Dockerfile
Copy
Ask AI
FROM reg.mini.dev/nginx-proxy-manager:latest# Copy nginx configurationCOPY nginx.conf /etc/nginx/nginx.conf
Create a src folder and save the following code to a new file index.php under the /src directory:
index.php
Copy
Ask AI
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>PHP-FPM Welcome</title> <meta http-equiv="refresh" content="5"> <style> body { font-family: sans-serif; margin: 40px; background-color: #f9f9f9; color: #333; } .container { max-width: 600px; padding: 20px; background: white; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); } h1 { color: #007acc; } p { margin: 16px 0; } </style></head><body> <div class="container"> <?php echo "<h1>Welcome to PHP-FPM - Built by Minimus!</h1>"; echo "<p>👍 Looking great!</p>"; echo "<p>Your PHP-FPM server is up and running.</p>"; $currentTime = date("Y-m-d H:i:s"); echo "<p><strong>Current time:</strong> $currentTime</p>"; ?> </div></body></html>
Create a directory /letsencrypt .You project directory should now look like this:
Open your web browser to view the welcome page at: http://localhost:8080. You should see a Minimus greeting with the current time.Once ready to clean up, run the following command to remove the containers and their associated volumes: