{"id":10626,"date":"2023-10-27T11:52:46","date_gmt":"2023-10-27T02:52:46","guid":{"rendered":"https:\/\/www.prime-strategy.co.jp\/column\/archives\/column_10626"},"modified":"2026-02-22T21:03:00","modified_gmt":"2026-02-22T12:03:00","slug":"effortlessly-manage-php-versions-with-kusanagi-php-2","status":"publish","type":"post","link":"https:\/\/kusanagi.tokyo\/column\/en\/archives\/column_10626","title":{"rendered":"Effortlessly Manage PHP Versions with \u201ckusanagi php\u201d"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This article explains how to use the kusanagi php command and compares it with kusanagi container.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hello, this is Fukuda from Prime Strategy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Did you know there\u2019s a command that lets you switch PHP versions instantly and optimize settings automatically? That\u2019s exactly what&nbsp;<code>kusanagi php<\/code>&nbsp;does.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For reference, in KUSANAGI 9 (Business Edition or higher), there is also an alternative called&nbsp;<code>kusanagi container<\/code>, which allows you to switch PHP versions per profile. We\u2019ll explore the differences later in this article.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Switching_PHP_Versions_with_the_%E2%80%93use_Option\"><\/span>Switching PHP Versions with the \u2013use Option<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To switch PHP versions, simply use the&nbsp;<code>--use<\/code>&nbsp;option. As of October 26, 2023, the available options are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>php82<\/code>\u00a0for PHP 8.2<\/li>\n\n\n\n<li><code>php81<\/code>\u00a0for PHP 8.1<\/li>\n\n\n\n<li><code>php80<\/code>\u00a0for PHP 8.0<\/li>\n\n\n\n<li><code>php74<\/code>\u00a0for PHP 7.4<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This command uses&nbsp;<code>dnf<\/code>&nbsp;under the hood, which uninstalls the old version and installs the new one, so the process takes several seconds to a few minutes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, when upgrading from PHP 8.1 to 8.2, you\u2019ll see output similar to the following. Once you see&nbsp;<code>Complete!<\/code>&nbsp;followed by&nbsp;<code>php completed.<\/code>, the switch is complete.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@host~]# kusanagi php --use php82 \nLast metadata expiration check: 1:07:54 ago on Fri Oct 27 02:17:40 2023.                                                Dependencies resolved.                                                                                                  ================================================================================                                         Package              Architecture Version                Repository       Size                                         ================================================================================\nInstalling:\n  kusanagi-php82       x86_64       8.2.11-1.el8           kusanagi         11 M\nInstalling dependencies:\n  libargon2            x86_64       20171227-3.el8         epel             29 k\nRemoving:\n  kusanagi-php81       x86_64       8.1.24-1.el8           @kusanagi        60 M                                                                                                                                                                 Transaction Summary                                                                                                     ================================================================================\nInstall  2 Packages\nRemove   1 Package                                                                                                                                                                                                                              Total download size: 11 M \nDownloading Packages:\n(1\/2): libargon2-20171227-3.el8.x86_64.rpm      712 kB\/s |  29 kB     00:00\n(2\/2): kusanagi-php82-8.2.11-1.el8.x86_64.rpm    45 MB\/s |  11 MB     00:00\n--------------------------------------------------------------------------------\nTotal                                            14 MB\/s |  11 MB     00:00\nRunning transaction check\nTransaction check succeeded.\nRunning transaction test\nTransaction test succeeded.\nRunning transaction\n  Preparing        :                                                        1\/1\n  Running scriptlet: libargon2-20171227-3.el8.x86_64                        1\/1\n  Installing       : libargon2-20171227-3.el8.x86_64                        1\/3\n  Installing       : kusanagi-php82-8.2.11-1.el8.x86_64                     2\/3\n  Running scriptlet: kusanagi-php82-8.2.11-1.el8.x86_64                     2\/3\n  Erasing          : kusanagi-php81-8.1.24-1.el8.x86_64                     3\/3\n  Running scriptlet: kusanagi-php81-8.1.24-1.el8.x86_64                     3\/3\n  Verifying        : libargon2-20171227-3.el8.x86_64                        1\/3\n  Verifying        : kusanagi-php82-8.2.11-1.el8.x86_64                     2\/3\n  Verifying        : kusanagi-php81-8.1.24-1.el8.x86_64                     3\/3\n\nInstalled:\n  kusanagi-php82-8.2.11-1.el8.x86_64       libargon2-20171227-3.el8.x86_64\nRemoved:\n  kusanagi-php81-8.1.24-1.el8.x86_64\n\nComplete!\nphp completed.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f\u00a0Please be sure to confirm compatibility with your applications before switching versions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Reference_PHP_Versions_Compatible_with_WordPress_on_KUSANAGI\"><\/span>Reference: PHP Versions Compatible with WordPress on KUSANAGI<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>PHP Version<\/td><td>WordPress version that works<\/td><td>PHP EOL Date<\/td><\/tr><tr><td>7.4<\/td><td>5.3 or higher<\/td><td>November 28, 2022<\/td><\/tr><tr><td>8.0<\/td><td>5.6 or higher<\/td><td>November 26, 2023<\/td><\/tr><tr><td>8.1<\/td><td>5.9 or higher<\/td><td>November 25, 2024<\/td><\/tr><tr><td>8.2<\/td><td>6.1 or higher<\/td><td>December 8, 2025<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see, PHP 7.4 is already past its end of life (EOL). Therefore, support for PHP 7.4 will soon be removed in KUSANAGI 9.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Restarting_PHP_and_Optimizing_Settings\"><\/span>Restarting PHP and Optimizing Settings<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019ve changed settings or encountered issues requiring a PHP restart, you typically use&nbsp;<code>systemctl restart php-fpm<\/code>. But with KUSANAGI, it\u2019s much simpler.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just run&nbsp;<code>kusanagi php<\/code>&nbsp;with no options. It will restart PHP and also optimize the instance settings if needed. Once&nbsp;<code>php completed.<\/code>&nbsp;is displayed, the restart was successful.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Comparing_kusanagi_php_and_kusanagi_container\"><\/span>Comparing kusanagi php and kusanagi container<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Both&nbsp;<code>kusanagi php<\/code>&nbsp;and&nbsp;<code>kusanagi container<\/code>&nbsp;deal with PHP, but they work differently:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th><code>kusanagi php<\/code><\/th><th><code>kusanagi container<\/code><\/th><\/tr><\/thead><tbody><tr><td>Affects<\/td><td>Host PHP (system-wide)<\/td><td>Per-profile using Podman<\/td><\/tr><tr><td>Version switching<\/td><td>Global<\/td><td>Per profile<\/td><\/tr><tr><td>Container required<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>Setup complexity<\/td><td>Simple<\/td><td>May require additional configuration<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Pros_of_kusanagi_php\"><\/span>Pros of kusanagi php<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Automatically optimizes configuration after changes.<\/li>\n\n\n\n<li>Available on\u00a0<strong>all editions<\/strong>\u00a0of KUSANAGI 9\u2014not just Business Edition or higher.<\/li>\n\n\n\n<li>No need to modify WordPress settings during initial setup.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"A_Double-Edged_Sword_Version_Switching_for_All_Profiles\"><\/span>A Double-Edged Sword: Version Switching for All Profiles<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A key characteristic of&nbsp;<code>kusanagi php<\/code>&nbsp;is that it changes the PHP version for&nbsp;<strong>all<\/strong>&nbsp;profiles at once (if you\u2019re not using containers). This can be both a benefit and a drawback.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pros:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Easier to apply security patches, feature updates, and performance improvements.<\/li>\n\n\n\n<li>No need to update versions one profile at a time.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Cons:<\/strong>\n<ul class=\"wp-block-list\">\n<li>If a new PHP version includes breaking changes, an across-the-board upgrade could break one or more sites.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Cons_of_kusanagi_php\"><\/span>Cons of kusanagi php<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You&nbsp;<strong>cannot run multiple PHP versions<\/strong>&nbsp;simultaneously. All profiles must use the same version.<br>For example, if you want to try out new features in PHP 8.2 on one profile but still need PHP 7.4 on another,&nbsp;<code>kusanagi php<\/code>&nbsp;alone won\u2019t support that.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ve explored the features of&nbsp;<code>kusanagi php<\/code>&nbsp;and how it compares to&nbsp;<code>kusanagi container<\/code>.<br>We hope this helps you better understand how KUSANAGI handles PHP version management.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"References\"><\/span>References<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a class=\"\" href=\"https:\/\/kusanagi.tokyo\/\">php \u2013 KUSANAGI Documentation<\/a><\/li>\n\n\n\n<li><a class=\"\" href=\"https:\/\/www.php.net\/supported-versions.php\">PHP: Supported Versions<\/a><\/li>\n\n\n\n<li><a>PHP Compatibility and WordPress Versions \u2013 Make WordPress Core<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This article explains how to use the kusanagi php command and compares it with kusanagi container. Hello, this is Fukuda from Prime Strategy. Did you know there\u2019s a command that lets you switch PHP versions instantly and optimize settings automatically? That\u2019s exactly what&nbsp;kusanagi php&nbsp;does. For reference, in KUSANAGI 9 (Business Edition or higher), there is also an alternative called&nbsp;kusanagi container, which allows you to switch PHP versions per profile. We\u2019ll ... <a title=\"Effortlessly Manage PHP Versions with \u201ckusanagi php\u201d\" class=\"read-more\" href=\"https:\/\/kusanagi.tokyo\/column\/en\/archives\/column_10626\" aria-label=\"Read more about Effortlessly Manage PHP Versions with \u201ckusanagi php\u201d\">Read more<\/a><\/p>\n","protected":false},"author":30,"featured_media":10684,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[93],"tags":[120],"series":[86],"journey":[126],"product":[121],"class_list":["post-10626","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-en","tag-technical-guides","series-kusanagi-command-en","journey-run","product-kusanagi","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33","no-featured-image-padding"],"_links":{"self":[{"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/posts\/10626","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/comments?post=10626"}],"version-history":[{"count":2,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/posts\/10626\/revisions"}],"predecessor-version":[{"id":10629,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/posts\/10626\/revisions\/10629"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/media\/10684"}],"wp:attachment":[{"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/media?parent=10626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/categories?post=10626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/tags?post=10626"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/series?post=10626"},{"taxonomy":"journey","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/journey?post=10626"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/en\/wp-json\/wp\/v2\/product?post=10626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}