Rocky Linux9 Varnishをインストールする方法
環境
Rocky Linux release 9.0
操作方法
1.アップデートを行います
$ sudo dnf update
2.「epel-release」をインストールします。
$ sudo dnf install epel-release
3.nginxを使用するので、インストールします
$ sudo dnf install nginx
4.nginxを起動します
$ sudo systemctl start nginx
自動起動を設定します
$ sudo systemctl enable --now nginx
ステータスを確認します
$ sudo systemctl status nginx
firewallを設定します
$ sudo firewall-cmd --permanent --add-service={http,https}
$ sudo firewall-cmd --reload
設定ファイルを編集します
$ sudo nano /etc/nginx/nginx.conf
server {
listen 8080;
listen [::]:8080;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
nginxを再起動します
$ sudo systemctl restart nginx
Varnish のインストールを行います
$ sudo dnf install varnish -y
バージョンを確認します
$ varnishd -V
ステータスを確認します。
$ systemctl status varnish
Varnish 設定を行います
$ sudo nano /usr/lib/systemd/system/varnish.service
「6081」から「80」に変更します。
[Unit] Description=Varnish Cache, a high-performance HTTP accelerator After=network-online.target [Service] Type=forking KillMode=process # Maximum number of open files (for ulimit -n) LimitNOFILE=131072 # Locked shared memory - should suffice to lock the shared memory log # (varnishd -l argument) # Default log size is 80MB vsl + 1M vsm + header -> 82MB # unit is bytes LimitMEMLOCK=85983232 # Enable this to avoid "fork failed" on reload. TasksMax=infinity # Maximum size of the corefile. LimitCORE=infinity ExecStart=/usr/sbin/varnishd -a :80 -f /etc/varnish/default.vcl -s malloc,256m ExecReload=/usr/sbin/varnishreload [Install] WantedBy=multi-user.target
varnishを再起動します
$ sudo systemctl daemon-reload
$ sudo systemctl restart varnish