All Products
Search
Document Center

Alibaba Cloud SDK:Install PHP

Last Updated:Jul 23, 2025

This topic describes how to install PHP on different operating systems.

Windows

  1. Visit the official website of PHP for Windows, select a suitable PHP version, and download the corresponding x64 Thread Safe ZIP package, such as PHP 8.3.8.

    image

  2. Decompress the ZIP file and configure environment variables.

    1. Right-click the This PC icon and select Properties.

    2. Click Advanced system settings.

    3. On the Advanced tab of the System Properties window, click Environment Variables.

    4. In the System variables section, find and select the Path variable and click Edit.

    5. Click New in the edit window, and then add the PHP installation directory (for example, D:\php) and the PHP extension directory (for example, D:\php\ext).

  3. Configure the php.ini file: php.ini is the PHP configuration file, which is mainly used to control the behavior and features of the PHP interpreter.

    Find the php.ini-development file in the decompressed folder. This file is typically used in a development environment. Rename the file to php.ini.

  4. Verify the installation: Press Win+R, enter cmd, and press Enter to open the command line. Enter php -v in the command line. If information similar to the following appears, the installation is successful.

    PHP 8.3.8 (cli) (built: Jun  4 2024 18:52:30) (ZTS Visual C++ 2019 x64)
    Copyright (c) The PHP Group
    Zend Engine v4.3.8, Copyright (c) Zend Technologies

Linux

  1. Run the following commands to install PHP:

    • Alibaba Cloud Linux/CentOS

      sudo yum install epel-release
      sudo yum install php
      
    • Ubuntu/Debian

      sudo apt update
      sudo apt install -y php
      
  2. Verify the installation.

    Run php -version. If the following information appears, the installation is successful.

    PHP 8.4.10 (cli) (built: Jul  3 2025 12:41:53) (NTS)
    Copyright (c) The PHP Group

macOS

You can install PHP and Composer on macOS using the Homebrew tool.

Note

If you encounter network issues when installing Homebrew or using Homebrew to install PHP, you can try setting the Homebrew installation source to a mirror in the Chinese mainland to resolve the issue. For example, you can use the USTC open source mirror:

Set Homebrew installation source to USTC mirror

Note

Homebrew supports setting the installation source by modifying environment variables. You can also use this method to accelerate the download process when installing Homebrew for the first time.

export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
brew update
  1. Use Homebrew to install the latest version of PHP:

    brew install php
    
  2. You can verify that PHP is successfully installed by running the following command:

    php -v
    

What to do next

Composer is a dependency management tool for PHP and an important tool for modern PHP development. For more information, see Install and use Composer.