Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

apt upgrade: Safely Update Ubuntu Packages

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.

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.

CommandChanges installed packagesMay remove packagesTypical use
apt updateNoNoRefresh index before any install or upgrade
apt upgradeYesNo (normally)Routine security and bugfix updates
apt full-upgradeYesYes, if neededRelease upgrades or complex dependency fixes
apt install packageYesRarelyTargeted 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.

Ubuntu Package Update Flowapt updateRefresh indexReview listCheck kernel, PHPBackupSnapshot or dumpapt upgradeInstall updatesReboot if neededNew kernel loadedReload servicesPHP-FPM, NginxVerify stackHTTP, cron, SSLNever skip the review and verify steps on productionapt upgrade safely update ubuntu packages end-to-end
Safe apt upgrade workflow: refresh index, review changes, backup, upgrade, reboot if required, reload services, verify.

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."

  1. Run apt update and review upgradable packages.
  2. Confirm backups and snapshot availability.
  3. Check disk space with df -h—upgrades need free space in /var.
  4. Verify SSH access and console fallback if the network stack updates.
  5. 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.

Stack Layers Touched by apt upgradeKernel + OpenSSL + systemd (reboot often required)Web server: Apache2 or Nginx packagesPHP 8.3 / 8.5 FPM + extensionsMySQL 9.7 / MariaDB 12.3 / PostgreSQL 18Redis 8.10, Certbot, UFW, fail2banVerify each layer after apt upgrade on Ubuntu
Ubuntu web servers stack layers commonly updated by apt upgrade—from kernel to application runtimes.

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:

ApproachBest forRiskEffort
Manual apt upgrade monthlySingle-app VPS, small teamsLow if runbook followed30–60 min per server
unattended-upgrades (security only)Multi-server fleets, complianceMedium—watch blacklistsSetup once, monitor mail
CI/CD image rebuildContainers, immutable infraLow at deploy boundaryHigher architecture cost
Managed hosting patchesNon-technical ownersVaries by providerMonthly 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.

Manual vs Automated Ubuntu UpdatesManual apt upgradeFull package reviewPlanned reboot windowApp smoke testsBest for Laravel stacksLower surprise riskunattended-upgradesSecurity pocket onlyNo auto-reboot defaultEmail on changeBest for patch velocityNeeds blacklist tuningMany teams combine both: automate security, manual quarterly full upgrade
Manual apt upgrade versus unattended-upgrades: trade-offs for Ubuntu production servers in 2026.

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.

Production apt upgrade Decision TreeKernel in list?YesSchedule rebootNotify stakeholdersNoReload servicesSkip rebootPHP packages?Reload PHP-FPMRun php -m checkSkip PHP reloadContinue verify
Decision tree for apt upgrade safely update ubuntu packages: kernel reboot vs service reload paths.

Key Takeaways

  • Always run apt update, then review apt list --upgradable and --dry-run before 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-required exists; 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

apt update refreshes the local package index from repositories without changing installed software. apt upgrade installs newer versions of packages already on the system while respecting dependencies. Run update first, then review, then upgrade.

Yes, with a runbook: apt update, review apt list --upgradable and apt upgrade --dry-run, snapshot or backup, upgrade during a maintenance window, reboot if the kernel changed, reload services, and smoke-test apps. Blind upgrades without review cause more outages than patching itself.

Reboot when kernel, microcode, or core libraries require it. Check /var/run/reboot-required and reboot-required.pkgs. PHP-FPM, Nginx, Apache, or Redis updates usually need only a service reload, not a full reboot.

Run apt update, apt list --upgradable, and apt upgrade --dry-run to flag kernel, OpenSSL, database, PHP, or web server changes. Check held packages with apt-mark showhold, confirm backups or a VPS snapshot, verify disk space with df -h, document the current kernel with uname -r, and schedule a low-traffic maintenance window with stakeholders notified.

After preparation, use screen or tmux so a dropped SSH session does not kill the process. The article recommends sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y to avoid config prompts blocking unattended servers. For interactive sessions, omit -y and answer config merge prompts deliberately, choosing keep current version unless you track vendor defaults.

Choose keep the local version currently installed unless you intentionally track vendor defaults. Custom PHP-FPM pools, OPcache settings, upload limits, Nginx client body size, and MySQL tuning live in those files. Blindly accepting the package maintainer version has broken uploads and portal features on real client servers before.

After sudo apt update, run apt list --upgradable to see pending versions. For a deeper preview, run sudo apt upgrade --dry-run and read output carefully. Flag anything touching the kernel, OpenSSL, MySQL 9.7, MariaDB 12.3, PostgreSQL 18 client libraries, PHP packages, or your web server before proceeding.

Held packages block upgrades silently until you notice stale security patches. List them with apt-mark showhold. If PHP or MySQL is held from a past emergency, document why before releasing. Unhold only when you accept the upgrade risk, for example sudo apt-mark unhold php8.3-fpm, then include that package in your next controlled upgrade window.

Confirm services with systemctl is-active and systemctl --failed. Smoke-test homepage SSL, login sessions, queue workers, cron paths pointing to current Deployer releases, and payment callbacks. Verify UFW and fail2ban still active. Review php8.3-fpm and Nginx error logs for extension mismatches or TLS issues after OpenSSL updates.

After non-kernel updates, reload affected daemons: sudo systemctl reload php8.3-fpm, apache2, and nginx. PHP-FPM reload picks up extension changes without dropping every connection. MySQL restart is heavier—do it during the maintenance window and confirm replication lag on replicas first. I reload PHP-FPM after every upgrade touching PHP packages to avoid stale OPcache confusion.

Install unattended-upgrades and configure /etc/apt/apt.conf.d/50unattended-upgrades to allow only the security pocket. Keep Automatic-Reboot false on web servers so kernel updates queue for a planned window. Blacklist packages needing manual validation such as php8.3-fpm, mysql-server-8.0, and nginx. Monitor notification mail and maintain a monthly manual review for blacklisted packages.

Blacklist runtime packages that need manual smoke-testing after updates: php8.3-fpm, mysql-server-8.0, and nginx are examples from the article. Adjust names to match dpkg -l output on your host. Blacklisting shifts responsibility to your monthly runbook but prevents surprise PHP extension or web server config changes during peak traffic hours.

apt upgrade installs newer versions of installed packages and normally does not remove software. apt full-upgrade, formerly dist-upgrade, may add or remove packages to resolve dependency conflicts. Use apt upgrade for routine security and bugfix maintenance. Reserve full-upgrade for planned release upgrades or complex dependency fixes documented in your runbook, not weekly production patching.

Upgrading PHP without verifying extensions with php -m and php -v breaks Imagick, Redis, intl, or mysql modules. Accepting new default config files overwrites Nginx body size, PHP memory_limit, and MySQL buffer settings. Ignoring reboot-required leaves patched userspace on an old kernel. Upgrading without disk space in /var leaves half-configured packages. Skipping ImageMagick or similar library updates can break document previews until policy files are adjusted.

Apply security patches within days via manual monthly upgrades or unattended-upgrades for the security pocket. Do full stack reviews quarterly to catch held packages and stale kernels. A VPS snapshot before patching costs roughly Rs 200–500 (~USD 1.50–3.75). Manual upgrades take 30–60 minutes per server. Managed hosting patch services often start around Rs 3,000+ (~USD 22+) monthly if you lack dedicated ops staff.

Share this article

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.

Quick Contact Options
Choose how you want to connect me: