Core Web Vitals on Ubuntu 24.04 for Hosting Sites

Why this Ubuntu 24.04 setup matters for hosting sites
If your pages feel quick in a browser but still miss Core Web Vitals, the usual culprits are server timing, cache behavior, or a sloppy backend handoff. On a fresh Ubuntu 24.04 VPS, you can tighten the request path and measure the effect instead of guessing.
This tutorial focuses on a practical hosting goal: lowering TTFB, avoiding unnecessary layout delay, and keeping the server steady under real traffic. Ubuntu 24.04 is a good fit because the tooling is current, AppArmor is enabled, and the default packages are predictable for support teams at Hostperl. If you are setting up a new deployment, a Hostperl VPS gives you a clean base for these changes without sharing resources with unrelated workloads.
You will also see how this work ties into broader site visibility. Hostperl’s guide on structured data for hosting SEO in 2026 covers the page-level signals that pair well with better performance, while How Hosting Sites Win AI Overviews in 2026 explains why fast, machine-readable pages are easier for answer engines to trust.
First login, OS check, and a safer admin account
On your local computer, connect to the server first. The address below is a documentation example; replace it with your server’s real public IP.
ssh root@203.0.113.10If your provider uses a non-root login by default, use that account with the same server IP instead. Keep this root session open until the new login is verified.
On the VPS as root, confirm the operating system and create a non-root admin user named deploy.
cat /etc/os-releaseThat shows the exact Ubuntu build, kernel, and codename. You should see Ubuntu 24.04 details before continuing.
adduser deploySet a strong password when prompted. Then add the user to the sudo group so you can manage the server safely without staying on root all the time.
usermod -aG sudo deployCreate SSH access for the new account. Replace the public key content with your own key from your workstation.
install -d -m 700 -o deploy -g deploy /home/deploy/.ssh
cat > /home/deploy/.ssh/authorized_keys <<'EOF'
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleReplaceWithYourPublicKeyComment
EOF
chown deploy:deploy /home/deploy/.ssh/authorized_keys
chmod 600 /home/deploy/.ssh/authorized_keysThat creates the SSH directory with strict permissions and places the key where OpenSSH expects it. Next, open a second terminal and test the new account before changing any login policy.
ssh deploy@203.0.113.10On the VPS as the non-root sudo user, confirm sudo works.
sudo -v
whoami
pwdYou should see deploy from whoami, and sudo -v should prompt for the account password only once. If that works, you have a safer base for the rest of the tutorial.
Update packages, time sync, and the tools you need
Fast pages depend on a stable server. On Ubuntu, start with a full package refresh and the utilities needed for Nginx, logging, and cache headers.
On the VPS as the non-root sudo user, update the system and install the required packages.
sudo apt update
sudo apt full-upgrade -y
sudo apt install -y nginx curl chrony ufwThis keeps the base OS current and installs Nginx, time sync, a firewall, and a client for checks. After the upgrade, verify the service set and the running kernel.
nginx -v
systemctl status chrony --no-pager
uname -rEnable time synchronization so log timestamps and cache expiry stay consistent across reboots.
sudo systemctl enable --now chronyIf you are rebuilding a site after a migration, Hostperl’s Colocation Handoff Checklist for New Ubuntu Servers is a useful companion because it covers the same early validation steps before the application layer goes live.
Firewall, SSH posture, and safe sequencing
Open the web ports before you tighten access rules. That avoids an easy lockout if you are reconnecting remotely.
On the VPS as root, allow SSH, HTTP, and HTTPS through UFW, then enable it.
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
ufw status verboseYou should see the three allowed rules and the firewall active. On Ubuntu 24.04, AppArmor remains in place, so Nginx’s default profile stays confined while you edit configuration.
Now harden SSH only after the alternate session works. Edit the SSH daemon file carefully.
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
nano /etc/ssh/sshd_configAdd or confirm these lines inside the file:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
KbdInteractiveAuthentication noSave and exit, then test the syntax before restarting SSH.
sshd -t
systemctl restart ssh
systemctl status ssh --no-pagerKeep the root session open until the deploy user has reconnected successfully. If the syntax check fails, restore the backup and retry.
Build an Nginx cache path that helps Core Web Vitals
For most hosting sites, the most useful server-side improvement is a fast cacheable front door. Nginx can serve compressed static assets quickly and hand dynamic requests to your app or origin without unnecessary delay.
On the VPS as the non-root sudo user, create a site directory and a simple test page so you can measure the server behavior first.
sudo mkdir -p /var/www/core-web-vitals
sudo chown -R www-data:www-data /var/www/core-web-vitals
cat > /var/www/core-web-vitals/index.html <<'EOF'
Core Web Vitals test page
This page helps verify server response, caching, and headers.
EOFNext, create a dedicated Nginx site definition with sensible cache headers for static assets and a short, clear server block.
sudo nano /etc/nginx/sites-available/core-web-vitalsUse this file content:
server {
listen 80;
listen [::]:80;
server_name example.com server.example.com;
root /var/www/core-web-vitals;
index index.html;
access_log /var/log/nginx/core-web-vitals.access.log;
error_log /var/log/nginx/core-web-vitals.error.log;
location / {
try_files $uri $uri/ =404;
}
location ~* \.(css|js|jpg|jpeg|png|gif|webp|svg|ico)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000, immutable";
access_log off;
}
}
Save and exit, then enable the site and disable the default one so the correct server block answers requests.
sudo ln -s /etc/nginx/sites-available/core-web-vitals /etc/nginx/sites-enabled/core-web-vitals
sudo rm -f /etc/nginx/sites-enabled/defaultTest the configuration before reload. Never skip this step on a remote server.
sudo nginx -t
sudo systemctl reload nginxAfter the reload, confirm that Nginx is listening and serving the page.
sudo ss -tulpn | grep nginx
curl -I http://127.0.0.1If you want to see how server-side tuning affects application timing, the patterns in Nginx Timeouts for Node.js Apps on AlmaLinux 9 show the same request-path logic from an application perspective.
Measure the site before and after changes
Core Web Vitals is not a command-line metric by itself, so you need a repeatable way to observe the server impact. Start by checking response headers and local latency, then move to browser-based lab testing.
On the VPS as the non-root sudo user, measure local response time and headers.
curl -o /dev/null -s -w 'HTTP %{http_code}\nTTFB %{time_starttransfer}\nTotal %{time_total}\n' http://127.0.0.1
curl -I http://127.0.0.1Successful output should show HTTP 200, a low TTFB on the local interface, and cache headers on static files once you add them. If TTFB is high on localhost, the bottleneck is in the server or app stack, not the network.
From your workstation, test the public IP and domain path after DNS is pointed at the server.
curl -o /dev/null -s -w 'HTTP %{http_code}\nTTFB %{time_starttransfer}\nTotal %{time_total}\n' http://203.0.113.10Replace 203.0.113.10 with your real public IP. You should see the same functional response, though the timing will be higher because of the network hop.
Log checks, diagnostics, and the most common failures
When a page misses performance goals, logs usually tell you which layer is slow. Start with Nginx logs and then check the service state.
On the VPS as the non-root sudo user, inspect the latest log entries.
sudo tail -n 50 /var/log/nginx/core-web-vitals.error.log
sudo tail -n 50 /var/log/nginx/core-web-vitals.access.log
sudo systemctl status nginx --no-pagerIf you see permission denied, the web root ownership or file permissions are wrong. Fix them with:
sudo chown -R www-data:www-data /var/www/core-web-vitals
sudo find /var/www/core-web-vitals -type d -exec chmod 755 {} \;
sudo find /var/www/core-web-vitals -type f -exec chmod 644 {} \;If you see address already in use, another service has port 80 or 443. Identify it before changing Nginx.
sudo ss -tulpn | grep ':80\|:443'If the site returns a 403, check the index file and the root path.
ls -l /var/www/core-web-vitals
sudo nginx -T | sed -n '1,220p'For a broader Linux maintenance path, Hostperl’s Linux Package Upgrades That Keep Servers Stable in 2026 complements this tutorial because performance work fails quickly on an unstable base system.
Rollback and recovery if the change hurts performance
Not every configuration wins. If the cache rules or site definition cause problems, revert in a controlled way rather than editing blindly.
On the VPS as root, disable the custom site, restore the default if needed, and reload safely.
rm -f /etc/nginx/sites-enabled/core-web-vitals
if [ -f /etc/nginx/sites-enabled/default.disabled ]; then mv /etc/nginx/sites-enabled/default.disabled /etc/nginx/sites-enabled/default; fi
nginx -t
systemctl reload nginxIf SSH changes caused trouble, use the backup copy you made earlier and test before restarting.
cp /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
sshd -t
systemctl restart sshThat gives you a fast way back to a known-good state without reinstalling the server.
Final verification from server and client
Finish with checks that prove the configuration survives a reboot and still responds correctly.
On the VPS as the non-root sudo user, confirm enabled services and reboot persistence.
systemctl is-enabled nginx
systemctl is-enabled chrony
systemctl is-enabled sshAll three should return enabled. Then verify the final page locally and over the network.
curl -I http://127.0.0.1On your local computer, run a real smoke test against the public site.
curl -I http://203.0.113.10Replace 203.0.113.10 with the actual server IP. A valid response with the expected title and headers confirms the site is reachable and the server is answering normally.
If your site is moving from another host, pairing this work with DNS TTL Changes for Safer Domain Migrations in 2026 reduces the risk of stale records during the cutover.
If you are tuning a live site for better Core Web Vitals, Hostperl VPS plans give you enough control to test Nginx, cache headers, and rollback steps without waiting on a generic shared environment. For larger properties or agency-managed sites, Hostperl VPS and dedicated server hosting both fit this kind of work well.
Our support team sees these issues during migrations and launch windows all the time, so the practical advice here is built for real production handoffs.
FAQ
Does better Core Web Vitals always mean a faster server?
No. A fast server helps, but layout shifts and render blocking can still come from front-end code, fonts, and third-party scripts.
Should I use Nginx cache headers for every file?
No. Static assets benefit most. Dynamic HTML usually needs shorter cache rules or application-level control.
What is the first metric I should check?
Check TTFB first. If it is high before the browser renders anything, fix the server path, cache, or backend before chasing client-side tweaks.
Can I do this on a busy production site?
Yes, but make one change at a time, test syntax before reload, and keep a rollback copy of each file you edit.
