How to Install PHP 8.3 on Ubuntu 22.04

Up-to-date guide on installing PHP 8.3 on Ubuntu 22.04, including Apache and Nginx (PHP-FPM) integration, extensions, and running multiple PHP versions side by side.
已发布:
Aleksandar Stajić
Updated: 2026年1月9日 00:16
How to Install PHP 8.3 on Ubuntu 22.04

配图

How to Install PHP 8.3 on Ubuntu 22.04

This guide shows how to properly install and run PHP 8.3 on Ubuntu 22.04 in a modern server environment. It covers system preparation, repository setup, Apache and Nginx integration, PHP extensions, version switching and common best practices.

Step 1: Update the Operating System

Before installing PHP, make sure your system is fully up to date. This prevents dependency conflicts and ensures security patches are applied.

sudo apt update && sudo apt upgrade -y

Step 2: Add the PHP Repository

Ubuntu 22.04 does not ship PHP 8.3 by default. The widely used and trusted Ondřej Surý repository provides up-to-date PHP versions and extensions.

sudo apt install -y ca-certificates apt-transport-https software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Step 3: Install PHP 8.3 (CLI)

Install the PHP 8.3 core package. This provides the PHP CLI and the base runtime required by web servers and background tasks.

sudo apt install -y php8.3

Verify the installed PHP version:

php -v

Step 4: Install PHP 8.3 for Apache

If you are using Apache, install PHP as an Apache module. This setup is common for traditional LAMP stacks.

sudo apt install -y libapache2-mod-php8.3

Restart Apache to activate the PHP module:

sudo systemctl restart apache2

Step 5: Install PHP 8.3 FPM for Nginx

For Nginx-based setups, PHP must run via PHP-FPM. This approach offers better performance and scalability.

sudo apt install -y php8.3-fpm

Check that the PHP-FPM service is running:

systemctl status php8.3-fpm

Step 6: Install Common PHP Extensions

Most applications require additional PHP extensions. Install only what your project actually needs to keep the system lean and secure.

sudo apt install -y php8.3-mysql php8.3-curl php8.3-xml php8.3-mbstring php8.3-zip php8.3-intl php8.3-gd php8.3-opcache

List all loaded PHP modules:

php -m

Step 7: Run Multiple PHP Versions Side-by-Side

Ubuntu allows multiple PHP versions to coexist. This is useful when maintaining legacy applications while deploying new projects on PHP 8.3.

sudo update-alternatives --config php

You can also set a specific PHP version directly:

sudo update-alternatives --set php /usr/bin/php8.3

Step 8: Recommended Post-Installation Checks

After installation, it is recommended to verify PHP configuration files, confirm the correct PHP-FPM socket or port for your web server, and ensure OPcache is enabled for production environments.

For production systems, always review php.ini settings such as memory limits, execution time, upload size and error handling according to your application requirements.

Conclusion

Installing PHP 8.3 on Ubuntu 22.04 provides a modern, stable and performant foundation for web applications. Whether you run Apache or Nginx, a clean PHP setup with the right extensions and version management ensures long-term maintainability and smooth operation.

Related Articles

tensorflow

tensorflow

Remove Duplicate APT Package Sources: Expert Guide for Ubuntu and Debian

Remove Duplicate APT Package Sources: Expert Guide for Ubuntu and Debian

A detailed guide for identifying and removing redundant or duplicate APT package sources in Debian and Ubuntu systems to ensure stability and performance.

企业级多租户架构,适用于国际平台

企业级多租户架构,适用于国际平台

Loving Rocks 是一款企业级婚礼平台,采用真正的多租户架构设计,实现租户间数据库隔离,并内置国际化支持,以确保全球可扩展性、安全性及长期运营稳定性。

Fedora 43上的ComfyUI:双虚拟环境 + 一键启动(2026年3月)

Fedora 43上的ComfyUI:双虚拟环境 + 一键启动(2026年3月)

目标:保留两个Python虚拟环境(例如3.12和3.14)以确保兼容性,但通过一个简洁、轻量的配置自动启动ComfyUI。

linux-server-webserver-git-rechteverwaltung

force-install-package-in-virtualenv

how-to-make-sql-modeno_engine_substitution-permanent-in-mysql-my-cnf

HEIC转JPG转换:为何值得考虑及其工作原理

HEIC转JPG转换:为何值得考虑及其工作原理

HEIC格式提供了现代化的图像压缩和高画质,但JPG仍是兼容性最广的格式。本指南将说明在Linux环境下,何时以及如何利用工具与自动化流程将HEIC转换为JPG格式。

PostgreSQL 14 Ubuntu Server 23.04

PostgreSQL 14 Ubuntu Server 23.04

Using Cygwin’s bash Babun terminal in a JetBrains IDE

Using Cygwin’s bash Babun terminal in a JetBrains IDE

掌握命令行:Find命令全面指南

释放Linux find命令的全部潜能。本指南涵盖语法、扩展示例及技术细节,助您实现高效文件管理。

apache-ubuntu-17-10-install-certbot-lets-encrypt