You can create a ZIP package that contains the NGINX configurations for an existing on-premises PHP application or the PHP application that you create on your on-premises machine. You can use the ZIP package to deploy the application in Serverless App Engine (SAE). This topic describes how to create a ZIP package for a PHP application and how to deploy the PHP application by using the ZIP package. This topic also provides the directory structure of the ZIP package and some sample configurations.
Directory structure of the ZIP package
ZIP directory | Runtime directory | Description |
./nginx | /home/admin/app/nginx/ | The directory in which the NGINX configuration file is stored. |
./nginx/*.conf | /home/admin/app/nginx/*.conf | The directory in which configurations of NGINX servers are stored. The |
./php | /home/admin/app/php/ | The directory in which PHP is stored. |
If you want to deploy an application, you can create a ZIP package for the application based on the demo application package and then upload the package to SAE. In this example, the demo application package is used. For more information, see hello-sae-php.zip. The following sample code provides an example of the directory structure after the ZIP package is decompressed.
.
├── nginx
│ ├── default.conf
│ ├── fastcgi_params
│ └── root.dir
├── php
│ ├── index.php
│ └── phpinfo.php
If you do not use NGINX, we recommend that you retain the NGINX configurations in the demo application package to ensure a smooth application startup.
Step 1: Create a ZIP package for a PHP application
Run commands or use a file compression tool to include the ./php and ./nginx directories into a ZIP package. The following section describes how to create a ZIP package by running commands.
Run the following command to download the demo application package:
wget https://sae-demo-cn-shenzhen.oss-cn-shenzhen.aliyuncs.com/demo/1.0/hello-sae-php.zip
Run the following command to decompress the package:
unzip hello-sae-php.zip
Run the following commands in sequence to add custom code to the application package. In this example, the demo application package is used.
echo '<?php' > php/index.php
echo 'echo "Hello my first SAE application";' >> php/index.php
Run the zip command to create a ZIP package.
zip -r sae.demo.zip nginx php
Step 2: Deploy the PHP application
Procedure
For more information, see Deploy a PHP application by using a ZIP package in the SAE console.
Additional configurations for the application
After the PHP application is deployed in SAE, you can view real-time logs to troubleshoot the application. You can also bind a Server Load Balancer (SLB) instance to the application and then access the application over the Internet. The following table describes the sample configurations for the application.
Item | Description |
Default port for HTTP and NGINX | Set the port number to |
Error logs | Include the standard output in real-time logs. |
Access logs | By default, access logs are not displayed. For information about how to obtain the access logs, see NGINX logs: standard output. |