Back to tutorials
Tutorial

Install PHP 8.3 on Ubuntu With Nginx and PHP-FPM

Install PHP 8.3 Ubuntu with Nginx + PHP-FPM, add a second PHP version, switch pools, and verify sockets and permissions.

By Anurag Singh
Updated on Dec 02, 2026
Category: Tutorial
Share article
Install PHP 8.3 on Ubuntu With Nginx and PHP-FPM

Adding a new PHP version on a live VPS usually fails for boring reasons. It’s rarely because PHP “won’t install.” Problems show up after the install. Nginx still targets the old FPM socket, the pool runs under the wrong user, or a small permissions mismatch turns every request into a 502.

This walkthrough shows you how to install PHP 8.3 Ubuntu alongside an existing PHP version. You’ll connect it to Nginx cleanly. Then you’ll verify sockets and permissions end-to-end.

This assumes Ubuntu Server with Nginx already installed and at least one site running (22.04/24.04 LTS are both common in 2026). If you’re starting from a clean box, a HostMyCode VPS gives you the access you need for multiple PHP-FPM pools, per-site users, and predictable performance under load.

What you’ll build (and what you should have ready)

  • PHP 8.3 installed from a maintained apt repository
  • A dedicated PHP-FPM pool for one site (separate from the default pool)
  • Nginx configured to talk to the correct PHP 8.3 socket
  • A verification checklist: PHP version, socket ownership, pool user, and Nginx upstream

Prereqs

  • Ubuntu server with sudo access
  • Nginx installed (we’ll include verification commands)
  • A domain already pointed to your server IP (optional but recommended)

Step 1: Confirm your current PHP/Nginx baseline

Take inventory before you touch anything. You want to know what’s installed, what’s running, and what Nginx is actually using.

sudo nginx -v
nginx -t

php -v || true
sudo systemctl status nginx --no-pager

If php -v shows PHP 8.1 or 8.2, that’s normal. It usually reflects the CLI binary.

Your website PHP version can be different. Nginx talks to PHP-FPM, not the CLI.

Now list existing FPM services:

systemctl list-units --type=service | grep -E 'php[0-9.]+-fpm' || true

You’ll typically see php8.1-fpm or php8.2-fpm. The goal is to add php8.3-fpm without disturbing what’s already serving production traffic.

Step 2: Add the apt repository for PHP 8.3

Ubuntu’s default repos don’t always ship the latest PHP minor across every supported LTS release. The usual approach is to use a maintained repository that builds multiple PHP versions.

On Ubuntu, Ondřej Surý’s PHP PPA is the common choice. Add it like this:

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

Verify:

apt-cache policy php8.3-fpm | sed -n '1,20p'

You should see a candidate version listed. If you don’t, the PPA wasn’t added correctly.

Another common cause is network reachability. DNS issues or outbound firewall rules can block apt.

Step 3: Install PHP 8.3, PHP-FPM, and common extensions

Install PHP 8.3 FPM and a practical set of extensions most apps expect. Trim or expand the list based on what your application actually uses.

sudo apt install -y \
  php8.3-fpm php8.3-cli php8.3-common \
  php8.3-mysql php8.3-pgsql \
  php8.3-xml php8.3-curl php8.3-gd php8.3-mbstring \
  php8.3-zip php8.3-bcmath php8.3-intl php8.3-soap \
  php8.3-redis \
  unzip

Verify FPM is running:

sudo systemctl enable --now php8.3-fpm
sudo systemctl status php8.3-fpm --no-pager

Find the default PHP 8.3 FPM socket:

ls -la /run/php/

You should see something like /run/php/php8.3-fpm.sock.

Step 4: Create a dedicated pool for your site (recommended)

You can run everything through the default www pool. On a multi-site VPS, that gets messy fast.

A per-site pool isolates permissions, makes logs easier to read, and reduces the blast radius of a compromised app.

First, create a dedicated Linux user for the site. Replace example with your site name.

sudo adduser --disabled-password --gecos "" example

Create a document root and set ownership:

sudo mkdir -p /var/www/example/public
sudo chown -R example:example /var/www/example

Now create a new PHP-FPM pool config:

sudo cp /etc/php/8.3/fpm/pool.d/www.conf /etc/php/8.3/fpm/pool.d/example.conf
sudo nano /etc/php/8.3/fpm/pool.d/example.conf

Edit /etc/php/8.3/fpm/pool.d/example.conf and change only what’s shown here. Leave everything else as-is.

[example]
user = example
group = example

listen = /run/php/php8.3-example.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

pm = dynamic
pm.max_children = 20
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6

; Helpful visibility for debugging (disable or restrict in production if you prefer)
php_admin_value[error_log] = /var/log/php8.3-fpm-example-error.log
php_admin_flag[log_errors] = on

Why those socket permissions? On Ubuntu, Nginx usually runs as www-data. If the socket is owned by www-data and the mode is 0660, you avoid “Permission denied” 502s.

This also keeps the socket tighter than 0666, which would open it up to everyone.

Test the pool configuration and reload:

sudo php-fpm8.3 -t
sudo systemctl reload php8.3-fpm

Verify the socket exists:

sudo ls -la /run/php/ | grep php8.3-example.sock

Step 5: Point Nginx at the PHP 8.3 pool socket

Create an Nginx server block (or update your existing one) so it uses the new pool socket. This is the one line most people miss during an upgrade.

sudo nano /etc/nginx/sites-available/example.conf

Paste and adjust:

server {
    listen 80;
    server_name example.com www.example.com;

    root /var/www/example/public;
    index index.php index.html;

    access_log /var/log/nginx/example.access.log;
    error_log  /var/log/nginx/example.error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-example.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Enable the site and test Nginx:

sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/example.conf
sudo nginx -t
sudo systemctl reload nginx

Common mistake: leaving fastcgi_pass pointed at an old socket (or a different version’s TCP port). That can silently serve the wrong PHP version.

If the upstream doesn’t exist, you’ll get a 502.

Step 6: Verify PHP 8.3 is actually serving web requests

Don’t trust the CLI version here. Confirm the site is hitting your PHP 8.3 pool.

Create a small version file:

sudo -u example tee /var/www/example/public/phpinfo.php >/dev/null <<'PHP'
<?php
phpinfo();
PHP

Request it locally:

curl -sS http://127.0.0.1/phpinfo.php | grep -i -m1 'PHP Version'

You should see PHP 8.3.x. If you don’t:

  • Confirm fastcgi_pass targets /run/php/php8.3-example.sock.
  • Check the socket exists and that Nginx can connect to it.
  • Verify the right server block matched your request (server_name and default_server conflicts can fool you).

Delete the file right after testing. Exposing phpinfo() is an avoidable security risk.

sudo rm -f /var/www/example/public/phpinfo.php

Step 7: Switch an existing site from old PHP-FPM to PHP 8.3 safely

If you already have a site running on an older FPM socket, make a small edit with an easy rollback. Keep the change to one line.

  1. Write down the current upstream in the site config: the existing fastcgi_pass value.
  2. Change one line to the new socket (either /run/php/php8.3-fpm.sock or your per-site socket).
  3. Reload (don’t restart) Nginx to avoid dropping connections.
  4. Watch logs for a few minutes while you hit key pages and login flows.

Edit the site file:

sudo nano /etc/nginx/sites-available/example.conf

Then test and reload:

sudo nginx -t
sudo systemctl reload nginx

Quick rollback: if you get 502s, revert fastcgi_pass to the old socket and reload Nginx again. Then debug without the clock ticking.

Step 8: Fix the two most common 502 causes (socket + permissions)

After a PHP switch, 502s usually come down to one of two things. Either the socket isn’t there, or Nginx can’t access it.

Check 1: Does the socket exist?

sudo ls -la /run/php/

If Nginx references /run/php/php8.3-example.sock but it’s missing, the pool didn’t load. Re-test and restart:

sudo php-fpm8.3 -t
sudo systemctl restart php8.3-fpm
sudo systemctl status php8.3-fpm --no-pager

Check 2: Can Nginx read the socket?

ps -u www-data -o pid,cmd | head
sudo stat /run/php/php8.3-example.sock

Match what you see to your pool config. With the setup in this tutorial, the Nginx user www-data owns the socket and the mode is 0660.

Also check your site files: the pool user (for example, example) must be able to read the PHP code. It must also be able to write to any app directories that need it (uploads, cache, sessions).

A quick read check:

sudo -u example test -r /var/www/example/public/index.php && echo OK || echo FAIL

Step 9: Tune PHP 8.3-FPM for real VPS workloads

The defaults are conservative, which is fine—until they aren’t. Too many children can push a small VPS into swapping.

Too few children can create queues, slow requests, and timeouts.

Open your pool config and tune based on available RAM:

sudo nano /etc/php/8.3/fpm/pool.d/example.conf

Practical starting points:

  • 1 GB RAM VPS: pm.max_children 6–12 (depending on app), keep it modest.
  • 2–4 GB RAM VPS: pm.max_children 15–35 for typical CMS/app workloads.

After changes:

sudo php-fpm8.3 -t
sudo systemctl reload php8.3-fpm

Verify pool activity:

sudo ss -xl | grep php8.3-example.sock || true
sudo tail -n 50 /var/log/nginx/example.error.log

If you’re chasing timeouts rather than 502s, add application-level logging and basic server monitoring. HostMyCode’s guide on self-hosting Netdata for server metrics pairs well with FPM tuning because you can spot memory pressure and CPU saturation quickly.

Step 10: Set the default CLI PHP version (optional)

This won’t change what Nginx serves. It does matter for Composer, cron jobs, deploy hooks, and maintenance scripts.

Ubuntu controls the default php binary with update-alternatives.

sudo update-alternatives --config php

Select the PHP 8.3 path, then verify:

php -v

Common mistake: switching CLI PHP and assuming the website followed along. Your web version depends on the running FPM service and the Nginx fastcgi_pass target.

Step 11: Add TLS (HTTPS) after the switch

Once the version change is stable, confirm HTTPS is still correct. The exact steps depend on how you manage certificates (Certbot, Caddy, a control panel).

If you use Nginx + Certbot, keep server blocks tidy. Re-run config tests after any TLS edits.

If you’d rather let a reverse proxy handle ACME and renewals, HostMyCode’s guide on Traefik with Docker Compose for HTTPS is a solid reference. Even without Docker, it lays out the moving parts and the failure modes.

Step 12: Deployment and change safety notes (what operators forget)

  • Restart order matters: change pool config → php-fpm8.3 -t → reload FPM → nginx -t → reload Nginx.
  • Don’t run all sites as www-data: per-site users + per-site pools reduce cross-site risk.
  • Keep logs per site: separate Nginx and PHP-FPM logs make 502 root cause obvious.
  • Plan for rollback: one-line change (socket) should be reversible in under a minute.

If SSH on your VPS still allows password login, fix that before you expose anything else. Follow Set Up SSH Keys And Disable Password Login On VPS and close off the easiest entry point.

Summary checklist (copy/paste for your change ticket)

  • Installed: php8.3-fpm + required extensions
  • Pool created: /etc/php/8.3/fpm/pool.d/example.conf
  • Socket present: /run/php/php8.3-example.sock
  • Nginx points to correct socket: fastcgi_pass unix:/run/php/php8.3-example.sock;
  • Permissions OK: socket readable by www-data; code readable by pool user
  • Verified via curl: web request returns PHP 8.3 version
  • Removed phpinfo: no leftover debug endpoints

If you run multiple PHP sites—or you just want predictable behavior during traffic spikes—a VPS is the right place to pin versions and use per-site PHP-FPM pools. Start with a HostMyCode VPS, or offload patching and service monitoring to managed VPS hosting so PHP upgrades don’t turn into late-night incidents.

FAQ: Install PHP 8.3 on Ubuntu with Nginx

Will installing PHP 8.3 break my existing PHP site?

Not by itself. Your site will keep using whatever PHP-FPM socket Nginx is configured to use. Problems start when you point fastcgi_pass at a socket that doesn’t exist or that Nginx can’t read.

Should I use the default php8.3-fpm.sock or a per-site socket?

Use a per-site pool and socket if you host more than one site, need different limits, or want tighter permissions. For a single-site VPS, the default socket is usually fine.

How do I confirm which PHP-FPM pool is serving requests?

Find fastcgi_pass in your Nginx config and match it to the sockets listed under /run/php/. Then confirm with a temporary PHP script and curl, and remove the script immediately afterward.

Why do I get 502 Bad Gateway right after switching sockets?

Either the socket path is wrong/missing, or Nginx can’t access it. Run php-fpm8.3 -t, confirm the socket exists, then verify socket owner/group/mode allow the Nginx user to connect.

Do I need to change update-alternatives for Nginx?

No. update-alternatives only changes the CLI php binary. Nginx uses PHP-FPM, which is controlled by your fastcgi_pass setting and the running FPM service.

Install PHP 8.3 on Ubuntu With Nginx and PHP-FPM | HostMyCode