0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ConoHa VPS kusanagi環境 セットアップ内容

Last updated at Posted at 2024-11-21

PHP バージョンアップ

2024年11月現在、ConoHa VPSのかんたんkusanagi設定で構築すると、PHPのパージョンはすでにサポート切れの7.4だった。そのためバージョンアップが必要。

手順

以下8.3にバージョンアップするには以下のコマンドで可能

bash
kusanagi php --use php83

確認方法

以下コマンドで8.3になっていることを確認

bash
php -v

さらに、wordpress管理画面にログインし、サイトヘルスにアクセスしphpバージョンを確認することで上記バージョンが反映されていることを確認

WebP対応

EWWW Image Optimizerをインストール後、以下を実施

対応内容

/etc/opt/kusanagi/nginx/conf.dにある「<英数字数十文字の文字列>.conf」を開いて以下を追記

追記内容

ファイルの冒頭に以下追記

sample.conf
map $http_accept $webp_suffix {
    default "";
    "~*webp" ".webp";
}

2つのserver{}内に、それぞれ合計2か所に以下追記

sample.conf
# 画像ファイルの処理設定を追加
location ~* ^.+\.(png|jpe?g)$ {
    add_header Vary Accept;
    try_files $uri$webp_suffix $uri =404;
}

完成例

※client_max_body_size は初期状態では16MBだったが、All in one migrationを利用する都合上512MBに変更し

sample.conf
# vim: ft=conf et sw=4
#=======================================
# sample.com
#---------------------------------------

map $http_accept $webp_suffix {
    default "";
    "~*webp" ".webp";
}

server {
    listen 80;
    listen [::]:80;

    server_name sample.com www.sample.com;
    rewrite ^(.*)$ https://sample.com$request_uri permanent; # SSL ONLY
    rewrite ^(.*)$ https://www.sample.com$request_uri permanent; # SSL ONLY

    set $do_not_cache 1; ## page cache
    set $expire_days 90d;

    access_log  /home/kusanagi/sampledummytext012345/log/nginx/access.log main;
    error_log   /home/kusanagi/sampledummytext012345/log/nginx/error.log warn;

    charset UTF-8;
    client_max_body_size 512M;
    root /home/kusanagi/sampledummytext012345/DocumentRoot;

    # 画像ファイルの処理設定を追加
    location ~* ^.+\.(png|jpe?g)$ {
        add_header Vary Accept;
        try_files $uri$webp_suffix $uri =404;
    }

    include conf.d/505.inc;
    include conf.d/favicon.inc;
    include conf.d/acme.inc;

    include conf.d/sampledummytext012345.wp.inc;
    include conf.d/static.inc;
}

server {
    include conf.d/ssl_listen.inc;

    server_name sample.com www.sample.com;

    set $do_not_cache 1; ## page cache
    set $expire_days 90d;

    ssl_certificate     /etc/letsencrypt/live/sample.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;

    include conf.d/ssl.inc;
    ## OCSP stapling
    ssl_stapling off;
    ssl_stapling_verify off;
    resolver  8.8.4.4 8.8.8.8 valid=300s;
    resolver_timeout 10s;

    access_log  /home/kusanagi/sampledummytext012345/log/nginx/ssl_access.log main;
    error_log   /home/kusanagi/sampledummytext012345/log/nginx/ssl_error.log warn;

    charset UTF-8;
    client_max_body_size 512M;
    root  /home/kusanagi/sampledummytext012345/DocumentRoot;

    # 画像ファイルの処理設定を追加
    location ~* ^.+\.(png|jpe?g)$ {
        add_header Vary Accept;
        try_files $uri$webp_suffix $uri =404;
    }

    include conf.d/505.inc;
    include conf.d/favicon.inc;
    include conf.d/acme.inc;

    include conf.d/sampledummytext012345.wp.inc;
    include conf.d/static.inc;
    include conf.d/fcache_purge.inc;
}


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?