Skip to content

Latest commit

 

History

History
77 lines (59 loc) · 2.14 KB

UPGRADE_PHP_README.md

File metadata and controls

77 lines (59 loc) · 2.14 KB

Upgrade PHP

Overview

This script will upgrade PHP from one version to another, and make all changes that LEMP setup guide makes to the PHP and PHP-FPM configs as part of the initial/per-site setup.

Note:

  • The script must be run as root (sudo su first if you're not already root)
  • It will exit on the first error it encounters
  • It assumes that at least 1 site has already been set up. You can run the LEMP setup guide to set up a site.

It will do the following:

  1. Install new versions of PHP and php-fpm if they don't already exist
  2. Install all php packages
  3. Enable all php extensions
  4. Make edits to PHP.ini file
  5. Make edits to www.conf file if needed
  6. Copy all php-fpm configs but www.conf over to the new version
  7. Loop through each file in /etc/nginx/sites-enabled. Per site:
    • Update php-fpm config
    • Test php-fpm config
    • Check that new php-fpm sockets have been created
    • Update nginx site conf to point to new socket
    • Test nginx config
  8. Update nginx fastcgicache conf to point to a new global socket
  9. Test nginx config and reload (this sets the new php version live)
  10. Update default PHP version
  11. Output next steps

Usage

upgrade-php.sh OLD_VERSION NEW_VERSION

Example: upgrade-php.sh 8.0 8.2

Note:

  • Set $DEBUG for a verbose output - $DEBUG=true ./upgrade-php.sh [options]
  • You can also run it without args to see the usage info: ./upgrade-php.sh

Troubleshooting

  • If you're having issues with the script, try running it with the $DEBUG variable set to true. This will output more verbose information about what the script is doing.
$DEBUG=true ./upgrade-php.sh OLD_VERSION NEW_VERSION

Helpful commands

  • Get php version
php -v
  • Check pool.d configs (this will show the old and new versions)
grep -R "listen = /var/run/php" /etc/php/*/fpm/pool.d/
  • Look for sockets
ls -al /var/run/ | grep php
  • Check nginx site configs
grep -R "unix:/var/run/php" /etc/nginx/sites-enabled/
  • Find running php-fpm processes
ps aux | grep php-fpm