Apache web server is used by millions of websites and blogs. Its makers regularly release updates and fixes. It is important to upgrade Apache server often to improve your web server performance. In this article, we will learn how to upgrade Apache server.
Why Upgrade Apache Server
Generally, people put off Apache server upgrades until it is absolutely necessary or too late. There are several key reasons why you should regularly update Apache server:
1. Security – Most updates include security updates and patches that fix vulnerabilities found in older versions of Apache server. When new threats are discovered, they are fixed pre-emptively in newer versions. If you simply keep your Apache server up-to-date, you can easily avail all these fixes, without much effort. These security updates protect your website from common attacks such as DDOS (Distributed denial of service) and XSS (Cross site scripting).
2. Performance & Efficiency – Newer Apache versions are more optimized to work faster with lesser resource consumption. It means being able handle more requests, with lesser memory requirement. It may also use newer algorithms to compress response data or use a completely new paradigm such as parallel processing help boost your site performance.
These updates also improve one or more Apache modules such as those for Python, Perl, PHP, etc. It also improves efficiency of common tasks such as user authentication and content delivery. In fact, it may even save money on hardware upgrades by running better on existing systems.
3. New Features – Software updates almost always include one or more new features that were not present in older versions. It may include advanced authentication, URL processing, data compression, etc. It may also provide better compatibility with other software such as PHP, Python & Perl. It may also include support for new modules and libraries that were hitherto unavailable.
4. Bug Fixes – Every software update includes a set of bug fixes discovered in older versions, making it stable. Also, newer versions are more popular in online forums and user communities making it easy to find answers to common problems.
How to Upgrade Apache Server in CentOS, Redhat & Linux
Here are the setps to upgrade Apache server in CentOS/Redhat Linux. Let us look at them one by one.
1. Backup configuration and data
The first step is to create a backup of Apache configuration files and website data. You can do that with the following command.
cp -r /etc/httpd /root/httpd_backup
cp -r /var/www /root/www_backup
2. Stop Apache Server
Next, stop Apache service to prevent any conflict during upgrade.
systemctl stop httpd
3. Update System Packages
Run the following command to update your system packages.
yum update
4. Upgrade Apache Server
There are two ways to upgrade Apache server. Let us look at them one by one.
4.1. Upgrade Within Same Major Version
For example, if you are already using Apache 2.4 and want to upgrade to a newer minor version (e.g., 2.4.1 to 2.4.27) then you can do so by simply updating your system packages.
yum update
This would have happened in the previous step itself. In this case, Apache will updated to the latest minor version of same major version but not further. For example, if you are on Apache 2.2.1 and want to go to Apache 2.4.27 then this step will only update Apache till 2.2.34, the last stable version of Apache 2.2.
Restart Apache service.
systemctl restart httpd.service
4.2. Upgrade to New Major Version
This solution will help you upgrade Apache to a completely new major version, such as from 2.2 to 2.4. For this, install Software Collections (SCL) repository.
yum install centos-release-scl
Next, install Apache 2.4 from scratch.
yum install httpd24
Then you can start and enable Apache 2.4.
systemctl enable httpd24-httpd.service
systemctl start httpd24-httpd.service
5. Update Configuration Files
Next, you need to copy back the backup configuration files and data. Make sure to resolve any conflicts in this case.
cp -r /root/httpd_backup /etc/httpd
cp -r /root/www_backup /var/www
6. Install Required Modules
If your previous Apache version used any modules, they may not be available for your new Apache version. So you need to re-install them.
yum install httpd24-mod_ssl
Restart Apache Server to apply changes.
systemctl start httpd
7. Verify Apache Version
Run the following command to get the version of Apache running on your system.
httpd -v
Key Points
Here are a few things to keep in mind while updating Apache server.
1. Backup – Before you upgrade or update Apache server, make sure you have created a backup of its configuration file, located at one of these -/etc/apache2/httpd.conf, /etc/apache2/apache2.conf, /etc/httpd/httpd.conf, and /etc/httpd/conf/httpd.conf. Also backup your website data. This will help you recover in case something goes wrong.
2. Dependencies – Major upgrades need you to update Apache configuration file. Make sure that all its dependencies are met before you update Apache server. Also, if you use virtual hosts, then ensure that it is compatible with latest Apache version.
3. Test – It goes without saying that no matter what changes you make to Apache, make sure to test them first before releasing them. In other words, perform the updates in a development or staging environment, before pushing it to production.
Conclusion
In this article, we have learnt a couple of different ways to update/upgrade Apache server. You can use either of these methods depending on your requirement.
Also read:
How to Block Image Hotlinking But Allow Google
How to Change Port Number in Apache
How to Password Protect Directory in Apache

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