需要收編的網站中有古董,在php不支援的狀況下就只能自己編譯後自己安裝了
這次要處理的是在plesk中,最低版本只有php7.3,需要多加上php5.6來用
查找了一下資料,發現寫到編譯重點,雖然寫得簡單
https://docs.plesk.com/zh-TW/obsidian/administrator-guide/%E4%B8%BB%E6%A9%9F/php-%E7%AE%A1%E7%90%86/%E6%B7%BB%E5%8A%A0%E8%87%AA%E8%A8%82%E7%9A%84-php-%E7%89%88%E6%9C%AC-linux.75356/
糾結一番後搞定了,整理一下我執行的順序
安裝編譯的必要套件
# apt-get install build-essential && apt-get install libxml2-dev
上面是debian,如果是centos系列的用這個
# yum install gcc -y && yum install libxml2-devel -y
去PHP官網 https://www.php.net/releases/ 下載版本
# wget https://www.php.net/distributions/php-5.6.40.tar.gz
# tar -zxvf php-5.6.40.tar.gz
進入目錄
# cd php-5.6.40
我打算把東西比照plesk方式去安裝在 /opt/plesk/php/5.6.40
開始編譯
# ./configure --prefix /opt/plesk/php/5.6.40 --enable-fpm --with-fpm-group=www-data
# make
# make install
make install在編譯完成後,會產出一些晚點會用到的東西,裡面會有對應資料。
Installing shared extensions: /opt/plesk/php/5.6.40/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary: /opt/plesk/php/5.6.40/bin/
Installing PHP CLI man page: /opt/plesk/php/5.6.40/php/man/man1/
Installing PHP FPM binary: /opt/plesk/php/5.6.40/sbin/
Installing PHP FPM config: /opt/plesk/php/5.6.40/etc/
Installing PHP FPM man page: /opt/plesk/php/5.6.40/php/man/man8/
Installing PHP FPM status page: /opt/plesk/php/5.6.40/php/php/fpm/
Installing PHP CGI binary: /opt/plesk/php/5.6.40/bin/
Installing PHP CGI man page: /opt/plesk/php/5.6.40/php/man/man1/
Installing build environment: /opt/plesk/php/5.6.40/lib/php/build/
Installing header files: /opt/plesk/php/5.6.40/include/php/
Installing helper programs: /opt/plesk/php/5.6.40/bin/
program: phpize
program: php-config
Installing man pages: /opt/plesk/php/5.6.40/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /opt/plesk/php/5.6.40/lib/php/
[PEAR] Archive_Tar - installed: 1.4.4
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.4.3
[PEAR] PEAR - installed: 1.10.7
Wrote PEAR system config file at: /opt/plesk/php/5.6.40/etc/pear.conf
You may want to add: /opt/plesk/php/5.6.40/lib/php to your php.ini include_path
/root/php-5.6.40/build/shtool install -c ext/phar/phar.phar /opt/plesk/php/5.6.40/bin
ln -s -f phar.phar /opt/plesk/php/5.6.40/bin/phar
Installing PDO headers: /opt/plesk/php/5.6.40/include/php/ext/pdo/
把ini檔案複製過去
# cp php.ini-development /opt/plesk/php/5.6.40/etc/php.ini
(參考指令 plesk bin php_handler –help)
向plesk註冊一個 FPM
# plesk bin php_handler --add -displayname 5.6.40-fpm -path /opt/plesk/php/5.6.40/sbin/php-fpm -phpini /opt/plesk/php/5.6.40/etc/php.ini -type fpm -id 5.6.40-fpm-custom -clipath /opt/plesk/php/5.6.40/bin/php -service PHP5.6.40-FPM -poold /opt/plesk/php/5.6.40/etc/php-fpm.d
看到回應 The new PHP handler with the id “5.6.40-fpm-custom” was successfully registered. 就是成功了。如果有錯誤就是照著錯誤指示去改
可以用 plesk bin php_handler –list 來看目前上面裝了哪些
移除用 plesk bin php_handler –remove -id ID名