php
最后更新于:2022-04-02 02:34:36
[TOC]
## 安装依赖
yum
```
yum install gcc libxml2-devel cmake ncurses-devel perl-Data-Dumper libaio libxml2 openssl openssl-devel bzip2 bzip2-devel libcurl-devel libcurl libjpeg-devel libpng libpng-devel freetype-devel gmp-devel readline-devel libxslt libxslt-devel libmcrypt libmcrypt-devel oniguruma oniguruma-devel libzip libzip-devel
```
## php 编译 为了提交编译效率,可先编译依赖较少的模块,openssl 与 GD 库可进行模块编译 ``` ./configure --prefix=/usr/local/php \ --with-openssl \ --with-mysqli --with-pdo-mysql \ --enable-mbstring \ --with-zlib \ --enable-sockets \ --with-curl \ --with-pcre-regex \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-opcache \ --disable-maintainer-zts \ // 可选 --with-config-file-path=/etc/php/ \ //默认 /usr/local/php/lib --with-config-file-scan-dir=/etc/php/php.d \ //默认 空 // nginx 添加一下编译选项 --enable-fpm // apache 添加一下编译选项 --with-apxs2=/usr/local/apache2/bin/apxs ``` > 线程安全则扩展目录为`no-debug-zts-20131226` > 非线程安全则扩展目录为`no-debug-no-zts-20131226` ### 修改配置 ``` > cd /usr/local/src/ > cp php.ini-development /usr/local/php/lib/php.ini // nginx 需要使用 php-fpm > cd /usr/local/php > cp etc/php-fpm.conf.default etc/php-fpm.conf > vi etc/php-fpm.conf user = www group = www //如不存在www,则添加 www 用户与群 > groupadd www > useradd -g www www ``` ### 启动/停止 php-fpm ``` /usr/local/php/sbin/php-fpm killall php-fpm ``` ## 问题 ### 某个 xxx.h 没有找到 如没找到 easy.h ``` > find / -name easy.h /data/home/bigant/curl-master/include/curl/easy.h > cp -R /home/bigant/ww/curl-master/include/curl /usr/local/include/ 编译带路径 --with-curl=/usr/local ``` 如果是国产化机器 ``` find / -name easy.h sudo mkdir -p /usr/include/aarch64-linux-gnu/curl/include/curl sudo ln -s /usr/include/aarch64-linux-gnu/curl/easy.h /usr/include/aarch64-linux-gnu/curl/include/curl 或 ln -s /usr/include/aarch64-linux-gnu/curl /usr/include/ ```
';
apt -编译依赖
``` apt-get install \ build-essential \ gcc \ g++ \ autoconf \ bison \ pkg-config \ re2c \ make \ // 需要so文件的 apt install \ libiconv-hook-dev \ libmcrypt-dev \ libxml2-dev \ libjpeg8-dev \ libssl-dev \ libssl-doc \ libldb-dev \ libldap2-dev \ libbz2-dev \ libjpeg-dev \ libgmp-dev \ libreadline6-dev \ libxslt1-dev \ libzip-dev \ libldap-2.4-2 \ libldap2-dev \ libcurl-openssl-dev \ libcurl4-openssl-dev \ ```## php 编译 为了提交编译效率,可先编译依赖较少的模块,openssl 与 GD 库可进行模块编译 ``` ./configure --prefix=/usr/local/php \ --with-openssl \ --with-mysqli --with-pdo-mysql \ --enable-mbstring \ --with-zlib \ --enable-sockets \ --with-curl \ --with-pcre-regex \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-opcache \ --disable-maintainer-zts \ // 可选 --with-config-file-path=/etc/php/ \ //默认 /usr/local/php/lib --with-config-file-scan-dir=/etc/php/php.d \ //默认 空 // nginx 添加一下编译选项 --enable-fpm // apache 添加一下编译选项 --with-apxs2=/usr/local/apache2/bin/apxs ``` > 线程安全则扩展目录为`no-debug-zts-20131226` > 非线程安全则扩展目录为`no-debug-no-zts-20131226` ### 修改配置 ``` > cd /usr/local/src/ > cp php.ini-development /usr/local/php/lib/php.ini // nginx 需要使用 php-fpm > cd /usr/local/php > cp etc/php-fpm.conf.default etc/php-fpm.conf > vi etc/php-fpm.conf user = www group = www //如不存在www,则添加 www 用户与群 > groupadd www > useradd -g www www ``` ### 启动/停止 php-fpm ``` /usr/local/php/sbin/php-fpm killall php-fpm ``` ## 问题 ### 某个 xxx.h 没有找到 如没找到 easy.h ``` > find / -name easy.h /data/home/bigant/curl-master/include/curl/easy.h > cp -R /home/bigant/ww/curl-master/include/curl /usr/local/include/ 编译带路径 --with-curl=/usr/local ``` 如果是国产化机器 ``` find / -name easy.h sudo mkdir -p /usr/include/aarch64-linux-gnu/curl/include/curl sudo ln -s /usr/include/aarch64-linux-gnu/curl/easy.h /usr/include/aarch64-linux-gnu/curl/include/curl 或 ln -s /usr/include/aarch64-linux-gnu/curl /usr/include/ ```