Jack Posted May 23, 2024 Share Posted May 23, 2024 (edited) ----------------------------- 安裝sury.org的PHP源 ----------------------------- 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 upgrade -y apt dist-upgrade -y apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates apt install php-pear 瀏覽pear版本 pear version apt install php8.3-{fpm,cli,mysql,curl,gd,mbstring,xml,zip,imap,soap,gmp,bcmath,redis} -y 如果要安裝其他元件,可以搜尋看看有無對應的套件 apt-cache search php8.3* | grep php 修改 php.ini 防止跨目录攻击 sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/8.3/fpm/php.ini 設置系統預設的PHP版本 update-alternatives --list php update-alternatives --set php /usr/bin/php8.3 update-alternatives --config php 重啟PHP systemctl restart php8.3-fpm --------------------------------------- 安裝redis、安裝exif、安裝imagick --------------------------------------- apt install redis apt install php-redis apt install exif apt install imagemagick ldconfig /usr/local/lib apt install php-imagick 重啟PHP systemctl restart php8.3-fpm 瀏覽已安裝的PHP擴展,已有exif、gmp、imagick、redis /bin/php8.3 -m ------------------ 修改php.ini ------------------ vi /etc/php/8.3/fpm/php.ini 使用Xshell 7 SSH軟體上面的選項,編輯 -> 尋找 -> 尋找目標,將能快速找到以下這些要修改的地方 停用危險函數 搜尋 disable_functions = 修改为 disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,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.3-fpm 瀏覽PHP的版本,確定是安裝PHP 8.3 php -v 開機啟動PHP8.3 systemctl enable php8.3-fpm 啟動PHP8.3 systemctl start php8.3-fpm 瀏覽狀態 systemctl status php8.3-fpm 重開機 reboot 瀏覽狀態,確認重開機後,PHP有自動啟動 systemctl status php8.3-fpm 按 ctrl + z 停止 Edited May 24, 2024 by Jack Link to comment Share on other sites More sharing options...
Jack Posted July 5, 2024 Author Share Posted July 5, 2024 (edited) 上面步驟,安裝PHP 8.3 在IPS論壇會跳出訊息 Invision Community 4.7.x 不支援/不支持 PHP 8.2、8.3、8.4 雖然我沒看出有啥大問題,但至少 widget 小部件/小工具 常常有幾個沒顯示 Edited July 5, 2024 by Jack Link to comment Share on other sites More sharing options...
Jack Posted July 5, 2024 Author Share Posted July 5, 2024 (edited) 安裝 PHP 8.1 後續的步驟,有出現 PHP 8.3 的地方,記得也要改為 8.1 ----------------------------- 安裝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 upgrade -y apt dist-upgrade -y apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates apt install php-pear 瀏覽pear版本 pear version apt install php8.1-{fpm,cli,mysql,curl,gd,mbstring,xml,zip,imap,soap,gmp,bcmath,redis} -y 如果要安裝其他元件,可以搜尋看看有無對應的套件 apt-cache search php8.1* | grep php 修改 php.ini 防止跨目录攻击 sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/8.1/fpm/php.ini 設置系統預設的PHP版本 update-alternatives --list php update-alternatives --set php /usr/bin/php8.1 update-alternatives --config php 重啟PHP systemctl restart php8.1-fpm --------------------------------------- 安裝redis、安裝exif、安裝imagick --------------------------------------- apt install redis -y apt install php-redis -y apt install exif -y apt install imagemagick -y ldconfig /usr/local/lib apt install php8.1-imagick -y 重啟PHP systemctl restart php8.1-fpm 瀏覽已安裝的PHP擴展,已有exif、gmp、imagick、redis /bin/php8.1 -m ------------------ 修改php.ini ------------------ vi /etc/php/8.1/fpm/php.ini 使用Xshell 7 SSH軟體上面的選項,編輯 -> 尋找 -> 尋找目標,將能快速找到以下這些要修改的地方 停用危險函數 搜尋 disable_functions = 修改为 disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,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.1-fpm 瀏覽PHP的版本,確定是安裝PHP 8.1 php -v 開機啟動PHP8.1 systemctl enable php8.1-fpm 啟動PHP8.1 systemctl start php8.1-fpm 瀏覽狀態 systemctl status php8.1-fpm 重開機 reboot 瀏覽狀態,確認重開機後,PHP有自動啟動 systemctl status php8.1-fpm 按 ctrl + z 停止 後續的步驟,有出現 PHP 8.3 的地方,記得也要改為 8.1 Edited July 5, 2024 by Jack Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now