Apache server is a popularly used by millions of websites and blogs. It is regularly updated with latest bug fixes, patches, performance improvements and new features. So it is important to update your Apache server from time to time. In this article, we will learn how to upgrade Apache version in Ubuntu.
Why Upgrade Apache Version
There are several important reasons why you should regularly update Apache server. Let us look at the most common ones.
1. Bug Fixes – Every software version contains bug fixes that were discovered in previous version. When you update your Apache server, these bugs are automatically fixed on your system, making it less vulnerable. It will also make your website more stable. If you do not update your server for a long time, then these bugs will continue to exist on your server and may be exploited by hackers. Lastly, latest software versions have wide community support, compared to older ones. This makes it easy to find answers to your questions.
2. New Features – Every Apache version releases new features that simplify the way you can use Apache server. If you do not upgrade Apache server, you are simply missing out on all these new features. Some of these new features such as safer authentication and data storage, data compression, etc. are very critical. Sometimes, a version may include new support for third-party platforms such as Python, PHP, Perl, etc.
3. Performance Improvements – Newer Apache versions deliver better performance with smaller memory footprint. It means being able to process more requests, compress data better or even support completely new ways of programming such as parallel processing. By keeping your Apache server up-to-date, you may obtain performance improvements without making any hardware upgrades, saving you tons of money.
4. Security Updates – New online threats are emerging regularly and it is important to protect our website from them. Apache software updates contain patches for most known vulnerabilities like cross-site scripting(XSS). Every software update contains many such patches, free of cost. By updating our Apache server, you can easily and pre-emptively fix all these problems and secure your site. You don’t need to fix them from scratch.
How to Upgrade Apache Version
Next, let us look at the steps to upgrade Apache version in Ubuntu server. You can use these steps on all Ubuntu/Debian systems.
1. Backup Configuration & Data
First, we need to take a backup of site data and Apache config files, so that we can easily recover them in case things do not go as expected. Here are the commands to do so. The first command does a backup of Apache configuration while the second one does a backup of site data and files.
cp -r /etc/apache2 /root/apache2_backup
cp -r /var/www /root/www_backup
2. Stop Apache Server
Next, we need to stop Apache server.
sudo service apache2 stop
3. Update System Packages
Next, we add Apache package repository.
sudo add-apt-repository ppa:ondrej/apache2
Then we need to update system packages with the following command.
sudo apt update
4. Upgrade Apache Server
Run the following command to upgrade Apache server.
sudo apt-get upgrade apache2
This command will update Apache to latest stable version. If you want to update Apache to a specific version then run the following command instead.
apt-get install <packagename>=<complete version name>
Here is an example.
sudo apt-get install apache2=2.2.14-5ubuntu8.7
6. Restart Apache Server
Run the following command to restart Apache server.
sudo service apache2 restart
7. Verify Apache Version
Run the following command to verify Apache version.
apache2 -v
Similarly, you can also upgrade Apache server in Redhat, CentOS & Fedora System.
Points to Remember
While upgrading Apache server, you need to keep the following points in mind.
- Backup – First step is to backup the Apache configuration and website files. Otherwise, it will be difficult for you to rollback any changes made during the upgrade.
- Dependencies – You need to check if its dependencies work well with the Apache version you are trying to install. If you use virtual hosts, check if they too are compatible with the Apache version.
- Test – It is always good to upgrade and test the server in a staging/development environment before making changes to production environment. This will help you identify and rectify issues beforehand.
Conclusion
In this article, we have learnt why it is important to upgrade Apache server, and also the steps to do so. You can follow these steps to update Apache server on a regular basis.
Also read:
How to Increase Max URL Length in Apache Server
How to Enable mod_ssl in Apache Server
How to Enable CORS in Apache Server

Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.