HTTP/2 is a major revision of the HTTP network protocol, designed to improve performance and efficiency. In this guide, we will walk you through the steps to enable HTTP/2 in Apache Web Server on Ubuntu and Debian. Whether you are hosting your site on a local server or using a Windows VPS UK, this tutorial covers all the necessary steps.
Step 1: Update Your System
Before making any changes, ensure your system is up to date. Run the following commands:
sudo apt update && sudo apt upgrade -y
Keeping your system updated is crucial for security and performance, whether you're setting it up locally or on a VPS Windows Servers platform.
Step 2: Install Apache
If Apache is not already installed, you can install it using:
sudo apt install apache2 -y
Step 3: Enable Apache Modules
To use HTTP/2, you need to enable the necessary Apache modules. Run the following commands:
sudo a2enmod headers
sudo a2enmod ssl
sudo a2enmod http2
Step 4: Configure Apache for HTTP/2
Edit your Apache configuration file to enable HTTP/2. If you are using the default configuration, you can edit the following file:
sudo nano /etc/apache2/sites-available/000-default.conf
Add the following lines within the <VirtualHost *:443>
block:
Protocols h2 http/1.1
Your configuration should look like this:
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Protocols h2 http/1.1
SSLEngine on
SSLCertificateFile /path/to/your/certificate.crt
SSLCertificateKeyFile /path/to/your/private.key
Step 5: Restart Apache
After making the changes, restart Apache to apply them:
sudo systemctl restart apache2
Step 6: Verify HTTP/2 Support
To verify that HTTP/2 is enabled, you can use an online tool like KeyCDN's HTTP/2 Test. Enter your domain, and it will tell you if HTTP/2 is supported.