Table of Contents
PHP is a widely used server-side scripting language for websites, web applications, and backend services. Installing the latest PHP version on Ubuntu provides better performance, security updates, and compatibility with modern applications.
Many developers deploy PHP environments on Linux VPS hosting servers to run websites, APIs, and custom web applications with full server control.
Step 1: Connect to the Ubuntu Server
Access the server using SSH:
ssh root@your_server_ip
Step 2: Update System Packages
Refresh the package index:
apt update && apt upgrade -y
Keeping the system updated helps avoid dependency and repository issues during installation.
Step 3: Install Required Dependencies
Install software properties support:
apt install software-properties-common ca-certificates lsb-release apt-transport-https -y
Step 4: Add the PHP Repository
Add the Ondřej Surý PHP repository:
add-apt-repository ppa:ondrej/php -y
Update package lists again:
apt update
Step 5: Install PHP 8.5
Install PHP 8.5 with common extensions:
apt install php8.5 php8.5-cli php8.5-fpm php8.5-mysql php8.5-curl php8.5-xml php8.5-mbstring php8.5-zip php8.5-gd -y
These extensions are commonly required for websites, APIs, and CMS platforms.
Step 6: Verify the PHP Installation
Check the installed PHP version:
php -v
Example output:
PHP 8.5.x (cli)
This confirms that PHP 8.5 has been installed successfully.
Step 7: Check PHP-FPM Status
Verify that PHP-FPM is running:
systemctl status php8.5-fpm
Enable PHP-FPM at boot:
systemctl enable php8.5-fpm
Step 8: Test PHP from the Terminal
Create a simple PHP test:
php -r "echo 'PHP is working';"
The terminal should display:
PHP is working
If you plan to host websites with PHP, learning how to install nginx reverse proxy on Ubuntu can help complete the web server environment.
Step 9: Install Additional PHP Extensions
Search available PHP 8.5 extensions:
apt search php8.5-
Install extra modules if needed:
apt install php8.5-imagick php8.5-intl -y
PHP 8.5 on Ubuntu 26.04 provides a modern and optimized environment for hosting websites, APIs, and server-side applications on VPS infrastructure.
