Upgrading Apache HTTP Server on Ubuntu is crucial for maintaining security, performance, and compatibility with the latest web technologies. Apache, one of the most widely used web servers globally, frequently receives updates that address vulnerabilities, improve efficiency, and add new features. For users who want to ensure they are running the latest version of Apache on their Ubuntu system, using Ondřej Surý’s PPA (Personal Package Archive) is an excellent option. This PPA provides up-to-date Apache builds and is maintained by a trusted and experienced Debian developer.
To upgrade Apache on Ubuntu 24.04, 22.04, or 20.04 using the command-line, you can add Ondřej Surý’s repository, which allows you to easily install and upgrade to the latest Apache version. This guide will walk you through the steps needed to upgrade your Apache installation using this method.
Update Ubuntu Before Apache Upgrade
Update your system before beginning the installation process to avoid potential conflicts. This proactive step ensures that your system’s packages are up-to-date and compatible with the installation, facilitating a smoother and more successful upgrade process.
In your terminal, run the following command:
sudo apt update
You can proceed with the following command to upgrade any outdated packages on your system. This will ensure that your system has access to the latest software versions, which can result in improved performance and security:
sudo apt upgrade
Import Apache LaunchPAD PPA
To upgrade the Apache webserver to the latest version, add Ondřej Surý’s repository as an initial step. Ensure you have installed the following packages:
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https
Next, import the repository using the following command:
sudo add-apt-repository ppa:ondrej/apache2 -y
Proceed to Upgrade Apache
The next step involves updating your repository to reflect the new changes. To do this, run the following command:
sudo apt update
After adding the PPA, install the latest Apache version or upgrade your existing one. Most users should run the installation command, even with Apache already on the system, to ensure installation of the latest version and update of all necessary dependencies.
To install the latest Apache version, use the following command:
sudo apt install apache2
To ensure that Apache is running correctly, you can use the systemctl command. This command allows you to check Apache’s status and verify that it is up and running as intended.
systemctl status apache2
If Apache isn’t activated or running, use the following command to start the web server application:
sudo systemctl start apache2
To enable Apache on system boot, use the following command:
sudo systemctl enable apache2
Restore Apache Default Version
If you need to remove the upgraded Apache version and restore the standard Ubuntu version, you can do so by following these steps:
First, stop the Apache service by using the following command:
sudo systemctl stop apache2
Next, remove Apache by using the following command:
sudo apt remove apache2
If you had imported the PPA to upgrade Apache, you could remove it by using the following command:
sudo add-apt-repository --remove ppa:ondrej/apache2 -y
Finally, to reflect the changes made to the APT sources list entries, run the following command:
sudo apt update
At this point, you can re-install the standard Apache version.
Conclusion
Upgrading Apache on your Ubuntu system using Ondřej Surý’s PPA ensures that you have access to the latest features, performance improvements, and security patches. By following the steps outlined, you can maintain a secure and efficient web server environment. Regularly checking for updates through this repository will keep your Apache installation current, ensuring that your web services are always running optimally on Ubuntu.