This topic describes how to install PHP on different operating systems.
Windows
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.

Decompress the ZIP file and configure environment variables.
Right-click the This PC icon and select Properties.
Click Advanced system settings.
On the Advanced tab of the System Properties window, click Environment Variables.
In the System variables section, find and select the Path variable and click Edit.
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).
Configure the php.ini file:
php.iniis the PHP configuration file, which is mainly used to control the behavior and features of the PHP interpreter.Find the
php.ini-developmentfile in the decompressed folder. This file is typically used in a development environment. Rename the file tophp.ini.Verify the installation: Press
Win+R, entercmd, and press Enter to open the command line. Enterphp -vin 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
Run the following commands to install PHP:
Alibaba Cloud Linux/CentOS
sudo yum install epel-release sudo yum install phpUbuntu/Debian
sudo apt update sudo apt install -y php
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.
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:
Use Homebrew to install the latest version of PHP:
brew install phpYou 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.