![](/img/trans.png)
[英]Ubuntu 14.04 Apache + SSL server, how to configure Varnish
[英]Install and Configure varnish cache on Ubuntu server with VestaCP
我想安裝和配置Varnish Cache以在VPS上正常工作。 vps操作系統是Ubuntu 14.04,我已經安裝並使用VestaCP。 我的vps上同時安裝了Apache和nginx。
我發現在vps上安裝清漆緩存沒有問題,我的問題是我無法將其配置為正常工作。 我找到的所有文檔都是針對使用Apache或Nginx的服務器的,但是VestaCP都安裝在我的計算機上。 我需要將apache和nging都移至其他端口,並將清漆移至端口80。因此,我需要有關如何執行此操作的信息。
謝謝你們。
您可以通過更改'/ etc / default / varnish'中的'-a'選項在Ubuntu上配置Varnish端口。
有關其他選項,請參見: https : //www.varnish-cache.org/docs/4.0/reference/varnishd.html#http-accelerator-daemon
可以在“ /etc/varnish/default.vcl”中配置清漆轉發到的后端系統。
首先,您需要在服務器上安裝VestaCP。 為此,您需要對服務器進行root訪問,然后鍵入:
curl -O http://vestacp.com/pub/vst-install.sh
和
bash vst-install.sh
要安裝清漆,請輸入:
sudo install varnish -y
您必須設置Varnish使其能夠在端口80上運行。這種情況將如下所示:Varnish在端口80上監聽,Nginx在端口8082上監聽,然后在端口8080上運行Apache。
Web請求=清漆(80)-> Nginx(8082)-> Apache(8080)
請按照以下步驟操作:
您可以編輯Varnish配置文件。 該文件位於以下目錄中:/ etc / sysconfig / varnish(或/etc/varnish/varnish.params)。 您可以使用自己喜歡的文本編輯器通過ftp進行編輯。
nano /etc/sysconfig/varnish
或nano /etc/varnish/varnish.params
搜索並找到VARNISH_LISTEN_PORT。 將端口號更改為80。
向下滾動頁面以找到VARNISH_STORAGE_SIZE。 將其設置為要分配給Varnish緩存文件的存儲器的合理數量的RAM。 (所有緩存的文件將從ram加載)
還要將VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"
更改為此: VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
保存更改並退出文本編輯器。
配置位於/ etc / varnish /中的Varnish默認VCL文件。 該VCL文件保存配置以告知varnish在何處查找Web服務器內容:/etc/varnish/default.vcl
nano /etc/varnish/default.vcl
這是您要執行的操作:
change .host ip from 127.0.0.1 to your server public IP
change .port 80 to .port 8082 which where nginx should listening.
uncomment (remove the # symbol) at sub vcl_recv section
add one } symbol at the end of that section
查找下面的子vcl_backend_response塊,並在其中添加以下幾行:
set beresp.ttl = 10s;
set beresp.grace = 1h;
轉到/etc/nginx/conf.d/目錄,查看是否有公共IP的配置文件:
cd /etc/nginx/conf.d ls
編輯該.conf文件。 用您自己的實際公共IP替換xxx.xxx.xxx.xxx:
nano xxx.xxx.xxx.xxx.conf
現在將端口:80更改為:8082
還要編輯/ usr / local / vesta / conf /中的vesta.conf文件。 使用您喜歡的文本編輯器,或者在我的情況下,我使用Nano:
nano /usr/local/vesta/conf/vesta.conf
將PROXY_PORT從80更改為8082
為位於/ home / user / conf / web的每個Vesta CP用戶編輯nginx.conf文件。 如果您有多個Vesta CP用戶,則此步驟效率不高,因為您必須對其全部進行編輯。 在我的示例中,我將為用戶admin編輯nginx.conf文件:
nano /home/admin/conf/web/nginx.conf
同樣,在偵聽線將端口80更改為8082。
打開您喜歡的Web瀏覽器,以管理員身份登錄到Vesta CP儀表板,然后單擊頁面頂部的“防火牆”菜單。 12.1。 編輯防火牆的12.2 / WEB部分。 現在在“端口”字段中廣告8082,然后單擊綠色的“保存”按鈕。
在運行測試之前,必須首先重新啟動Nginx並啟動Varnish Cache服務器:
service nginx restart service varnish start
我按照此頁面上的說明進行操作: http : //www.servermom.org/varnish-cache-vesta-cp/2564/ http://www.servermom.org/vestacp-configuration-varnish-cache/2580/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.