Upgrading Apache HTTP Server on Ubuntu maintains security, performance, and compatibility with current web technologies. Apache receives frequent updates that patch vulnerabilities, improve efficiency, and introduce features. The Personal Package Archive (PPA) maintained by long-time Debian and Ubuntu contributor Ondřej Surý tracks upstream releases faster than Ubuntu’s default repositories so you can deploy current builds without waiting for the distro.
This guide covers upgrading Apache on Ubuntu using Ondřej Surý’s PPA, including repository import, version verification, and rollback procedures if needed. You’ll learn how to safely upgrade Apache while maintaining the option to restore the default Ubuntu version.
Check Your Current Apache Version
Before modifying repositories, check which Apache release is currently installed. Knowing the starting point lets you confirm that the PPA actually delivers a newer build and provides a baseline if you need to roll back.
Use the following commands to display the installed version and the package source Ubuntu will use by default:
apache2 -v
The output shows the currently installed Apache version and build date:
Server version: Apache/2.4.52 (Ubuntu) Server built: 2024-10-15T14:32:18
Check the package source Ubuntu will use by default:
The apt-cache utility is part of APT (Advanced Package Tool, Ubuntu’s package manager similar to combining Windows Update with the Microsoft Store) and reports which repositories supply each package so you know whether the PPA actually adds a newer build.
apt-cache policy apache2
This displays the installed version and available versions from configured repositories:
apache2:
Installed: 2.4.52-1ubuntu4.12
Candidate: 2.4.52-1ubuntu4.12
Version table:
*** 2.4.52-1ubuntu4.12 500
500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
100 /var/lib/dpkg/status
If Apache is not installed yet, these commands will show “not found,” which is fine because you can proceed to the installation section after importing the PPA.
Update System Packages Before Upgrading
Before upgrading Apache, update your system packages to avoid conflicts. This ensures package compatibility and reduces potential issues during the Apache upgrade process.
Open a terminal (press Ctrl+Alt+T) and run the following command to refresh APT’s package index:
sudo apt update
Next, upgrade any outdated packages on your system for improved performance and security:
sudo apt upgrade
Import Apache Launchpad PPA
To access newer Apache versions, add Ondřej Surý’s repository. Surý is a long-time Debian and Ubuntu maintainer who follows Apache’s upstream releases closely, so his Launchpad PPA delivers current builds long before Ubuntu’s default channels. First, ensure the repository helper tools are available:
sudo apt install ca-certificates dirmngr gnupg software-properties-common
Next, import the repository using the following command:
sudo add-apt-repository ppa:ondrej/apache2 -y
The Ondřej Surý PPA tracks upstream Apache releases for current Ubuntu LTS versions. Back up
/etc/apache2before upgrading, especially if you rely on third-party modules or custom MPM settings.
Upgrade Apache to Latest Version
After adding the PPA, update your repository listings to reflect the new source:
sudo apt update
Now install Apache or upgrade your existing installation. Run the installation command even if Apache is already installed to ensure you receive the latest version and all necessary dependency updates:
To install the latest Apache version, use the following command:
sudo apt install apache2
After installation, verify the configuration and restart Apache so the new binaries and modules load cleanly:
sudo apachectl configtest
A successful configuration test displays:
Syntax OK
If the syntax check passes, restart Apache to load the new version:
sudo systemctl restart apache2
Check the service status and review recent logs to ensure Apache started without module or virtual host errors:
sudo systemctl status apache2
A healthy Apache service shows active status and recent startup messages:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2025-11-16 10:15:32 UTC; 2min ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 12847 (apache2)
Tasks: 55 (limit: 4558)
Memory: 12.4M
CPU: 142ms
CGroup: /system.slice/apache2.service
├─12847 /usr/sbin/apache2 -k start
├─12848 /usr/sbin/apache2 -k start
└─12849 /usr/sbin/apache2 -k start
To enable Apache on system boot, use the following command:
sudo systemctl enable apache2
Finally, confirm the upgrade succeeded by rerunning the earlier version commands. The output should now reference the PPA build:
apache2 -v
The upgraded version now shows a higher version number from the PPA:
Server version: Apache/2.4.62 (Ubuntu) Server built: 2024-10-28T10:45:12
Verify the package now comes from the Ondřej Surý PPA:
apt-cache policy apache2
The output confirms the PPA is now the active source:
apache2:
Installed: 2.4.62-1+ubuntu22.04.1+deb.sury.org+1
Candidate: 2.4.62-1+ubuntu22.04.1+deb.sury.org+1
Version table:
*** 2.4.62-1+ubuntu22.04.1+deb.sury.org+1 500
500 https://ppa.launchpadcontent.net/ondrej/apache2/ubuntu jammy/main amd64 Packages
100 /var/lib/dpkg/status
Restore Default Ubuntu Apache Version
If you need to revert to the standard Ubuntu Apache version, use ppa-purge to remove the PPA packages and reinstall Ubuntu’s supported build in one step.
First, stop the Apache service and install ppa-purge if it is not already on your system:
sudo systemctl stop apache2
sudo apt install ppa-purge
Next, purge the PPA and reinstall Ubuntu’s default Apache packages automatically:
sudo ppa-purge ppa:ondrej/apache2
When the purge completes, start Apache again so the downgraded service comes back online and re-enable it on boot if you temporarily disabled it earlier:
sudo systemctl start apache2
sudo systemctl enable apache2
Verify the service reports an active state with the restored Ubuntu build before resuming production traffic:
sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Active: active (running) since Sat 2025-11-16 11:12:04 UTC; 20s ago
Main PID: 17842 (apache2)
CPU: 62ms
Finally, refresh your package lists and confirm the version matches Ubuntu’s repository:
sudo apt update
apache2 -v
The version output confirms the downgrade to Ubuntu’s repository version:
Server version: Apache/2.4.52 (Ubuntu) Server built: 2024-10-15T14:32:18
At this point, Apache is back on the Ubuntu-maintained build, and you can re-enable the PPA later if needed.
Troubleshoot Apache Upgrade Issues
If Apache fails to start or the PPA import encounters errors, walk through the following checks before rolling back. Each section explains what the symptom looks like, which commands to run, and how to interpret the output so you can get back to a working web server quickly.
Fix PPA Import or Update Failures
Repository timeouts and authentication errors usually trace back to network problems, stale cached data, or partially imported keys. Confirm the Launchpad mirror is reachable before repeatedly re-running apt update:
curl -I https://ppa.launchpadcontent.net/ondrej/apache2/ubuntu/dists/jammy/Release
A healthy connection returns an HTTP 200 header:
HTTP/1.1 200 OK Content-Length: 209 Content-Type: text/plain Date: Tue, 14 Jan 2025 16:02:08 GMT
If the request times out or shows TLS errors, fix upstream networking or install the missing certificate packages:
sudo apt install --reinstall ca-certificates dirmngr gnupg software-properties-common
When apt update shows a NO_PUBKEY warning, remove and re-add the PPA so the correct key is imported automatically:
sudo add-apt-repository --remove ppa:ondrej/apache2
sudo add-apt-repository ppa:ondrej/apache2
sudo apt update
Use this pattern on proxy-bound servers as well, but export your proxy variables first:
Set proxies temporarily before adding the PPA:
export http_proxy=http://proxy:3128andexport https_proxy=http://proxy:3128. Unset the variables after the repository import succeeds.
This is what a failed apt update run looks like when the key is missing:
Err:7 https://ppa.launchpadcontent.net/ondrej/apache2/ubuntu jammy InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E5267A6C
If the error persists, download the key manually:
sudo gpg --keyserver keyserver.ubuntu.com --recv-keys E5267A6C
sudo gpg --export --armor E5267A6C | sudo tee /etc/apt/trusted.gpg.d/ondrej-apache2.gpg > /dev/null
sudo apt update
Resolve Module ABI or Configuration Failures
Major Apache bumps can disable modules that were compiled against the old binary interface (ABI). List every enabled module and look for custom entries you might have added earlier:
sudo apachectl -M | sort
When a module throws errors, disable it, reload Apache, and install the updated package from the PPA:
sudo a2dismod php8.1
sudo systemctl reload apache2
sudo apt install libapache2-mod-php8.3
sudo a2enmod php8.3
sudo apachectl configtest
A failing module usually surfaces in apachectl configtest:
apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Cannot load /usr/lib/apache2/modules/libphp8.1.so into server: undefined symbol: unixd_config
Disable the module referenced in the error, reinstall it from the PPA, and only re-enable it after configtest reports Syntax OK.
Debug Apache Service Start Errors
Systemd status checks quickly reveal permission problems, missing files, or syntax issues. Capture the status output and then dive into the recent journal entries:
sudo systemctl status apache2 --no-pager
sudo journalctl -u apache2 -n 50 --no-pager
sudo tail -n 50 /var/log/apache2/error.log
A failed restart due to a typo in a virtual host looks like this:
Jan 14 16:11:07 web01 apachectl[10947]: AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/example.conf: Jan 14 16:11:07 web01 apachectl[10947]: Invalid command '<VirutalHost', perhaps misspelled or defined by a module not included in the server configuration
Open the referenced file, fix the typo, rerun sudo apachectl configtest, and start Apache again:
sudo nano /etc/apache2/sites-enabled/example.conf
sudo apachectl configtest
sudo systemctl start apache2
Detect Port Conflicts After the Upgrade
Apache cannot bind to ports 80 or 443 when another service already listens on those sockets. Identify the conflicting process with ss:
sudo ss -tulpn | grep -E ':(80|443)'
Example output showing Nginx occupying both ports:
tcp LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=2214,fd=6))
tcp LISTEN 0 511 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=2214,fd=7))
Stop or reconfigure the conflicting service before retrying Apache:
sudo systemctl stop nginx
sudo systemctl disable nginx
sudo systemctl start apache2
Alternatively, adjust Apache to listen on different ports by editing /etc/apache2/ports.conf and the affected virtual host files.
Recover from Partial or Broken Package Upgrades
A cancelled upgrade or a dependency mismatch can leave Apache in a half-configured state where new binaries are unpacked but not configured. Use APT’s repair commands to clean up pending package actions:
sudo apt --fix-broken install
sudo dpkg -l | grep apache2
Reinstall any package marked with ii but missing files, then rerun the configuration test:
sudo apt install --reinstall apache2 apache2-bin apache2-data
sudo apachectl configtest
sudo systemctl restart apache2
If the repair commands report held packages, clear them and attempt the upgrade again:
sudo apt-mark unhold apache2 apache2-bin
sudo apt full-upgrade
These steps return Apache to a consistent state so future upgrades and module installations apply cleanly.
Conclusion
Ondřej Surý’s PPA provides newer Apache versions with current security patches and performance improvements ahead of Ubuntu’s default repositories. The upgrade process now includes version verification, configuration checks, and safe rollback procedures so you can test new releases confidently. For automatic security updates, configure unattended upgrades to maintain Apache without manual intervention, secure your web server with UFW firewall rules, and review the Apache installation guide for TLS, virtual host, and module tuning tips.