How to Build and Deploy PHP Application Images on the Omega Platform
This article guides readers through the architecture, extension types, image construction steps, configuration details, and local debugging procedures for deploying PHP applications as container images on the Omega platform, highlighting best practices and common pitfalls.
Background: Container technology can greatly improve PHP application deployment efficiency, reducing initial deployment from half a day to minutes; Omega platform supports all company applications.
Purpose: This article explains the process and details of building PHP application images on the Omega platform.
Part 1: PHP Technology Overview
This section covers the PHP architecture diagram, server architecture, and extension classification.
1.1 PHP Architecture Diagram
PHP consists of four layers from bottom to top:
Zend Engine : Core written in C, parses PHP code into opcodes, provides data structures, memory management, and APIs.
Extensions : Provide built‑in functions and libraries; developers can create custom extensions.
SAPI : Server Application Programming Interface that decouples PHP from the surrounding environment.
Application Layer : The PHP program itself, running via various SAPIs (web server, CLI, etc.).
1.2 PHP Server Architecture
Two common stacks:
LAMP : Apache handles static files; PHP runs as an Apache module.
LNMP : Nginx handles static files; PHP‑FPM processes PHP requests via FastCGI.
1.3 PHP Extension Packages
Extensions are installed from source; there are three types:
Extension Type
Description
Download Method
Installation Method
Core Extension
Included in PHP source, compiled via configure options.
Source included, no download.
Compile with PHP source.
General Extension
Available from the PECL repository.
PECL website.
Install via yum/pecl or source.
Non‑General Extension
Not in PECL; must obtain source from GitHub or other sites.
GitHub or personal site.
Compile from source.
Part 2: Building PHP Images
The deployment workflow on Omega is illustrated below:
Key steps:
Build the image: start from a PHP base image and add application code.
Publish the image: store it in an image registry for deployment or rollback.
Deploy the image: run the image on a Kubernetes cluster.
Common issues addressed:
Base image construction : Separate images for PHP5 and PHP7, built with required extensions, Nginx, etc.
OS selection : Custom images are used instead of official ones to keep the image minimal and meet security policies.
Extension installation : Performed via source compilation to ensure consistency.
File paths inside the image (e.g., /app/bin, /app/conf, /app/www, /app/logs, ~/runtime).
Special configuration : php.ini includes auto_prepend_file = /app/conf/Environment.php; nginx.conf includes include /app/conf/vhosts*.conf;. These files are added manually through the Omega platform.
Deployment steps on Omega : Create project, configure files, and start the project via the Omega UI.
Part 3: Practical Local Debugging
Steps to run the image locally:
Obtain the image name from Omega.
Prepare configuration files (Environment.php, nginx config) and mount them.
Start the container, e.g.:
docker run -d -p <Local Port>:<Container Port> --name <Container Name> -v <Local Conf path>:/app/conf -v <Local code>:/app/www <Image Name>Example:
docker run -d -p 10080:80 --name test -v /Users/nian/ziroom/dockerfile/php7/Archive/conf:/app/conf harbor.ziroom.com/rent-web/mis:release_20190828100643_daily-5757After a successful start, the application is reachable at http://php.test.local:10080. An alternative approach is to create a new image via a Dockerfile (see attached Dockerfile.zip).
References:
https://www.cnblogs.com/phphuaibei/archive/2011/09/13/2174927.html
https://littlesqx.github.io/2017/10/15/lamp-lnmp-lanmp/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
