- @TOC下载php
wget https://www.php.net/distributions/php-8.2.10.tar.gz
- 解压
tar -zxvf php-8.2.10.tar.gz
- 安装各种依赖,出现各种错误,就是查看当前config.log的日志,缺少各种依赖
apt install gcc
apt install pkg-config
apt install libxml2
apt install libsqlite3-dev
apt-get install zlib1g-dev
apt-get install libbz2-dev
apt-get install libcurl4-openssl-dev
apt-get install libssl-dev
apt install libffi-dev
apt install libpng-dev
apt install libpng-dev
apt install libwebp-dev
apt install libjpeg-dev
apt install libonig-dev
apt install libzip-dev
atp install gcc automake autoconf libtool make
- 预编译php
./configure --prefix=/usr/local/php --sysconfdir=/etc/php --with-openssl --with-zlib --with-bz2 --with-curl --enable-bcmath --enable-gd --with-webp --with-jpeg --with-mhash --enable-mbstring --with-imap-ssl --with-mysqli --enable-exif --with-ffi --with-zip --enable-sockets --with-pcre-jit --enable-fpm --with-pdo-mysql --with-freetype
# 解释:
./configure
--prefix=/usr/local/php #安装地址
--sysconfdir=/etc/php #设置文件地址
--with-openssl #启用ssl
--with-zlib
--with-bz2
--with-curl #启用curl(必开)
--enable-bcmath
--enable-gd
--with-webp
--with-jpeg
--with-mhash
--enable-mbstring #必开,很多需要用到
--with-imap-ssl
--with-mysqli #mysqli函数,如果用pdo,可以补开
--enable-exif
--with-ffi #支持外挂C程序
--with-zip
--enable-sockets #开启socket
--with-pcre-jit #开启jit
--enable-fpm #开启fpm模式(必开)
--with-pdo-mysql #支持mysql
--with-pdo-pgsql #支持pgsql
--enable-pcntl #多进程控制扩展,如果使用swoole,建议不加
-
编译成功
-
安装 开始安装时间:10:51 安装结束时间:10:59
make && make install
- 安装完成,各种配置路径
- 执行php -v
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
# 安装的php 在 /usr/lcoal/php
# 追加php安装路径
export PATH=$PATH:/usr/local/php/bin
# 再次执行
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/php/bin
php -v
10. 生成php.ini
cp php.ini-development /usr/local/php/lib/php.ini
- 撒花!!!结束!!!