Friday, March 24, 2023
  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Podcasts
  • Web Hosting Directory
  • Login
  • Register
Cloud7 News
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • Software
    • Network/Internet
    • Hardware
    • Artificial Intelligence
    • Windows
    • Policy/Legislation
    • Blockchain
    • Troubleshooting
    • How-Tos
    • Articles
No Result
View All Result
Cloud7 News
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • Software
    • Network/Internet
    • Hardware
    • Artificial Intelligence
    • Windows
    • Policy/Legislation
    • Blockchain
    • Troubleshooting
    • How-Tos
    • Articles
No Result
View All Result
Cloud7 News
No Result
View All Result

Home > How-Tos > How to install Varnish on AlmaLinux

How to install Varnish on AlmaLinux

You can install Varnish Cache to your website to reduce the burden on your hosting service and the delays.


Birol Bavas Birol Bavas
July 9, 2022
5 min read

Varnish is an HTTP reverse proxy tool that you can use to reduce your website load and avoid lags. It stores client requests in RAM and eliminates the need to send a client request to the web service on the next visit. In this way, your website will load faster for the visitor.

If the content requested by the user is not in the cache, Varnish connects to the web server and stores the content for the next request. The services in this caching process work as two different layers.

“Origin” represents your original web server and “Edge” represents your Varnish application.

VCL, an abbreviation of Varnish Configuration Language, is a configuration language used to provide Varnish controls. It is a unique Varnish application language used to perform request processing, routing, caching, and many other operations.


Table of Contents

  • Varnish installation
  • Configuration
    • Changing Varnish ports
    • Setting Varnish listening port
    • Changing ports on Nginx

Varnish installation

Here, we have a video version of our tutorial if you want to check:

The Varnish application can be installed on distributions such as Ubuntu, Debian, CentOS, and Red Hat Enterprise Linux. In this article, we will install Varnish on the AlmaLinux operating system.

Let’s check the HTTP Response values of the website before installation with the help of curl. You should replace the IP address with your website’s IP address, or you can directly write your address as well:

curl -I https://yourwebsite.com


Varnish can be installed from the AlmaLinux repo, but if the package manager is out of date, it will install an old version. To avoid this, it would be healthier to install Varnish from the official site.

First, disable the Varnish service from the DNF package manager:

sudo dnf module disable varnish


Then install the EPEL package manager to allow Varnish dependencies to be installed:

sudo dnf install epel-release -y


The EPEL installation was successful. Go to the official Varnish Cache site and copy and paste the code below into the terminal screen.

. /etc/os-release
sudo tee /etc/yum.repos.d/varnishcache_varnish60lts.repo > /dev/null <<-EOF
[varnishcache_varnish60lts]
name=varnishcache_varnish60lts
baseurl=https://packagecloud.io/varnishcache/varnish60lts/el/${VERSION_ID%%.*}/$(arch)
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish60lts/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF

You can copy the command from the Varnish installation tutorial page to register the latest version to the EPEL repository.

As the registration completes, you can now install Varnish Cache 6.0 LTS by using the following command:

dnf install varnish -y

Configuration

Changing Varnish ports

After the Varnish installation is finished, you can manage its settings by running the varnishd parameter. The varnishd process is managed by systemd. To make changes to the configuration file, copy and paste the following command to the terminal screen:

nano /usr/lib/systemd/system/varnish.service

While installing Varnish Cache, it uses port 6081 so that it does not conflict with the web service. Change port 6081 to 80 in the -a parameter in the ExecStart field so that the Varnish Cache service can listen on port 80. Then we will make settings on the Nginx service. Save this file and exit.


Setting Varnish listening port

No port changes have been made on the Nginx yet, but we need to specify which port to listen to the Varnish Cache service. In this article, port 8080 will be used. So check the .port field and change it to 8080. Then save the file and exit.

nano /etc/varnish/default.vcl


Changing ports on Nginx

To change the port of the Nginx service, go to the file path below and follow the steps, or quickly perform the following steps with the sed command:

nano /etc/nginx/nginx.conf

You can also quickly perform the operations above using the command below:

sudo find /etc/nginx -name '*.conf' -exec sed -r -i 's/\blisten ([^:]+:)?80\b([^;]*);/listen \18080\2;/g' {} ';'

As the steps above complete, restart the Nginx service:

systemctl reload nginx.service


Then enable the Varnish Cache service:

systemctl enable varnish
systemctl start varnish.service


You have completed the installation of Varnish on AlmaLinux. To verify the installation, check the HTTP response list again with the curl command:

curl -I https://yourwebsite.com

Tags: AlmaLinux OS
Birol Bavas

Birol Bavas

Birol Bavas is the operations & security manager of Cloud7. He has been building system architectures for several years. He is also a PHP and C# developer and has built countless web applications. For more than 10 years, he has been using Linux actively.

Leave a Reply Cancel reply

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

I agree to the Terms & Conditions and Privacy Policy.

Next Post
how to fix http 503 error

What is HTTP 503 (Service Unavailable) Error? How to fix it?

Related News

How to manage DNS settings in Linux

How to manage DNS settings in Linux

March 23, 2023 9:00 pm
How to change system language on Windows 11

How to change system language on Windows 11

March 22, 2023 7:00 pm
How to create and manage menus in WordPress

How to create and manage menus in WordPress

March 22, 2023 6:30 pm
Learn how to install GE-Proton on Steam Play using the ProtonUp-Qt app

How to install GE-Proton on Steam Play using the ProtonUp-Qt app

March 14, 2023 3:15 pm
Get free daily newsletters from Cloud7 News Get the Cloud7 Newsletter
Select list(s):

Check your inbox or spam folder to confirm your subscription.

By subscribing, you agree to our
Copyright Policy and Privacy Policy

Get the free newsletter

Subscribe to receive the latest IT business updates straight to your inbox.

Select list(s):

Check your inbox or spam folder to confirm your subscription.

Recent News

  • Photopea review: The best free Photoshop alternative for Linux
  • CloudFest 2023 is completed
  • EdgeConneX executes $3.3B in sustainability-linked financing
  • How to manage DNS settings in Linux
  • What is Cloudflare Warp?

Cloud7 News
Cloud7 is a news source that publishes the latest news, reviews, comparisons, opinions, and exclusive interviews to help tech users of high-experience levels in the IT industry.

EXPLORE

  • Web Hosting
  • Cloud Computing
  • Data Center
  • Cybersecurity
  • Linux
  • Network/Internet
  • Software
  • Hardware
  • Artificial Intelligence
  • How-Tos
  • Troubleshooting

RESOURCES

  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Podcasts
  • Web Hosting Directory

Get the Cloud7 Newsletter

Get FREE daily newsletters from Cloud7 delivering the latest news and reviews.

  • About Us
  • Privacy & Policy
  • Copyright Policy
  • Contact

© 2023, Cloud7 News. All rights reserved.

No Result
View All Result
  • Cloud Computing
  • Web Hosting
  • Data Center
  • Linux
  • Cybersecurity
  • More
    • Software
    • Network/Internet
    • Hardware
    • Artificial Intelligence
    • Windows
    • Policy/Legislation
    • Blockchain
    • Troubleshooting
    • How-Tos
    • Articles
  • Events
  • Interviews
  • Jobs
  • Opinion
  • Whitepapers
  • Podcasts
  • Web Hosting Directory

© 2023, Cloud7 News. All rights reserved.

Welcome Back!

Sign In with Facebook
Sign In with Google
Sign In with Linked In
OR

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Sign Up with Facebook
Sign Up with Google
Sign Up with Linked In
OR

Fill the forms below to register

*By registering into our website, you agree to the Terms & Conditions and Privacy Policy.
All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.