
September 11, 2026
12 min read
By Kokil Thapa | Last reviewed: September 2026
Running apt upgrade: Safely Update Ubuntu Packages on a live web server sounds trivial until a PHP-FPM restart breaks checkout or a kernel update leaves MySQL unreachable after reboot. On production Ubuntu boxes that host PHP 8.3 or 8.5 applications, Laravel 12 sites, and WordPress 7.1 stores, package updates are routine maintenance—not a fire-and-forget command. This guide walks through the exact workflow I use before touching packages on client servers in Kathmandu and on remote VPS hosts worldwide.
apt update, review held packages and pending kernel changes, take a snapshot or backup, execute apt upgrade during a maintenance window, reboot if the kernel changed, then verify web services, cron jobs, and SSL before reopening traffic.What Is the Difference Between apt update and apt upgrade on Ubuntu?
Before you touch production packages, you need a clear mental model. These two commands do different jobs, and mixing them up causes confusion during incident response.
apt update refreshes your local package index from configured repositories. It downloads metadata about available versions. Nothing on disk changes yet. Think of it as reading the menu.
apt upgrade installs newer versions of packages already installed on the system. It respects dependency rules and will not remove packages unless required. It is the safer default for routine maintenance.
apt full-upgrade (formerly dist-upgrade) may remove or install packages to resolve dependency conflicts. Use it deliberately, not as a weekly habit on production.
| Command | Changes installed packages | May remove packages | Typical use |
|---|---|---|---|
apt update | No | No | Refresh index before any install or upgrade |
apt upgrade | Yes | No (normally) | Routine security and bugfix updates |
apt full-upgrade | Yes | Yes, if needed | Release upgrades or complex dependency fixes |
apt install package | Yes | Rarely | Targeted new software (e.g., Redis 8.10) |
For day-to-day server work, pair apt update with a controlled apt upgrade. Save full-upgrade for planned migration windows documented in your runbook.
How Do You Prepare a Ubuntu Server Before Running apt upgrade?
Preparation separates a boring Tuesday patch from a three-hour outage. On servers running Deployer 7 releases for Laravel apps, I treat every upgrade like a mini deployment.
Confirm what will change
Run these commands as a user with sudo access:
sudo apt update
apt list --upgradable
sudo apt upgrade --dry-run
Read the output carefully. Flag anything touching the kernel, OpenSSL, MySQL 9.7, MariaDB 12.3, PostgreSQL 18 client libraries, PHP packages, or your web server. A kernel update almost always needs a reboot. Plan that reboot before you start.
Check held packages
Held packages block upgrades silently until you notice stale security patches. List them:
apt-mark showhold
If PHP or MySQL is held from a past emergency, document why before releasing the hold. Unhold only when you accept the upgrade risk:
sudo apt-mark unhold php8.3-fpm
Take a recoverable backup
At minimum, snapshot the VPS or run your normal backup routine. For database-backed apps, confirm last night's dump succeeded. I follow the same backup mindset described in our Ubuntu server backup strategies article—filesystem snapshot plus verified SQL export.
On AWS or similar hosts, create an AMI or volume snapshot. Cost is usually Rs 200–500 per snapshot (~USD 1.50–3.75). That is cheap insurance against a broken libc upgrade.
Schedule a maintenance window
Patch during low traffic. For Nepal eCommerce sites, late night or early morning often works. Put the site in maintenance mode at the application layer if you run Laravel or WordPress. Notify stakeholders with a short window: "Server maintenance, 02:00–02:30 NPT."
- Run
apt updateand review upgradable packages. - Confirm backups and snapshot availability.
- Check disk space with
df -h—upgrades need free space in/var. - Verify SSH access and console fallback if the network stack updates.
- Document the starting kernel:
uname -r.
How Do You Run apt upgrade Safely on a Production Ubuntu Web Server?
With preparation done, execute the upgrade in a controlled session. Use screen or tmux so a dropped SSH connection does not kill the process mid-install.
Standard safe upgrade command
sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y
The noninteractive flag prevents apt from blocking on config file prompts. That matters on unattended servers. For interactive sessions where you want control over config merges, omit -y and answer prompts deliberately.
When apt asks about replacing /etc/php/8.3/fpm/php.ini or similar, choose "keep current version" unless you intentionally track vendor defaults. Custom PHP-FPM pools, OPcache settings, and upload limits live in those files. Blindly accepting new defaults has broken uploads on client portals before.
Handle kernel and microcode updates
After upgrade completes, check whether a reboot is pending:
[ -f /var/run/reboot-required ] && cat /var/run/reboot-required.pkgs
If the kernel or linux-image packages updated, schedule sudo reboot. Old kernels remain in GRUB as fallback—a useful safety net if the new kernel fails to boot.
Reload services without unnecessary downtime
Not every upgrade needs a full reboot. After non-kernel updates, reload affected daemons:
sudo systemctl reload php8.3-fpm
sudo systemctl reload apache2
sudo systemctl reload nginx
sudo systemctl restart mysql
PHP-FPM reload picks up extension changes without dropping every active connection. Apache and Nginx reload apply config if packages touched default templates. MySQL restart is heavier—do it during the maintenance window and confirm replication lag first on replicas.
On sister sites sharing a Deployer pipeline—similar to Notary Kathmandu and related legal-tech portals—I reload PHP-FPM after every upgrade that touches PHP packages. Stale OPcache bytecode has caused "works on old release" confusion after symlink swaps.
What Post-Upgrade Checks Prevent Silent Production Failures?
The upgrade command exiting zero means packages installed. It does not mean your site works. Post-checks catch the failures I see most often on maintained servers.
Service health
systemctl is-active nginx php8.3-fpm mysql redis-server
systemctl --failed
Any failed unit needs immediate attention before you disable maintenance mode.
Application smoke tests
Hit critical paths manually or with a short script:
- Homepage returns HTTP 200 with correct SSL.
- Login and session cookies work (OpenSSL updates can affect TLS).
- Queue worker processes restart—check Supervisor or systemd units.
- Cron still points to the correct release path after Deployer deploys.
- Payment callback URLs respond (eSewa, Khalti, Stripe test modes).
Stale cron paths after symlink changes are a recurring issue. After upgrades, confirm crontab -l references current not an old release folder. Our Ubuntu cron jobs guide covers path patterns that survive deploys.
Security tooling still active
Confirm UFW rules and fail2ban jails survived the upgrade. Package updates occasionally reset config templates. Run sudo ufw status and sudo fail2ban-client status.
Log review
sudo journalctl -u php8.3-fpm --since "30 min ago" -p err
sudo tail -n 50 /var/log/nginx/error.log
PHP extension mismatches show up quickly in FPM logs after upgrades. If php8.3-mysql updated but FPM was not reloaded, you may see connection errors until reload.
How Do You Automate Ubuntu Security Updates Without Breaking Apps?
Manual monthly upgrades work for many small business servers. High-traffic or compliance-sensitive systems often need automated security patches with guardrails.
Ubuntu ships unattended-upgrades for this purpose. It installs security updates from the official Ubuntu security pocket without full interactive review. Official documentation lives at the Ubuntu Server unattended-upgrades guide.
Enable unattended security updates
sudo apt install unattended-upgrades apt-listchanges
sudo dpkg-reconfigure -plow unattended-upgrades
Edit /etc/apt/apt.conf.d/50unattended-upgrades to control origins:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
};
Unattended-Upgrade::Automatic-Reboot "false";
Unattended-Upgrade::Mail "admin@example.com";
I keep automatic reboot disabled on web servers. Kernel security updates queue until a planned window. Forcing midnight reboots has interrupted long-running queue jobs on Laravel booking systems.
What to exclude from automation
Consider blacklisting packages that need manual validation:
Unattended-Upgrade::Package-Blacklist {
"php8.3-fpm";
"mysql-server-8.0";
"nginx";
};
Adjust names to match dpkg -l output on your host. Blacklisting shifts responsibility back to your monthly runbook—but prevents surprise PHP extension changes during peak hours.
Compare automated vs manual approaches:
| Approach | Best for | Risk | Effort |
|---|---|---|---|
| Manual apt upgrade monthly | Single-app VPS, small teams | Low if runbook followed | 30–60 min per server |
| unattended-upgrades (security only) | Multi-server fleets, compliance | Medium—watch blacklists | Setup once, monitor mail |
| CI/CD image rebuild | Containers, immutable infra | Low at deploy boundary | Higher architecture cost |
| Managed hosting patches | Non-technical owners | Varies by provider | Monthly fee Rs 3,000+ (~USD 22+) |
For teams without dedicated ops staff, pairing automation with a support and maintenance retainer often costs less than one emergency outage.
What Common apt upgrade Mistakes Break Laravel and WordPress Sites?
Experience on production stacks surfaces the same failure patterns. Most are preventable with five minutes of reading before you press Enter.
Upgrading PHP without testing extensions
When php8.3-* packages update, extension ABIs can shift. Imagick, Redis, and intl extensions break if versions drift. After upgrade:
php -m | grep -E 'redis|imagick|intl|mysql'
php -v
If you run multiple PHP versions side by side—as covered in our PHP on Ubuntu installation guide—upgrade each SAPI deliberately. Do not assume 8.3 and 8.5 pools updated together.
Accepting new default config files
Debian packaging uses ucf to merge configs. Choosing "install package maintainer's version" overwrites local tuning. Nginx client body size, PHP memory_limit, and MySQL innodb_buffer_pool_size are common casualties. Always diff before accepting:
sudo apt-get install --reinstall -d nginx
Ignoring reboot-required on kernel updates
Running an old kernel with patched userspace creates subtle bugs. Meltdown-style fixes and certain OpenSSL behaviours expect the new kernel loaded. Schedule reboots; do not defer for months.
Upgrading without disk space
Apt downloads .deb files to /var/cache/apt/archives/. Full disks mid-upgrade leave packages half-configured. Clean old kernels after successful reboot:
sudo apt autoremove --purge
sudo apt clean
Skipping security context on first upgrade after provisioning
Fresh Ubuntu 24.04 servers should run baseline hardening before first production traffic. Apply security hardening and web server hardening first. Then patch on a known-good baseline.
On a legal-tech portal with document uploads, I once traced broken PDF previews to an ImageMagick policy update pulled in via a routine upgrade. The fix was a one-line policy.xml change—but only after checking apt list --upgradable history would have flagged ImageMagick earlier.
Key Takeaways
- Always run
apt update, then reviewapt list --upgradableand--dry-runbefore upgrading production. - Snapshot or backup databases and filesystems before any apt upgrade on a live web server.
- Keep local config files during package prompts unless you intentionally track vendor defaults.
- Reboot when
/var/run/reboot-requiredexists; reload PHP-FPM and web servers after runtime package changes. - Automate security patches with
unattended-upgrades, but blacklist PHP, MySQL, and Nginx if you need manual validation. - Verify HTTP endpoints, cron paths, queues, and firewall rules after every upgrade—not just when something breaks.
People Also Ask
Is apt upgrade safe to run on a production server?
Yes, when you follow a runbook: refresh the index, review pending packages, backup, upgrade during a maintenance window, reboot if the kernel changed, and smoke-test applications. Blind weekly upgrades without review cause more outages than patching itself.
Do I need to reboot after apt upgrade on Ubuntu?
Reboot when kernel, microcode, or core system libraries require it. Check /var/run/reboot-required. PHP, Nginx, or Redis updates usually need only a service reload—not a full reboot.
What is the difference between apt upgrade and apt dist-upgrade?
apt upgrade installs newer versions of installed packages without removing software. apt dist-upgrade (now full-upgrade) may add or remove packages to resolve dependencies. Use full-upgrade for release upgrades, not routine patching.
How often should Ubuntu servers be updated?
Security patches should land within days—manual monthly or automated via unattended-upgrades. Full stack reviews every quarter catch held packages and stale kernels. Align timing with low-traffic windows for your audience.
Next Steps for Reliable Ubuntu Server Maintenance
Treating apt upgrade: Safely Update Ubuntu Packages as a documented procedure—not a casual SSH habit—keeps Laravel, WordPress, and custom PHP stacks stable across years of operation. The commands are simple. The discipline around backups, config merges, reboots, and verification is what separates maintained servers from surprise downtime.
If you manage multiple client sites on shared EC2 infrastructure—similar to the Deployer 7 workflow I use on Adventure Third Pole Trek and related properties—write one runbook and reuse it. Log each upgrade date, packages changed, and reboot status. Future you will thank present you during the next OpenSSL advisory.
For deeper context, read our Ubuntu security updates guide, server setup guide, and performance optimization checklist. Use the password generator when rotating service credentials after major OpenSSH updates. Need hands-on help with patching, hardening, or Linux system administration for Nepal-hosted workloads? Contact us to schedule a maintenance review.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

