This topic describes how to deploy a ThinkPHP application to Function Compute. Compared with traditional deployment methods, you can skip the steps such as purchasing a machine and deploy the traditional ThinkPHP application remotely and directly for production with one click. The ThinkPHP application also has the auto scaling, pay-as-you-go and maintenance-free features.

Background information

ThinkPHP is a free open source, fast, simple, object-oriented lightweight PHP development framework. It was born for Agile Web application development and simplify enterprise application development. ThinkPHP has always been designed in a simple and practical way, with excellent performance and simple code, and ease of use at the same time. ThinkPHP-based applications that are released under the Apache2 open source license agreement can be used for free. ThinkPHP-based applications can even be released as an open source project or be sold as commercial products.

Step 1: Prepare the environment

You only need to install Funcraft instead of installing Docker. The simplest method is to download the executable binary files.

  1. Install Funcraft on the local machine. For more information, see Install Funcraft.
  2. Run the fun --version command to check whether the installation is successful.

Step 2: Deploy an application

  1. Use the following command to create a ThinkPHP project. If you have an existing ThinkPHP project, skip this step.
    composer create-project topthink/think tp                        
  2. Use the following command to enter the newly created project or an existing project.
    cd <project-name>            
  3. Use the following command to run the local project.
    php think run           
  4. Run the fun deploy -y command to deploy the project to Function Compute.

    Funcraft automatically enters the deployment process.

    fun deploy -y
    current folder is not a fun project.
    downloading nginx and php7.2 zip from to /private/var/folders/wl/_2ngtj291wx1cj55xlnn290w0000gn/T/
    extract nginx and php7.2 zip to custom runtime...
    ... ... ...
            trigger httpTrigger deploy success
        function tp deploy success
    service tp deploy success
    Detect 'DomainName:Auto' of custom domain 'Domain'
    Request a new temporary domain ...
    The assigned temporary domain is,expired at 2020-04-10 13:17:42, limited by 1000 per day.
    Waiting for custom domain Domain to be deployed...
    custom domain Domain deploy success           

    After the deployment is successful, you can see the temporary domain name generated by Function Compute in the log. Through this temporary domain name, you can directly access the just deployed application.

    Note The temporary domain name is only used for demonstration and development and is only valid for a period. For production purposes, bind a domain name that has been filed with Alibaba Cloud.