下载链接
依赖包
#yum install libxml2-devel libjpeg-devel libpng-devel freetype-devel sqlite-devel openldap openldap-devel --downloadonly --downloaddir=/home/hdlh/packages/php-rpm/
#rpm -ivh *.rpm --force --nodeps
#yum install libxml2-devel libjpeg-devel libpng-devel freetype-devel sqlite-devel openldap openldap-devel
解压
#tar xzvf php-7.2.30.tar.gz -C /tools/
编译安装
#cd /tools/php-7.2.30
#./configure --prefix=/tools/php7 --bindir=/usr/bin --sbindir=/usr/sbin --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-gd --with-jpeg-dir --with-png-dir --enable-zip --with-zlib --with-zlib-dir --with-gettext --with-ldap --enable-mbstring --with-pcre-dir --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-bcmath --enable-sockets -with-jpeg-dir -with-freetype-dir
#make && make install
7.4
#./configure --prefix=/project/php --bindir=/usr/bin --sbindir=/usr/sbin --enable-fpm --with-fpm-user=supervisor --with-fpm-group=supervisor --enable-gd --with-png --with-zip --with-zlib --with-zlib-dir --with-gettext --with-ldap --enable-mbstring --with-pcre-dir --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-bcmath --enable-sockets --with-jpeg -with-freetype
--prefix=/tools/php7 ###安装路径
--bindir=/usr/bin
--sbindir=/usr/sbin
--enable-fpm ###启用 fpm 扩展
--with-fpm-user=nginx ###设定 fpm 所属用户
--with-fpm-group=nginx ###设定 fpm 所属用户组
--with-gd ###启动 gd 图片操作扩展
--with-jpeg-dir ###开启对 jpeg 图片的支持
--with-png-dir ###开启对 png 图片的支持
--enable-zip ###启用 zip 压缩
--with-zlib 、 --with-zlib-dir ###启用对 zlib 支持
--with-freetype-dir ###开启 freetype
--enable-mbstring ###启用 mbstring 库
--with-pcre-dir ###开启 pcre
--enable-mysqlnd ###启用 mysqlnd 支持
--with-mysqli ###启用 mysqli 支持
--with-pdo-mysql ###启动 pdo 扩展
--enable-bcmath
--enable-sockets ###开启 socket
--with-mysqli=/tools/mysql-8.0.18/bin/mysql_config ###设定 mysql 配置文件路径(指向 mysql 安装目录)
编译报错
编译可能出现的错误
1,configure: error: Package requirements (libzip >= 0.11) were not met
libzip提示版本太低,yum自带的是0.10,需自行编译安装 libzip
#wget https://libzip.org/download/libzip-1.2.0.tar.gz
#tar -zxvf libzip-1.2.0.tar.gz
#cd libzip-1.2.0
#./configure
#make && make install
装完了之后找一下/usr/local/lib下有没有pkgconfig目录,有的话执行命令
#export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
指定PKG_CONFIG_PATH
2,configure: error: Cannot find ldap libraries in /usr/lib
#cp -frp /usr/lib64/libldap* /usr/lib/
3,configure: error: Package requirements (oniguruma) were not met
下载安装 rpm 包
http://down.24kplus.com/linux/oniguruma/oniguruma-6.7.0-1.el7.x86_64.rpm
http://down.24kplus.com/linux/oniguruma/oniguruma-devel-6.7.0-1.el7.x86_64.rpm
4,make install :
/usr/lib/x86_64-linux-gnu/liblber-2.4.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
#在PHP源码目录下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make即可
配置修改
#cp /tools/php7/etc/php-fpm.d/www.conf.default /tools/php7/etc/php-fpm.d/www.conf
#cp /tools/php7/etc/php-fpm.conf.default /tools/php7/etc/php-fpm.conf
#cp -a /tools/php-7.2.30/php.ini-production /tools/php7/etc/php.ini
用户权限
#useradd nginx -s /sbin/nologin
#chown -R nginx.nginx /tools/php-7
启动
#pkill php
#php-fpm -c /tools/php7/etc/php.ini
附
lnmp环境需要nginx打开php的location配置
location ~ \.php$ {
root /hdfs/project/xinhu;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}