Deploy an application using a code package

更新时间:
复制 MD 格式

When you deploy an application using a code package, SAE supports the technology stacks and runtime environments that are described in this topic. Before you start, you must create a code package that meets SAE requirements. If your technology stack or runtime environment is not in the following list, you must deploy the application using an image.

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

For more information, see Open-source Dragonwell 21.

Dragonwell 17

2022-07-11

17.0.3.0.3+7

CentOS Linux release 7.9.2009

Yes

Yes

For more information, see 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

For more information, see 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

Features such as Wisp coroutines and self-check for Netty NIO compatibility are enabled by default. For more information, see 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 introduction

Online applications: Nginx with PHP-FPM

SAE provides a default LNMP (Linux, Nginx, MySQL, and PHP) runtime environment for PHP web applications. This environment includes the following components:

  • The official PHP-FPM base image.

  • Built-in official Nginx.

  • Common built-in PHP extensions.

If your application depends on other resources, you can use the following 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).For more information, see the following documents:

PHP runtime description

Software versions

The following table describes the publicly available PHP environments. If you require a later version of the PHP environment, 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 uses the following default directories for 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. For more information, see 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

The recommended path for the php.ini configuration file in SAE. For more information, see Set the configuration file for a PHP application.

The following table describes the default configurations of official PHP-FPM.

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 configuration file for PHP-FPM. For more information, see FastCGI Process Manager (FPM). To learn how to modify the file, see Manage and use configuration items (K8s ConfigMap).

The following table describes the default configurations of official Nginx.

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 configuration file nginx.conf. This file contains the http {} configuration. The http {} configuration references the configuration in the /home/admin/app/nginx/ path by default. To learn how to modify the file, see Manage and use configuration items (K8s ConfigMap).

Built-in extensions

The PHP environment provided by SAE supports the following extensions:

Related permissions

Official PHP-FPM and Nginx use the www-data user to run applications by default. The following table describes the permissions.

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

When you deploy an application, you can configure the php.ini file to enable built-in extensions, including official PHP extensions and PECL extensions. For more information, see Set the configuration file for a PHP application.

Run the following command in the Webshell to obtain the specific built-in extensions. For information about how to open the Webshell, see View the Webshell.

php -m

The following code provides sample outputs of the built-in extensions that are supported by different runtime environments:

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

You can enable official PHP extensions or install specific versions of PECL extensions using the SAE console or by calling an API. For more information, see Deploy a PHP application.

Install third-party extensions

This section provides an example of how to install a third-party extension. The example shows how to install the YAML extension by compiling its source code in a PHP-FPM 7.3 environment.

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

  2. Enable public network access. For more information, see 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. For more information, see 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

The following table describes the default service port values of the Nginx and PHP-FPM programs that are configured 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: static files, images, and media

For PHP code, you can configure the php.ini file to enable or disable OPcache. SAE enables OPcache by default. For more information about the configuration, see OPcache runtime configuration.

  • Enable OPcache: This is suitable for online websites to accelerate code execution and reduce disk I/O.

  • Disable OPcache: This is suitable for debugging scenarios. Code changes can take effect in real time.

The following code shows the php.ini configuration:

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

File cache: PHP code

For static files, such as images, videos, CSS, and JS, you can enable or disable Nginx static file caching. For more information about the configuration, see the Demo and Module ngx_http_headers_module.

  • Enable static resource caching: This is suitable for scenarios such as online services and sites with many media files. This improves throughput capacity and reduces read IOPS.

  • Disable static resource caching: This is suitable for scenarios such as remote debugging, uploads, and downloads. This lets you access files in real time.

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 methods for uploading and downloading files. Select a method as needed:

  • Console: Upload and download small files for debugging (The file size cannot exceed 10 MB).

    You can upload and download files from the SAE console. For more information, see 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

For more information, see Python 3.9.15.

.NET Core

To simplify development and deployment, SAE base images are built on the official .NET base images and come preconfigured with common 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)