看网上总结的乱七八糟的, 始终都不怎么靠谱,这年头还有人拿php跑soap玩posix、shmop? 编译这些烂玩意有什么意义。算了, 还是自己写一个吧。
配置apt
debian系统使用的是apt包管理, 不是yum, 自带的apt获取程序包镜像是境外的, 网速非常慢, 所以事先调整, 改为科大的景象
cd /etc/apt rm sources.list && touch sources.list && cat > sources.list
把下面内容ctrl+v粘贴进去
deb http://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb-src http://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb http://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb-src http://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb http://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb-src http://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb http://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware deb-src http://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
粘贴完毕后,alt+c强行退出来算是存储完成。之所以不用阿里云的镜像, 主要是阿里云最近几年不知道怎么了, 镜像经常崩。
上述问题搞定之后, 在科大ustc镜像把可用的库列表更新一下, 下载编译php之前的库
apt-get update && apt-get install wget autoconf libxml2-dev libsqlite3-dev libcurl4-openssl-dev libssl-dev libonig-dev libtidy-dev zlib1g-dev pkg-config libbz2-dev libpng-dev libxslt-dev libzip-dev gcc g++ make m4 lzip
接下来, 下载php的8.2.12
wget https://www.php.net/distributions/php-8.2.12.tar.gz tar zxf php-8.2.12.tar.gz && cd php-8.2.12
编译配置
用下方命令配置编译参数
只用swoole的
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \ --enable-mysqlnd \ --enable-phar \ --enable-xml \ --enable-bcmath \ --enable-mbregex \ --enable-mbstring \ --enable-intl \ --enable-gd \ --enable-pcntl \ --enable-ctype \ --enable-filter \ --enable-sockets \ --enable-exif \ --enable-session \ --with-bz2 \ --with-xsl \ --with-pdo-mysql=mysqlnd \ --with-iconv \ --with-zlib \ --with-curl \ --with-openssl=/usr/local/libressl \ --with-mhash \ --with-zip \ --with-gmp \ --with-libxml \ --disable-debug \ --disable-rpath \ --disable-opcache \ --disable-cgi \ --disable-short-tags \ --disable-posix \ --without-sqlite3 \ --without-pdo-sqlite \ --without-pcre-jit
如果是fpm版本的, 需要先建议专门用于运行fpm的名为www的用户和用户组:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \ --disable-debug \ --disable-rpath \ --enable-ctype \ --enable-filter \ --enable-phar \ --enable-exif \ --enable-session \ --enable-opcache \ --enable-mysqlnd \ --enable-xml \ --enable-bcmath \ --enable-mbregex \ --enable-mbstring \ --enable-intl \ --enable-gd \ --enable-pcntl \ --enable-sockets \ --with-bz2 \ --with-xsl \ --with-gmp \ --with-libxml \ --with-pdo-sqlite \ --with-curl \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-iconv \ --with-zlib \ --with-jpeg \ --with-freetype=/usr/local/freetype \ --with-freetype \ --with-openssl=/usr/local/libressl \ --with-mhash \ --with-zip \ --enable-fpm --with-fpm-user=www --with-fpm-group=www
剩下的就是根据需求编译swoole和redis
swoole配置
./configure --with-php-config=/usr/local/php/bin/php-config \ --enable-sockets \ --enable-openssl \ --enable-cares \ --enable-swoole-curl
redis配置
./configure --with-php-config=/usr/local/php/bin/php-config \ --enable-redis-igbinary \ --enable-redis-msgpack
php-redis扩展安装可以参考
https://www.wkwkk.com/articles/44b97536a7fa2d5e.html
删除不用的系统库文件
apt autoremove wget autoconf libxml2-dev libsqlite3-dev libcurl4-openssl-dev libssl-dev libonig-dev libtidy-dev zlib1g-dev pkg-config libbz2-dev libpng-dev libxslt-dev libzip-dev gcc g++ make m4 lzip
听说php凉了? 这话从2005年就开始,听的本人耳朵都起茧子了。php 73%的web市场占有率, 你凉了php都不会凉。