We’ll use the Ondřej Surý PPA (Personal Package Archive). If you think it is not safe, do not use it. The choice is entirely yours. You can also check out this discussion.
1. If you’re trying this on a virtual machine first — which is a good idea — create a snapshot. That way, you can easily roll back changes on the VM.
2. Check your current Apache version:
apache2 -v
On Ubuntu 22.04 I’ve got:
Server version: Apache/2.4.52 (Ubuntu)
Server built: 2024-07-17T18:57:26
3. Check enabled Apache modules:
apache2ctl -M
4. Add the PPA (Personal Package Archive):
sudo apt update sudo apt install software-properties-common -y sudo add-apt-repository ppa:ondrej/apache2 -y
and update the package list:
sudo apt update
5. Upgrade Apache from the PPA:
Make a copy of your current Apache2 configuration file /etc/apache2/apache2.conf
. Then run:
sudo apt upgrade apache2
Please notice:
1. You can consider upgrading all Ubuntu packages, not just apache2
:
sudo apt upgrade
2. If Apache isn’t installed on your server, you’ll need to install it instead of upgrading, of course:
sudo apt install apache2
6. Restart Apache:
service apache2 restart
7. Check the Apache version:
apache2 -v
Now, on Ubuntu 22.04 I’m getting:
Server version: Apache/2.4.62 (Ubuntu)
Server built: 2024-07-22T12:36:51
Conclusion
Thank you for reading to the end.
If you have any questions or thoughts to share, feel free to ask in the comments section below—I’d be happy to help!