deepin系统安装php8
一、deepin系统与php的版本
1.deepin系统的版本 --社区版(20.8)

2.php的版本 -- PHP 8.1.11 (cli)

二、下载php的源码包
1.官网下载地址
https://www.php.net/releases/

2.选择下载PHP的版本
# 下载下面的php源码包
PHP 8.1.11 (tar.gz)
sha256: 3660e8408321149f5d382bb8eeb9ea7b12ea8dd7ea66069da33f6f7383750ab2
三、先安装php的扩展包
1.安装PHP的基础扩展包
$ sudo apt-get install -y gcc autoconf automake libtool cmake m4 bison re2c

2.安装PHP的依赖扩展包
$ sudo apt-get -y install libwebp-dev libjpeg-dev libxpm-dev libzip-dev libxslt1-dev libmcrypt-dev libsqlite3-dev libcurl4-openssl-dev libssl-dev libfreetype6-dev

3.安装jpeg格式文件的支持程序
# 说明:之前没有安装,在测试laravel框架的验证码时,就过不去,使得要重新安装php
# 安装后,就可以很好地支持php地gd模块地扩展
$ tar -zxvf jpegsrc.v9b.tar.gz
$ cd jpeg-9b
$ ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
$ sudo make && sudo make install
四、安装php源码包
1.解压并进入php源码包
# 解压源码包
$ tar -zxvf php-8.1.11.tar.gz
# 进入源码包
$ cd php-8.1.11/

2.php的配置
# php的配置
# 注意:–with-gd 改变为 –enable-gd(是否启用扩展) 和 –with-external-gd (使用外部 libgd,而不是捆绑的)
$ ./configure --prefix=/usr/local/php/php8.1 --with-config-file-path=/usr/local/php/php8/phpconfig --enable-mbstring --with-openssl --enable-ftp --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --without-pear --enable-sockets --enable-bcmath --enable-fpm --enable-xml --enable-sockets --with-zlib --with-iconv --enable-soap --enable-pcntl --enable-cli --with-curl --enable-gd --with-external-gd --with-jpeg=/usr/local/jpeg/ --with-external-pcre

3.解决配置不成功问题
a.No package 'libpcre2-8' found

#1. No package 'libpcre2-8' found 解决方案
http://www.pcre.org/ --下载地址
https://master.dl.sourceforge.net/project/pcre/pcre2/10.34/pcre2-10.34.tar.bz2?viasf=1 --浏览器输入这个地址,就可以下载
$ tar xjvf pcre2-10.34.tar.bz2
$ cd pcre2-10.34
$ ./configure --prefix=/usr/local/pcre2 \
--enable-pcre2-16 \
--enable-pcre2-32 \
--enable-jit \
--enable-jit-sealloc
$ sudo make && sudo make install
$ export PKG_CONFIG_PATH=/usr/local/pcre2/lib/pkgconfig/
b.之前安装PHP遇到的其他问题
#2. No package 'libpng' found
# sudo apt-get install libpng-dev
#3. No package 'oniguruma' found方案:
Oniguruma是一个新式灵活的正则表达式库,mbstring的正则表达式处理功能对它有依赖性。
编译安装
$ git clone https://github.com/kkos/oniguruma.git
$ cd oniguruma/
# 生成 configure
$ ./autogen.sh
# 检测
$ ./configure --prefix=/usr/local
# 编译及安装
$ sudo make && sudo make install
#4. No package 'gdlib' found
sudo apt-get install libgd-dev
4.php配置成功

5.php的编译与编译安装
# php的编译与编译安装
$ sudo make && sudo make install
-- 编译安装较慢,需要耐心等待...(我这里使用了10分钟)
-- 安装成功,记住以下配置


6.测试php是否安装成功
# 使用绝对路径
$ /usr/local/php/php8.1/bin/php -v
# 使用相对路径
$ cd /usr/local/php/php8.1/bin
$ ./php -v

五、下一篇内容
-- php与php-fpm的软连接