工作目錄:
mkdir -p ~/software/php
cd ~/software/php
【編譯安裝m4-1.4.20】
wget https://ftp.gnu.org/gnu/m4/m4-1.4.20.tar.gz --no-check-certificate
tar xf m4-1.4.20.tar.gz
cd m4-1.4.20
./configure
make
make install
ldconfig
cd ..
【編譯安裝autoconf-2.72】
wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.gz --no-check-certificate
tar xf autoconf-2.72.tar.gz
cd autoconf-2.72
./configure
make
make install
ldconfig
cd ..
【編譯安裝libtool-2.5.4】
wget https://ftp.gnu.org/gnu/libtool/libtool-2.5.4.tar.gz --no-check-certificate
tar xf libtool-2.5.4.tar.gz
cd libtool-2.5.4
./configure
make
make install
ldconfig
cd ..
【編譯安裝automake-1.18】
wget https://ftp.gnu.org/gnu/automake/automake-1.18.tar.gz --no-check-certificate
tar xf automake-1.18.tar.gz
cd automake-1.18
./configure
make
make install
ldconfig
cd ..
【編譯安裝pkg-config-0.29.2】
wget https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz --no-check-certificate
tar xf pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2
./configure --with-internal-glib
make
make install
ldconfig
cd ..
【編譯安裝Python-3.13.5.tar.xz】
特別注意:一定要加--enable-shared選項,把so庫編譯出來。python和其他軟件包不同,enable-shared選項的默認值是no。
wget https://www.python.org/ftp/python/3.13.5/Python-3.13.5.tar.xz --no-check-certificate
tar xf Python-3.13.5.tar.xz
cd Python-3.13.5
./configure --enable-shared
make
make install
ldconfig
cd ..
【編譯安裝libxml2-2.14.4】
wget https://github.com/GNOME/libxml2/archive/refs/tags/v2.14.4.tar.gz --no-check-certificate
mv v2.14.4.tar.gz libxml2-2.14.4.tar.gz
tar xf libxml2-2.14.4.tar.gz
cd libxml2-2.14.4
./autogen.sh
make
make install
ldconfig
cd ..
【編譯安裝sqlite-3.50.1】
wget https://sqlite.org/2025/sqlite-src-3500100.zip --no-check-certificate
unzip sqlite-src-3500100.zip
cd sqlite-src-3500100
./configure
make
make install
ldconfig
cd ..
sqlite3.c文件很大,有8.84MB,編譯大概需要500MB內存,RV1106G3晶片片內的256MB內存不夠用。
編譯前必須開啟swap虛擬內存:swapon /root/swapfile
不然內存會耗盡,提示gcc: fatal error: Killed signal terminated program cc1
編譯完成後可以關閉swap虛擬內存:swapoff /root/swapfile
編譯生成的sqlite3.o大小為5.19MB,sqlite3程序的大小為5.91MB。
[root@luckfox-rv1106 ~/bluetooth]# free -h
total used free shared buff/cache available
Mem: 215.4M 206.6M 2.8M 108.0K 6.0M 3.0M
Swap: 2.0G 310.0M 1.7G
【編譯安裝bzip2-1.0.8】
wget https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz --no-check-certificate
tar xf bzip2-1.0.8.tar.gz
cd bzip2-1.0.8
修改Makefile文件,CFLAGS=末尾加上-fPIC選項。
make
make install
ldconfig
cd ..
【編譯安裝libpsl-0.21.5】
wget https://github.com/rockdaboot/libpsl/releases/download/0.21.5/libpsl-0.21.5.tar.gz --no-check-certificate
tar xf libpsl-0.21.5.tar.gz
cd libpsl-0.21.5
./configure
make
make install
ldconfig
cd ..
【編譯安裝curl-8.14.1】
wget https://curl.se/download/curl-8.14.1.tar.gz --no-check-certificate
tar xf curl-8.14.1.tar.gz
cd curl-8.14.1
./configure --with-openssl
make
make install
ldconfig
cd ..
【編譯安裝libpng-1.6.49】
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.49.tar.gz
tar xf libpng-1.6.49.tar.gz
cd libpng-1.6.49
./configure
make
make install
ldconfig
cd ..
【編譯安裝cmake-4.0.3】
wget https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3.tar.gz --no-check-certificate
tar xf cmake-4.0.3.tar.gz
cd cmake-4.0.3
swapon /root/swapfile
./configure
make
make install
swapoff /root/swapfile
ldconfig
cd ..
【編譯安裝libjpeg-turbo-3.1.1】
(本軟件包的默認安裝目錄是/opt/libjpeg-turbo)
wget https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.1.1/libjpeg-turbo-3.1.1.tar.gz --no-check-certificate
tar xf libjpeg-turbo-3.1.1.tar.gz
cd libjpeg-turbo-3.1.1
cmake .
make
make install
cd ..
【編譯安裝freetype-2.13.3】
wget https://download.savannah.gnu.org/releases/freetype/freetype-2.13.3.tar.gz --no-check-certificate
tar xf freetype-2.13.3.tar.gz
cd freetype-2.13.3
./configure
make
make install
ldconfig
cd ..
【編譯安裝oniguruma-6.9.10】
wget https://github.com/kkos/oniguruma/releases/download/v6.9.10/onig-6.9.10.tar.gz --no-check-certificate
tar xf onig-6.9.10.tar.gz
cd onig-6.9.10
./configure
make
make install
ldconfig
cd ..
【編譯安裝postgresql-17.5】
https://zh.purasbar.com/post.php?t=32880
【編譯安裝tidy-5.8.0】
wget https://github.com/htacg/tidy-html5/archive/refs/tags/5.8.0.tar.gz --no-check-certificate
mv 5.8.0.tar.gz tidy-html5-5.8.0.tar.gz
tar xf tidy-html5-5.8.0.tar.gz
cd tidy-html5-5.8.0/build/cmake
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5
make
make install
cd ../../..
【編譯安裝php-8.4.8】
wget https://www.php.net/distributions/php-8.4.8.tar.gz --no-check-certificate
tar xf php-8.4.8.tar.gz
cd php-8.4.8
./configure --prefix=/opt/php-8.4.8 --with-apxs2=/opt/httpd-2.4.63/bin/apxs --enable-bcmath --enable-mbstring --with-bz2 --with-curl --with-gettext --with-mysqli --with-pdo-mysql --with-pgsql --with-pdo-pgsql --enable-gd --with-freetype --with-jpeg --with-openssl --with-tidy --with-zlib JPEG_CFLAGS="-I/opt/libjpeg-turbo/include" JPEG_LIBS="-L/opt/libjpeg-turbo/lib32 -ljpeg"
swapon /root/swapfile
make
make install
swapoff /root/swapfile
cd ..
本人編譯Zend/zend_execute.c這個文件花了43分鐘,而且至少用了280MB的內存。
一開始沒開swap虛擬內存,編譯到一半才開的。
【配置httpd-2.4.63和php-8.4.8】
vi /opt/httpd-2.4.63/conf/httpd.conf
找到DirectoryIndex index.html,加上index.php。
在文件末尾添加:
AddType application/x-httpd-php .php
vi /opt/httpd-2.4.63/htdocs/info.php
內容:
<?php phpinfo() ?>
測試配置:/opt/httpd-2.4.63/bin/httpd -t
重啟apache伺服器:/opt/httpd-2.4.63/bin/apachectl restart
(如果無法訪問網頁,那就多重啟幾次)
訪問:https://板子IP/info.php
可以看到phpinfo的界面,裏面顯示Loaded Configuration File為(none),即沒有加載php.ini文件。
從源碼目錄裏面複製過去:cp ~/software/php/php-8.4.8/php.ini-development /opt/php-8.4.8/lib/php.ini
重啟apache伺服器:/opt/httpd-2.4.63/bin/apachectl restart
查看phpinfo裏面Loaded Configuration File一欄,就可以看到成功加載了/opt/php-8.4.8/lib/php.ini文件。