備忘錄_20160105(定位) 修改 回首頁

程式 2024-04-09 14:36:21 1712644581 100
raspberry pi 4 更新 php (結果 php7.3, php8.3 並存)

raspberry pi 4 更新 php (結果 php7.3, php8.3 並存)
First download GPG key.

sudo apt -y install lsb-release apt-transport-https ca-certificates 
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Next, add SURY to the repository.

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

sudo apt update -y
sudo apt upgrade -y
sudo reboot

apache2 的 php 從 7.3 轉到 8.3 時,許多東西異常,需要花時間處理,先轉回來!

/*
sudo a2dismod php7.3
sudo a2enmod php8.3
sudo service apache2 restart

sudo update-alternatives --set php /usr/bin/php8.3
sudo update-alternatives --set phar /usr/bin/phar8.3
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.3
sudo update-alternatives --set phpize /usr/bin/phpize8.3
sudo update-alternatives --set php-config /usr/bin/php-config8.3
*/

安裝 pecl

sudo apt-get install php-pear

sudo pecl channel-update pecl.php.net
sudo apt-get install php8.3-dev (這樣就有phpize)
sudo pecl install openswoole-22.1.2

中間跑很久,僅節錄最後結果
  Build process completed successfully
  Installing '/usr/lib/php/20230831/openswoole.so'
  Installing '/usr/include/php/20230831/ext/openswoole/config.h'
  Installing '/usr/include/php/20230831/ext/openswoole/php_openswoole.h'
  install ok: channel://pecl.php.net/openswoole-22.1.2
  configuration option "php_ini" is not set to php.ini location
  You should add "extension=openswoole.so" to php.ini

sudo nano /etc/php/8.3/cli/php.ini
  增加 extension=openswoole.so
  
php -i | grep swoole (可知 swoole 已啟用)
composer require openswoole/core:22.1.5