Loading... ## 0x00 配置 开发板: Raspberry Pi 3B 系统: Raspbian 2019-04-08 stretch ## 0x01 下载源码 2019 年 5 月最新的 PHP 7.2 版本号是 7.2.18 [PHP 7.2.18 Source code](https://www.php.net/distributions/php-7.2.18.tar.gz) ```bash wget https://www.php.net/distributions/php-7.2.18.tar.gz tar zxvf php-7.2.18.tar.gz ``` ## 0x02 安装依赖包 这里包含了依赖包以及开发工具 ```bash apt install libkrb5-dev \ libc-client2007e \ libc-client2007e-dev \ libcurl4-openssl-dev \ libbz2-dev \ libjpeg-dev \ libmcrypt-dev \ libxslt1-dev \ libxslt1.1 \ libpq-dev \ libgmp-dev \ libreadline-dev \ build-essential \ git \ make ``` ## 0x03 建立库文件的软链接 在 Raspbian 中编译 PHP 的时候会出现找不到某些库的问题,但实际上已经安装了这些库,只需要建立相应的软链接即可 ```bash mkdir /usr/c-client/ ln -s /usr/lib/libc-client.a /usr/c-client/ mkdir /usr/kerberos ln -s /usr/lib/arm-linux-gnueabihf/mit-krb5/* /usr/kerberos ``` ## 0x04 编译安装 首先进行配置,指定安装位置,配置文件位置以及需要安装的模块等 ```bash ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/etc \ --with-zlib-dir \ --with-freetype-dir \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ --enable-calendar \ --with-curl \ --with-zlib \ --with-gd \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --enable-exif \ --enable-bcmath \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-pdo-mysql \ --with-mysqli \ --with-mysql-sock=/var/run/mysqld/mysqld.sock \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --with-openssl \ --with-fpm-user=www-data \ --with-fpm-group=www-data \ --with-libdir=/usr/lib/arm-linux-gnueabihf \ --enable-ftp \ --with-imap \ --with-imap-ssl \ --with-kerberos \ --with-gettext \ --with-xmlrpc \ --with-xsl \ --enable-opcache \ --enable-fpm \ --disable-debug \ --enable-shared \ --with-iconv \ --with-cdb \ --enable-dom \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --with-openssl-dir \ --with-png-dir \ --enable-gd-jis-conv \ --with-gmp \ --enable-json \ --enable-mbregex-backtrack \ --with-libmbfl \ --with-onig \ --enable-pdo \ --enable-session \ --with-readline \ --enable-shmop \ --enable-simplexml \ --enable-sysvmsg \ --enable-wddx \ --enable-mysqlnd-compression-support \ --with-pear ``` make 命令的 -j 参数用于指定编译时使用的线程数,根据开发板配置自行指定 这个过程会非常漫长 ```bash make -j 4 make install ``` ## 0x05 配置 php-fpm 复制默认配置文件 ```bash cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf ``` 运行 php-fpm ```bash /usr/local/php/sbin/php-fpm ``` 最后修改:2022 年 01 月 03 日 © 允许规范转载