看網上總結的亂七八糟的, 始終都不怎麽靠譜,這年頭還有人拿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都不會涼。