軟件包連接:https://pan.baidu.com/s/1WHfuPXUMxTENOcngjEWZZQ
首先準備環境:兩臺虛擬機:一臺80.111一臺80.112yum install lrz* -y 安裝上傳工具
上傳軟解包和依賴包:
libedit-devel-3.0-12.20121213cvs.el7.x86_64.rpm
python-docutils-0.11-0.2.20130715svn7687.el7.noarch.rpm
varnish-5.2.1.tgz
html
yum install -y gcc gcc-c++ make //安裝編譯器和環境 安裝依賴關係包和所須要的插件: yum install -y \ libtool \ ncourses-devel \ pcre-devel \ libedit-devel \ libxslt \ groff \ pkgconfig \ ncurses-devel \ python-* rpm -ivh libedit-devel-3.0-12.20121213cvs.el7.x86_64.rpm rpm -ivh python-docutils-0.11-0.2.20130715svn7687.el7.noarch.rpm 安裝軟件 tar xf varnish-5.2.1.tgz -C /opt cd /opt/varnish-5.2.1/ //進入解壓後的文件夾中定義須要的模塊 ../autogen.sh //檢查系統環境
安裝依賴包 ./configure \ --prefix=/usr/local/varnish \ --enable-debugging-symbols \ --enable-developer-warnings make && make install //編譯 cd /usr/local/varnish/ ln -s /usr/local/varnish/sbin/varnishd /usr/sbin/ ln -s /usr/local/varnish/bin/* /usr/local/bin 建立軟鏈接 cp /usr/local/varnish/share/doc/varnish/example.vcl /usr/local/varnish/default.vcl //配置文件模板拷貝出來用 vi /usr/local/varnish/default.vclg 修改如下內容: backend default { .host = "192.168.80.112" //第二臺虛擬機的ip .port = "80" }
完成後保存退出python
varnishd -f /usr/local/varnish/default.vcl -a 0.0.0.0:80 //#指定監聽的ip和端口啓動varnish netstat -anpt | grep varnishd 查看端口是否在運行
在另外一臺linux虛擬機上搭建一個web服務器:linux
yum install -y httpd vi /var/www/html/index.html <h1>server 1</h1> systemctl start httpd 測試,在windows瀏覽器中輸入http://192.168.80.111(varnish服務器的ip地址)
vi /etc/httpd/conf/httpd.conf 直接輸入/ServerName回車將servername前面的#刪掉
保存退出c++
啓動httpd服務:systemctl start httpd
再瀏覽器中輸入192.168.80.111(第一臺服務器IP地址)
出現再第二臺虛擬機中寫的網頁加即算成功web