Setting up PHP Ubuntu 26.04 is essential for developers who want to run modern web applications, CMS platforms, or dynamic websites on Linux servers. PHP continues to power major platforms like WordPress, Laravel, and Magento because of its flexibility and broad ecosystem.
Ubuntu 26.04 includes PHP 8.5 in its default repositories, making installation quick and straightforward. Whether you use Apache or Nginx, Ubuntu offers reliable tools for deploying PHP applications efficiently.
PHP remains one of the most trusted server-side scripting languages for web development. Combined with Ubuntu 26.04, it creates a stable environment suitable for production servers, cloud deployments, and development machines.
The latest PHP release introduces better performance, improved memory handling, and updated security enhancements. In addition, Ubuntu’s package management system makes maintaining PHP installations simple.
If your server uses Apache, installing PHP requires only a few commands. First, update the package index:
sudo apt update
Next, install PHP along with the Apache integration module:
sudo apt install php libapache2-mod-php
Once the installation completes, restart Apache to load the PHP module properly:
sudo systemctl restart apache2
Apache can now process PHP files directly through the integrated module.
Unlike Apache, Nginx does not process PHP files natively. Instead, it uses PHP-FPM (FastCGI Process Manager).
Install PHP-FPM using:
sudo apt updatesudo apt install php-fpm
After installation, verify the service status:
sudo systemctl status php8.5-fpm
Next, update your Nginx server block to forward PHP requests through the FastCGI socket. Restart Nginx afterward:
sudo systemctl restart nginx
This setup provides better performance and resource efficiency for high-traffic environments.
Most PHP applications require additional modules for database access, image processing, or API communication.
Install commonly used extensions with:
sudo apt install php-mysql php-curl php-gd php-mbstring php-xml php-zip
These packages add support for MySQL databases, image rendering, ZIP handling, and multibyte string processing.
To list all installed modules:
php -m
To confirm PHP works correctly, create a test file inside your web root:
echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php
Open the file in your browser:
http://your_server_ip/info.php
If everything is configured properly, you will see the PHP information page showing active modules and server details.
After testing, remove the file for security reasons:
sudo rm /var/www/html/info.php
Ubuntu also supports multiple PHP versions using third-party repositories. This is useful when hosting applications that depend on different PHP releases.
You can switch between installed versions with:
sudo update-alternatives --config php
This allows administrators to manage compatibility without reinstalling the operating system.
Deploying PHP Ubuntu 26.04 is a simple process whether you choose Apache or Nginx. Ubuntu’s package repositories provide fast access to PHP 8.5, essential extensions, and PHP-FPM for optimized performance.
With the right configuration, PHP on Ubuntu 26.04 delivers a reliable foundation for hosting websites, APIs, and enterprise-grade web applications securely and efficiently.