Ray Lee | 李宗叡
Learn or Die
Published in
May 30, 2024

# 前言

紀錄在 Debian 上安裝 PHP 8.3 的步驟

# 加入 SURY repository

  • 安裝必要套件
  • apt-get install -y apt-transport-https lsb-release ca-certificates
  • 加入 repository key
  • wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg >/dev/null 2>&1
  • 加入 repository
  • echo "deb https://packages.sury.org/php/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/php.list
  • 更新套件清單
  • apt-get update
  • 升級套件版本
  • apt-get upgrade

# 安裝 PHP

apt-get install php8.3 php8.3-cli php8.3-cgi php8.3-fpm php8.3-gd php8.3-mysql php8.3-imap php8.3-curl php8.3-intl php8.3-pspell php8.3-sqlite3 php8.3-tidy php8.3-xsl php8.3-zip php8.3-mbstring php8.3-soap php8.3-opcache libonig5 php8.3-common php8.3-readline php8.3-xml

上面列出大概會使用到的套件,但並未包含全部。

# 更新 OS default PHP version

update-alternatives --config php
update-alternatives --config php-cgi
update-alternatives --config php-fpm.sock

# config 檔案位置

  • PHP-FPM init script: php8.3-fpm
  • php.ini directory: /etc/php/8.3/fpm/
  • PHP-FPM pool directory: /etc/php/8.3/fpm/pool.d/

# 參考來源

Ray Lee | 李宗叡
Learn or Die

It's Ray. I do both backend and frontend, but more focus on backend. I like coding, and would like to see the whole picture of a product.