Deploy an application using a code package

Updated at:

SAE supports several technology stacks and runtime environments for code package deployment. Create a code package that meets SAE requirements before you begin. If your stack is not listed, deploy the application using an image instead.

Java

Runtime environment

Update time

JDK version

Operating system version

Open source

Maintained

Description

Dragonwell 21

2024-07-18

21.0.3.0.3+9

CentOS Linux release 7.9.2009

Yes

Yes

Open-source Dragonwell 21

Dragonwell 17

2022-07-11

17.0.3.0.3+7

CentOS Linux release 7.9.2009

Yes

Yes

Open-source Dragonwell 17

Dragonwell 11

2021-08-27

11.0.10.10-AJDK

CentOS Linux release 7.9.2009

No

Yes

  • Updated Dragonwell and OpenJDK.

  • Updated the operating system version.

  • Added support for Chinese and English fonts.

  • Significantly optimized the startup speed.

2020-09-27

Open-source Dragonwell 11

Dragonwell 8

2021-10-18

1.8.0_302

CentOS Linux release 7.9.2009

Yes

Yes

Fixed an issue that may cause high CPU utilization.

2021-08-27

  • Updated Dragonwell and OpenJDK.

  • Updated the operating system version.

  • Added support for Chinese and English fonts.

  • Significantly optimized the startup speed.

2020-09-27

Wisp coroutines and Netty NIO compatibility self-check are enabled by default. Open-source Dragonwell 8.

OpenJDK 21

2023-09-19

21

Debian 11

Yes

Yes

None

OpenJDK 17

2021-09-14

17.0.2

Debian 11

Yes

Yes

ARMS recommends that you use JDK 17.0.9 or later.

OpenJDK 11

2018-09-25

11.0.16

Debian 11

Yes

Yes

ARMS recommends that you use JDK 11.0.17 or later.

OpenJDK 8

2019-06-19

1.8.0_191

CentOS Linux release 7.6.1810

Yes

No

None

OpenJDK 7

2019-02-25

1.7.0_201

CentOS Linux release 7.6.1810

Yes

No

ARMS no longer supports this version.

openjdk-8u191-jdk-alpine3.9

2019-02-25

1.8.0_191

alpine 3.9.2

Yes

No

Some commands in the Alpine image are different from the commands in the CentOS operating system. Examples:

  • telnet: The telnet command in the Alpine image does not support the -e parameter.

  • curl

  • wget

openjdk-7u201-jdk-alpine3.9

2019-02-25

1.7.0_201

alpine 3.9.2

Yes

No

Some commands in the Alpine image are different from the commands in the CentOS operating system. Examples:

  • telnet: The telnet command in the Alpine image does not support the -e parameter.

  • curl

  • wget

PHP

Runtime overview

Online applications: Nginx with PHP-FPM

SAE provides a default LNMP (Linux, Nginx, MySQL, PHP) environment with these components:

  • The official PHP-FPM base image.

  • Built-in official Nginx.

  • Common built-in PHP extensions.

For additional dependencies, use these Alibaba Cloud products:

Application monitoring: ARMS

For SAE applications with PHP versions 5.4 to 7.3, you can enable application monitoring to obtain more detailed monitoring information, such as inter-application call chain tracing and resource access latency for ApsaraDB RDS for MySQL and Tair (Redis OSS-compatible). Related documents:

PHP runtime description

Software versions

Publicly available PHP environments. For later versions, join the DingTalk group (ID: 32874633) and contact a product technical expert for assistance.

Runtime environment

Update time

PHP version

Nginx version

Operating system version

Description

PHP-FPM 7.3

2021-12-27

7.3.32

1.18.0

Debian 11.0

  • Supports built-in fonts.

  • Supports built-in official PHP extensions.

  • Supports built-in PHP PECL extensions.

PHP-FPM 7.2

2021-09-17

7.2.34

1.18.0

Debian 10.7

None

PHP-FPM 7.1

2021-09-17

7.1.33

1.18.0

Debian 10.2

None

PHP-FPM 7.0

2021-09-17

7.0.33

1.18.0

Debian 9.6

None

PHP-FPM 5.6

2021-09-17

5.6.40

1.18.0

Debian 9.6

None

PHP-FPM 5.5

2021-09-17

5.5.38

1.18.0

Debian 8.5

None

PHP-FPM 5.4

2021-09-17

5.4.45

1.18.0

Debian 8.2

None

System directories

The SAE PHP environment default directories for code package deployment:

Type

Path

Description

Directory

/home/admin/app/

The default directory for package deployment.

Directory

/home/admin/app/nginx/

  • The default Nginx site directory. This directory corresponds to the ./nginx/ directory in the demo package.

  • Supports Nginx server {} configurations. ngx_http_core_module.

Directory

/home/admin/app/php/

The default PHP application directory. This directory corresponds to the ./php/ directory in the demo package.

File

/usr/local/etc/php.ini

Recommended php.ini path in SAE. Set the configuration file for a PHP application.

Default PHP-FPM configurations:

Type

Path

Description

Directory

/usr/local/etc/php

PHP_INI_DIR.

Directory

/usr/local/etc/php/conf.d/

The configuration directory for built-in PHP extensions. This directory stores the default .ini files for the extensions.

File

/usr/local/etc/php-fpm.conf

The default PHP-FPM configuration file. FastCGI Process Manager (FPM). To modify, use Manage and use configuration items (K8s ConfigMap).

Default Nginx configurations:

Type

Path

Description

File

/usr/sbin/nginx

The official Nginx program.

Directory

/etc/nginx/

The default Nginx configuration directory.

File

/etc/nginx/nginx.conf

The default nginx.conf file. The http {} configuration references /home/admin/app/nginx/ by default. To modify the http {} configuration, use Manage and use configuration items (K8s ConfigMap).

Built-in extensions

The PHP environment provided by SAE supports the following extensions:

Related permissions

PHP-FPM and Nginx run as the www-data user by default.

Service

Permission USER GROUP

Description

PHP-FPM

Process

www-data www-data

The default path of the PHP configuration file is /usr/local/etc/php-fpm.conf.

Nginx

Process

www-data www-data

By default, the Nginx configuration file is located at /etc/nginx/nginx.conf.

File directory

Directory

root root

The deployment directory for code packages is /home/admin/app/. The following is an example:

drwxrwxrwx 2 root root 4096 May 13  2021 nginx
drwxrwxrwx 1 root root 4096 Apr  8 11:45 php
Important

To prevent application failures, do not change the user.

PHP extension support

Official and PECL extensions

Configure php.ini during deployment to enable built-in extensions (official PHP and PECL). Set the configuration file for a PHP application.

Run this command in the Webshell to list built-in extensions. View the Webshell.

php -m

Built-in extensions by runtime environment:

PECL 7.3

[PHP Modules]
amqp
ARMS
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
imagick
json
libxml
mbstring
mcrypt
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
yaml
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

PECL 7.2

[PHP Modules]
amqp
ARMS
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
imagick
json
libxml
mbstring
mcrypt
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
yaml
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

PECL 7.1

[PHP Modules]
amqp
ARMS
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
imagick
json
libxml
mbstring
mcrypt
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
yaml
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

PECL 7.0

[PHP Modules]
amqp
ARMS
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
imagick
json
libxml
mbstring
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
yaml
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

PECL 5.6

[PHP Modules]
amqp
ARMS
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
imagick
json
libxml
mbstring
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
yaml
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

PECL 5.5

[PHP Modules]
amqp
ARMS
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
imagick
json
libxml
mbstring
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
yaml
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

PECL 5.4

[PHP Modules]
amqp
ARMS
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
igbinary
imagick
json
libxml
mbstring
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
recode
redis
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
swoole
sysvmsg
sysvsem
sysvshm
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlrpc
xmlwriter
yaml
zip
zlib

[Zend Modules]
Xdebug

Install extensions using the console and API

Enable official PHP extensions or install specific PECL versions from the SAE console or API. Deploy a PHP application.

Install third-party extensions

The following example installs the YAML extension by compiling source code in PHP-FPM 7.3.

  1. Create an SAE application that uses PHP 7.3 as the runtime environment.

  2. Enable public network access. Configure a NAT gateway to allow an SAE application to access the Internet.

  3. Log on to the instance using the Webshell and run the following commands to install and compile the extension.

    # Obtain the source code.
    wget https://pecl.php.net/get/yaml-2.2.2.tgz
    tar -zxvf yaml-2.2.2.tgz
    # Compile and install the extension.
    cd yaml-2.2.2 && \
    phpize && \
    ./configure && \
    make && make install
  4. Download the extension to your local machine. Use logs to upload and download files for application diagnosis.

    The extension is stored in the following path:

    /home/admin/yaml-2.2.2/modules/yaml.so
  5. Package the extension into a ZIP package. The following code shows the structure of the ZIP package:

    .
    ├── nginx
    │ ├── default.conf
    │ ├── fastcgi_params
    │ ├── global
    │ └── root.dir
    ├── php
    │ ├── index.php
    └── extensions
     └── yaml.so
  6. Deploy the application, upload the new ZIP package, and add a php.ini configuration to enable the extension.

    extension=/home/admin/app/extensions/yaml.so
  7. Log on to the instance using the Webshell and check whether the extension is loaded.

    # php -m | grep yaml
    yaml

Common configurations

Default service ports

Default service ports for Nginx and PHP-FPM in SAE:

Program

Port

Nginx

80

PHP-FPM

127.0.0.1:9000

PHP-FPM logs: standard output

  • By default, PHP-FPM logs are output to real-time logs. The following code shows the configuration. The configuration file path is /usr/local/etc/php-fpm.d/docker.conf.

    [global]
    error_log = /proc/self/fd/2
    log_limit = 8192
    
    [www]
    access.log = /proc/self/fd/2
  • By default, PHP error logs are not configured to be displayed. The following code shows the configuration from the php.ini file:

    error_log => no value => no value
    log_errors => Off => Off
    log_errors_max_len => 1024 => 1024
  • To output error logs to real-time logs, configure the php.ini file with the following setting when you create or deploy the application:

    log_errors = on
    error_log = /proc/self/fd/2

Nginx logs: standard output

  • By default, Nginx logs are output to real-time logs. The following code shows the configuration. The configuration file path is ./nginx/default.conf.

    #access_log /dev/stdout;
    error_log stderr;
  • You can enable access_log. By default, the logs are output to real-time logs.

File cache: PHP code (OPcache)

Configure OPcache in php.ini. SAE enables OPcache by default. OPcache runtime configuration.

  • Enable OPcache: Accelerates code execution and reduces disk I/O. Best for production.

  • Disable OPcache: Code changes take effect immediately. Best for debugging.

The following code shows the php.ini configuration:

; Enable OPcache
opcache.enable=1
; Disable OPcache
;opcache.enable=0

File cache: static resources

Enable or disable Nginx caching for static files (images, videos, CSS, JS) using the Demo and Module ngx_http_headers_module.

  • Enable caching: Improves throughput and reduces read IOPS. Best for production sites with many media files.

  • Disable caching: Access files in real time. Best for debugging, uploads, and downloads.

The following code shows the configuration in the ./nginx/default.conf file:

    # Static resource cache
    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
        # Disable cache
        #expires off;
        # Enable cache
        expires 1s;
    }

Enhanced features

Hot restart services

  • You can use a ConfigMap to dynamically configure and modify file content.

  • You can use the Webshell to dynamically restart services.

    • Hot restart Nginx (without service interruption)

      # Test the validity of the configuration file.
      nginx -t
      # Dynamically restart the service.
      nginx -s reload
    • Hot restart PHP-FPM (This may cause a stream interruption. You need to check the php.ini configuration.)

      ps uax | grep 'php-fpm: master' | grep -v grep | awk '{print $2}' | xargs kill -USR2

Upload and download

SAE supports multiple file transfer methods:

  • Console: Upload and download small files for debugging (max 10 MB).

    Upload and download files from the SAE console. Use the Webshell to upload and download files.

  • Console: remote debugging.

  • Persistent storage: NAS or OSS.

    • When you deploy an application, you can mount NAS or OSS to share a file directory.

    • Upload and download files to or from NAS using Serverless Devs.

    • Upload and download files to or from OSS using the OSS console.

    • Upload and download files to or from OSS using ossutil.

Python

Runtime environment

Update time

Operating system version

Description

Python 3.9.15

2022-10-11

Debian 11.0

Python 3.9.15

.NET Core

SAE base images extend the official .NET images with preconfigured troubleshooting tools and font packages.

Version

Base image

Operating system

Runtime

3.1

mcr.microsoft.com/dotnet/aspnet:3.1

Debian GNU/Linux 10 (buster)

  • Microsoft.AspNetCore.App 3.1.32

  • Microsoft.NETCore.App 3.1.32

5.0

mcr.microsoft.com/dotnet/aspnet:5.0

Debian GNU/Linux 10 (buster)

  • Microsoft.AspNetCore.App 5.0.17

  • Microsoft.NETCore.App 5.0.17

6.0

mcr.microsoft.com/dotnet/aspnet:6.0

Debian GNU/Linux 11 (bullseye)

  • Microsoft.AspNetCore.App 6.0.33

  • Microsoft.NETCore.App 6.0.33

7.0

mcr.microsoft.com/dotnet/aspnet:7.0

Debian GNU/Linux 11 (bullseye)

  • Microsoft.AspNetCore.App 7.0.20

  • Microsoft.NETCore.App 7.0.20

8.0

mcr.microsoft.com/dotnet/aspnet:8.0

Debian GNU/Linux 12 (bookworm)

  • Microsoft.AspNetCore.App 8.0.8

  • Microsoft.NETCore.App 8.0.8

9.0

mcr.microsoft.com/dotnet/aspnet:9.0

Debian GNU/Linux 12 (bookworm)

  • Microsoft.AspNetCore.App 9.0.6

  • Microsoft.NETCore.App 9.0.6

HTML

Runtime environment

Nginx version

Base image

Operating system version

nginx 1.20

1.20.2

nginx:1.20

Debian GNU/Linux 11 (bullseye)

nginx 1.22

1.22.1

nginx:1.22

Debian GNU/Linux 11 (bullseye)

nginx 1.24

1.24.0

nginx:1.24

Debian GNU/Linux 11 (bullseye)

nginx 1.26

1.26.3

nginx:1.26

Debian GNU/Linux 12 (bookworm)

nginx 1.28

1.28.0

nginx:1.28

Debian GNU/Linux 12 (bookworm)