1.安装依赖包

yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers  libxslt libxslt-devel libzip

2.下载php7安装

  • 这里以php7.3为例,官网下载地址:https://secure.php.net/get/php-7.3.0.tar.gz/from/a/mirror
wget http://cn2.php.net/distributions/php-7.3.0.tar.gz

3.解压、编译安装

tar zxvf php-7.3.0.tar.gz
cd php-7.3.0
#配置
./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
 --with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
 --with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
#编译
make
#安装
make install
  • 编译中遇到的错误
1.Libzip 版本过低或提示reinstall解决方法
yum remove libzip -y

2.configure: error: off_t undefined; check your library configuration
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf&&ldconfig -v

3./usr/local/include/zip.h:59:21: 致命错误:zipconf.h:没有那个文件或目录
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

4.配置

  • 在之前编译的源码包中,找到 php.ini-production,复制到/usr/local/php下,并改名为php.ini
[root@MiWiFi-R3P-srv php-7.3.0]# pwd
/usr/local/php-7.3.0
[root@MiWiFi-R3P-srv php-7.3.0]# cp php.ini-production /usr/local/php/etc/php.ini
  • 显示错误信息
vim /usr/local/php/php.ini 
修改display_errors = On
  • 复制启动脚本
[root@MiWiFi-R3P-srv fpm]# pwd
/usr/local/php-7.3.0/sapi/fpm
[root@MiWiFi-R3P-srv fpm]# cp init.d.php-fpm /etc/init.d/php-fpm 
[root@MiWiFi-R3P-srv fpm]# chmod a+x /etc/init.d/php-fpm

[root@MiWiFi-R3P-srv etc]# pwd
/usr/local/php/etc
[root@MiWiFi-R3P-srv etc]# cp php-fpm.conf.default php-fpm.conf
[root@MiWiFi-R3P-srv etc]# vim php-fpm.conf
修改去掉 pid = run/php-fpm.pid 前面的分号

[root@MiWiFi-R3P-srv php-fpm.d]# pwd
/usr/local/php/etc/php-fpm.d
[root@MiWiFi-R3P-srv php-fpm.d]# cp www.conf.default www.conf

版权声明:本文为zhangjianqiang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zhangjianqiang/p/10145233.html