PHP

Installing PHP

PHP 8.2 • Configuration

Installation Options

1. Download Binaries

Download pre-built packages for your platform from the official site:

cd /tmp
curl -O https://www.php.net/distributions/php-8.2.12.tar.gz
tar -xzf php-8.2.12.tar.gz
cd php-8.2.12

2. Windows Installation

Use the official installer or extract the ZIP package:

php -v
# Should output: PHP 8.2.12 (cli) (built: Jun 15 2025 14:30:00) (ZTS Visual C++ 2022 x64)

3. Linux Distributions

# Ubuntu/Debian
sudo apt-get install php8.2

# Red Hat/CentOS
dnf install php-8.2

Some distributions may require enabling the official PHP repository first.

4. macOS Installation

brew install php@8.2
brew link --overwrite php@8.2

5. From Source

./configure --prefix=/usr/local/php-8.2 \
  --with-openssl=/usr/local/openssl-3.x \
  --enable-fpm \
  --with-pdo-mysql=mysqlnd

make
sudo make install

Verification

Basic Check

php -v
# Expected output:
# PHP 8.2.12 (cli) (built: Jun 15 2025 14:30:00) 
# Copyright (c) The PHP Group

For web servers, create a info.php file with phpinfo(); and access it via your browser.

Best Practices

Use Package Managers

Use tools like phpbrew or phpenv for managing multiple PHP versions.

Configuration

Copy php.ini-development to php.ini and adjust settings for your deployment environment.

Web Servers

Use official binaries for common stacks: php-fpm for NGINX or mod_php for Apache.

See Also

php.ini

Details about the configuration file and its directives

View documentation

Getting Started

First steps with PHP: writing your first script

View guide

Tip: For production environments consider using version managers like phpbrew to maintain consistent development environments.