1.SSH连接服务器,执行cd oneinstack,再执行 ./uninstall.sh 输入 5 回车 接着 y 回车 卸载已经安装的PHP。Image
2.进入/root/oneinstack/include目录,找到要安装的PHP版本对应的文件打开,比如要安装PHP8.1.x则打开php-8.1.sh,在--with-zlib后面添加--with-webp(有两处):Image
./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ --with-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib --with-webp \ --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ --enable-sysvsem ${php81_with_curl} --enable-mbregex \ --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php81_with_openssl} \ --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options} else ./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \ --with-config-file-scan-dir=${php_install_dir}/etc/php.d \ --with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \ --with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib --with-webp \ --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \ --enable-sysvsem ${php81_with_curl} --enable-mbregex \ --enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php81_with_openssl} \ --with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \ --with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options}修改后如图:Image
3.进入/root/oneinstack/src目录,删除所有包含要安装PHP版本的文件夹和文件,如本教程要安装PHP8.1则删除php-8.1.12和php-8.1.12.tar.gz。Image
Image
4.执行cd ~/oneinstack 命令返回oneinstack目录,再执行./install.sh进入安装流程,除了Do you want to install PHP? : 输入y回车,然后输入要安装的PHP版本序号,其他的都输入n或0跳过,如下:Image
Please input SSH port(Default: 22):回车
Do you want to install Web server? : n
Do you want to install Database? : n
Do you want to install PHP? : y
Please select a version of the PHP:
1. Install php-5.3
2. Install php-5.4
3. Install php-5.5
4. Install php-5.6
5. Install php-7.0
6. Install php-7.1
7. Install php-7.2
8. Install php-7.3
9. Install php-7.4
10. Install php-8.0
11. Install php-8.1
12. Install php-8.2
Please input a number:(Default 7 press Enter) 11
Do you want to install opcode cache of the PHP? : y
Please select a opcode cache of the PHP:
1. Install Zend OPcache
2. Install APCU
Please input a number:(Default 1 press Enter) 1
Please select PHP extensions:
0. Do not install
1. Install zendguardloader(PHP<=5.6)
2. Install ioncube
3. Install sourceguardian(PHP<=7.2)
4. Install imagick
5. Install gmagick
6. Install fileinfo
7. Install imap
8. Install ldap
9. Install phalcon(PHP>=5.5)
10. Install yaf(PHP>=7.0)
11. Install redis
12. Install memcached
13. Install memcache
14. Install mongodb
15. Install swoole
16. Install xdebug(PHP>=5.5)
Please input numbers:(Default '4 11 12' press Enter) 0
Do you want to install Nodejs? : n
Do you want to install Pure-FTPd? : n
Do you want to install phpMyAdmin? : n
Do you want to install redis-server? :n如果安装PHP提示“No package 'libwebp' found ”如图:Image
则根据《安装PHP提示 No package 'libWebP' found 的解决方法》安装好libwebp后重新执行 ./install.sh 按照上面的步骤操作。安装完PHP,再在浏览器访问 IP/phpinfo.php 找到gd可以看到已经有 WebP Support enable,说明已经启用对WebP图片格式的支持。Image