Banner image featuring a colorful abstract feather with upward arrows, symbolizing progress and upgrading. Text on the left reads 'Upgrade Apache on Ubuntu,' with branding 'Guides by DevAnswe.rs' below.

How to Upgrade Apache HTTP Server on Ubuntu

Last updated on

Upgrading Apache HTTP Server is essential for maintaining a stable and optimized web server environment. This guide provides step-by-step instructions for upgrading Apache on Ubuntu. It also covers situations where the version in Ubuntu’s default repository might be outdated, necessitating the addition of a custom repository to access the latest version.

1: Check the Latest Apache Version

Before starting the upgrade process, it’s important to know the latest version of Apache available so you can decide whether you need to add a custom repository.

How to Check the Latest Apache Version:

  1. Visit the Official Apache Website: You can find the latest stable release of Apache HTTP Server on the official Apache HTTP Server Project website. Look for the latest version listed under the “Current Release” section.
  2. Compare With Your Current Version: Note the latest version available on the website.
  3. Check Your Current Apache Version: Open your terminal (or use the terminal on your server) and type:
  4. apache2 -v

    This will display the current version of Apache. Compare this version with the latest version noted from the Apache website.

    • If your current version is up-to-date or close to the latest, you may not need to add a custom repository.
    • If your current version is significantly behind, or if the latest version includes important security updates, proceed with the steps below to add a custom repository.

2: Reboot Your Server

Sometimes, Apache might auto-update during a system reboot if your server is configured for automatic updates. To check if this happens:

sudo reboot

Wait a moment for the server to reboot, then log back in.

3: Check Apache Version Again

After the server has rebooted, check the Apache version again:

apache2 -v

Compare this version to the one noted earlier. If the version has changed, Apache was automatically updated during the reboot.

  • If the version is updated and matches the latest available version, no further upgrade is necessary.
  • If the version has not changed, proceed with the next step to attempt a manual upgrade.

4: Attempt to Upgrade Apache Using Default Repositories

Before adding any custom repositories, it’s worth attempting to upgrade Apache using Ubuntu’s default repositories. This step may save you from having to add a custom repository if the default repositories are up-to-date.

Update Your Package List:

Make sure your package list is up to date to ensure that you’re installing the latest versions available in the default repositories.

sudo apt update

Upgrade Apache:

Attempt to upgrade Apache using the following command:

sudo apt upgrade apache2

Check Apache Version Again:

After the upgrade attempt, verify the Apache version:

apache2 -v

If this version matches or is close to the latest version, no further steps are needed.

  • If the version has not updated to the desired version, proceed with adding a custom repository in the next step.

5: Add the Latest Apache Repository (If Necessary)

If the version available in the default repositories is not the latest or does not meet your requirements, you’ll need to add a custom repository that has the latest version.

Install software-properties-common:

This package allows you to add new repositories.

sudo apt-get install software-properties-common

Add the Latest Apache PPA (Personal Package Archive):

sudo add-apt-repository ppa:ondrej/apache2

Update Your Package List Again:

sudo apt-get update

6: Upgrade Apache HTTP Server Using the Custom Repository

After ensuring that your package list is up to date with the new repository, upgrade Apache:

sudo apt install apache2

7: Verify Apache Version

After the upgrade, it’s essential to verify that the correct version of Apache has been installed.

apache2 -v

This should return a line similar to the following if the upgrade was successful:

Server version: Apache/2.4.55 (Ubuntu)

8: Restart Apache

To ensure that the changes take effect, restart the Apache service.

sudo systemctl restart apache2

9: Check Apache Status

To confirm that Apache is running correctly, use the following command:

sudo systemctl status apache2

You should see an output indicating that Apache is active and running.

Conclusion

By following these steps, you can ensure that Apache HTTP Server on your Ubuntu system is up-to-date and functioning optimally. Checking for the latest version, attempting an upgrade with the default repositories, and adding a custom repository if necessary ensures that your server runs the most secure and stable version of Apache available. Regular updates and maintenance are crucial for keeping your web server secure, efficient, and capable of handling modern web traffic demands. Remember, staying current with updates not only improves performance but also helps protect your server from potential vulnerabilities.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

Leave a reply

Your email address will not be published. Required fields are marked *