Package your PHP application as a ZIP file and deploy it to Serverless App Engine (SAE) using code package deployment.
Prerequisites
Before you begin, make sure you have:
A PHP application packaged as a ZIP file that meets SAE packaging requirements
An Alibaba Cloud account with access to the SAE console
(Optional) A pre-created namespace, vSwitch, and security group if you want to use an existing network configuration
Deploy the application
Log on to the SAE console, go to Applications > Applications in the left-side navigation pane, select a deployment region, and then click Create Application.
If Applications > Applications is not in the navigation pane, go to Applications > Microservice Applications instead.
Select an application version.
ImportantLightweight Edition and Professional Edition are currently in invitation-only testing. If you are not participating in invitation-only testing, the application defaults to Standard Edition and you do not need to select a version.
Edition Application monitoring Microservice governance Lightweight Edition Not supported Not supported Standard Edition Basic Application Monitoring included; Advanced Application Monitoring requires additional purchase Requires additional activation and purchase Professional Edition Advanced Application Monitoring included Included On the Create Application page, enter an Application Name and configure the following settings.
a. Select a namespace.
A namespace maps to a Kubernetes namespace and provides resource isolation across environments. You cannot change the namespace after the application is created.
System Created: Use the default namespace, vSwitch, and security group that SAE creates in the selected region.
Existing Namespace: Select a namespace, vSwitch, and security group that you created in advance.
b. Configure code package deployment.
For Application Deployment Method, select Code Package Deployment, then click Configure Code Package Deployment. Under Technology Stack Language, select PHP and the PHP environment that matches your code.
Configure the following parameters, then click OK.
Parameter Description Upload Method Upload a local ZIP file, or enter the URL of a code package. Version Enter a version number, or click Use Timestamp As Version Number. Time Zone Settings Select the time zone for the application. Startup Command Leave blank if your package follows PHP code package specifications. Custom Runtime Environment Settings (Optional) Pre-install tools, download or modify files, and install runtime dependencies or extensions. Options include PHP Extensions, PHP PECL Extensions, and Customize The Runtime Environment By Command Line. See the example below. Custom Php.ini (Optional) Enter the content of your php.iniconfiguration file. Set Php.ini Mount Path to the mount path, for example/usr/local/etc/php/php.ini.Custom runtime environment example
The following script installs the
gdextension with common image format support:#!/bin/bash docker-php-ext-configure gd \ --with-gd \ --with-webp-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib-dir \ --with-xpm-dir \ --with-freetype-dir \ && docker-php-ext-install -j$(nproc) gdVerify php.ini configuration
After deployment, run the following command in Webshell to confirm that your
php.inifile is loaded:php -i | grep iniExpected output:
Loaded Configuration File => /usr/local/etc/php/php.inic. Configure capacity.
In the Capacity Settings section, set Single Instance Type and the number of Instances.
(Optional) Click Next: Advanced Settings to configure additional features.
Runtime environment and lifecycle
Set environment variables, Hosts binding, and configuration injection to update runtime settings without rebuilding the image.
Configure health checks to automatically restart unhealthy instances and route traffic only to ready instances.
Set lifecycle hooks to run custom commands on startup and shutdown, including graceful shutdown.
Network access
Register and discover services between applications using service registration and discovery. Additional fees apply for Microservice Engine (MSE) service registration and discovery.
Expose applications externally by binding a Network Load Balancer (NLB), binding a CLB, or configuring gateway routing. Additional fees apply.
Enable outbound internet access by configuring a NAT Gateway or binding an Elastic IP Address (EIP) to instances. Additional fees apply.
Data persistence
Store data in Apsara File Storage NAS, Object Storage Service (OSS), or a database to prevent data loss. Additional fees apply.
Logs and monitoring
View real-time logs and resource usage immediately after deployment, without additional configuration. Optionally, forward logs to Simple Log Service (SLS) or ApsaraMQ for Kafka for centralized analysis. Additional fees apply.
Application Real-Time Monitoring Service (ARMS) helps you identify slow or failing interfaces, trace performance bottlenecks, and reproduce call parameters.
Standard Edition: ARMS Basic Edition monitoring is available after deployment. Activate ARMS Pro monitoring separately (additional fees apply).
Professional Edition: Enable Application Monitoring in Advanced Settings to access ARMS Pro monitoring at no additional cost.
Other features
Microservice Governance enables Lossless Online And Offline, Traffic Protection, End-to-end Grayscale, and Same-zone Routing Priority for Java applications.
Standard Edition: Activate after deployment (additional fees apply).
Professional Edition: Enable Microservice Governance in Advanced Settings to configure Lossless Online And Offline at no additional cost. For additional governance features, go to the application details page after deployment to configure.
Enable the CPU Burst feature (Standard Edition and Professional Edition only) to handle higher CPU load during application startup.
Add Sidecar containers to separate non-business functions from the main container.
Click Create Application.
Verify the deployment
Creating an application takes 1–2 minutes. To confirm the deployment succeeded:
Go to Applications > Applications in the SAE console. The application appears in the list with a Running status when deployment is complete.
Click the application name to open its details page, then check Change History for the deployment status. A successful deployment shows all instances in a running state. If the deployment failed, no instances are created — review the error details in Change History to troubleshoot.
(Optional) Click Webshell on the details page to open a browser-based terminal and interact with a running instance directly.
What's next
After your application is running, you can:
Adjust capacity: Manually scale instances or change instance specifications at any time.
Automate scaling: Configure Auto Scaling policies to add or remove instances based on load.
Reduce idle costs: Enable idle mode to lower resource consumption when the application is not in use.
Update configuration: On the application details page, click Deploy Application to apply new settings. The application restarts automatically — perform updates during off-peak hours to minimize impact.