Jump to content
View in the app

A better way to browse. Learn more.

PHP论坛人

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

安裝PHP 8.4與配置

Featured Replies

-----------------------------
修改為安裝sury.org的PHP源
-----------------------------

apt install wget

wget -O /usr/share/keyrings/php.gpg https://packages.sury.org/php/apt.gpg


echo "deb [signed-by=/usr/share/keyrings/php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list


更新源
apt update


apt install curl vim gnupg dpkg apt-transport-https lsb-release ca-certificates -y


apt install php-pear -y


apt install php8.4-{fpm,cli,mysql,curl,gd,mbstring,xml,zip,imap,soap,gmp,bcmath,redis} -y


瀏覽pear版本
pear version


可看到 PEAR Version: 1.10.16
可看到 PHP Version: 8.4.16
可看到 Zend Engine Version: 4.4.16
可看到 Running on: Linux 000 6.12.63+deb13-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.63-1 (2025-12-30) x86_64




如果要安裝其他元件,可以搜尋看看有無對應的套件
apt-cache search php8.4* | grep php




修改 php.ini 防跨目錄/路徑攻擊
sed -i 's@^;*cgi.fix_pathinfo=.*@cgi.fix_pathinfo=0@' /etc/php/8.4/fpm/php.ini


檢查
grep cgi.fix_pathinfo /etc/php/8.4/fpm/php.ini


你應該看到 cgi.fix_pathinfo=0



設置系統預設的PHP版本
update-alternatives --list php


update-alternatives --set php /usr/bin/php8.4


update-alternatives --config php


重啟PHP
systemctl restart php8.4-fpm




---------------------------------------
確認有安裝exif、gmp、imagick、redis
---------------------------------------

apt install php8.4-exif -y

apt install imagemagick -y

apt install php8.4-imagick -y



重啟PHP
systemctl restart php8.4-fpm



已安裝的PHP擴展,確定已安裝了 exif、gmp、imagick、redis
/bin/php8.4 -m






------------------
修改php.ini
------------------

本教學只修改 PHP-FPM 的 php.ini,CLI 使用的是 /etc/php/8.4/cli/php.ini
vi /etc/php/8.4/fpm/php.ini


使用Xshell 8軟體上面的選項,編輯 -> 尋找 -> 尋找目標,將能快速找到以下這些要修改的地方

停用危險函數
搜尋 
disable_functions =

修改为,請注意:部分套件(如 Composer、queue、worker)可能需要 exec / proc_open,請依實際需求調整
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,pcntl_exec




搜尋以下這些,並修改它們的值

max_execution_time = 300

max_input_time = 180

memory_limit = 512M




顯示PHP程式錯誤,正式運作的論壇通常是 Off 關閉狀態
display_errors = Off


post_max_size = 100M

upload_max_filesize = 100M

max_file_uploads = 100

default_socket_timeout = 180



ESC儲存並離開
:wq




重啟PHP
systemctl restart php8.4-fpm




瀏覽PHP的版本,確定你是安裝PHP 8.4
php -v



開機啟動PHP8.4
systemctl enable php8.4-fpm


啟動PHP8.4
systemctl start php8.4-fpm


瀏覽狀態
systemctl status php8.4-fpm



重開機
reboot


重開機後,確認PHP有自動啟動
systemctl status php8.4-fpm

Create an account or sign in to comment

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.