Linux Tutorials Others

Setup Hi-performance web server by Apache Nginx with Varnish

varnish_cache copy

Varnish is an HTTP accelerator designed for content-heavy dynamic web sites as well as heavily consumed APIs. In contrast to other web accelerators, such as Squid, which began life as a client-side cache, or Apache and nginx, which are primarily origin servers, Varnish was designed as an HTTP accelerator

Our Scenario

varnish

Connect to your server

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish0

install peel release

yum install epel-release

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish1guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish2

update yum

yum update

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish3guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish4

install apache (httpd) server

yum install httpd

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish5

enable and restart httpd server

systemctl enable httpd

systemctl restart httpd

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish6

check the httpd status

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish7

Installation of VARNISH

yum install varnish

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish8 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish9

Modify Varnish listing port so that varnish can able to access port 80

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish10 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish11

 

change varnish proxy port to apache port here we will change the apache port 80 to 8080

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish12 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish13

change apache port to 8080

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish14guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish14guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish15

restart httpd, varnish

systemctl restart httpd

systemctl restart varnish

systemctl enable varnish

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish16 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish17

check the status

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish18

install nginx for high-performance

yum install nginx

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish19 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish20

change the nginx port to 8000 and after that we will change varnish backend port to 8000

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish21 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish22 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish23

create a html file in /var/www/html/index.html for testing

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish24

now open your ip with port 8000 for nginx testing

http://your-ip:8000

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish25

now change varnish backend port to 8000

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish26

restart varnish

systemctl restart varnish

Now install php for dynamic file processing

yum install php

yum install php-fpm

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish29 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish30 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish31 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish32

now change nginx config so that it can forward the dynamic php file to httpd

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish28

restart nginx and apache

systemctl restart nginx

systemctl restart httpd

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish29 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish33

create a index.php with following code in /var/www/html

<?php

echo phpinfo();

?>

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish34 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish35

test your ip in browser

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish36

now enable Gzip for compression.

modify some nginx configuration file

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish37 guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish38

restart nginx

systemctl restart nginx

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish39

open your ip in browser, you are now using best hi speed web browser

guess_linux_setup_hi_perfomance_serevr_with_apache_nginx_with_varnish40

 

Thank you…

Leave a Comment