下载源码包并解压

[root@blog src]# wget https://www.php.net/distributions/php-7.3.3.tar.gz
[root@blog src]# tar xvf php-7.3.3.tar.gz

创建用户 php-fpm,然后 ./configure,最后 make && make install(如果遇到问题,请看文章最后一段的 可能遇到的问题 的内容)

[root@blog src]# cd php-7.3.3/
[root@blog php-7.3.3]# useradd -s /sbin/nologin php-fpm
[root@blog php-7.3.3]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm
[root@blog php-7.3.3]# make && make install

把 php-fpm 命令添加到环境变量,修改 php-fpm 配置文件,启动 php-fpm

[root@blog php-7.3.3]# cd /usr/local/php-fpm/sbin/
[root@blog sbin]# vim /etc/profile
  export PATH=$PATH:/usr/local/php-fpm/sbin
[root@blog sbin]# source /etc/profile
[root@blog sbin]# php-fpm -v
PHP 7.3.3 (fpm-fcgi) (built: Apr  3 2019 01:37:21)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
[root@blog sbin]# cd /usr/local/src/php-7.3.3/
[root@blog php-7.3.3]# cp php.ini-production /usr/local/php-fpm/etc/php.ini
[root@blog php-7.3.3]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@blog php-7.3.3]#  vim /usr/local/php-fpm/etc/php-fpm.conf
  [global]
  pid = /usr/local/php-fpm/var/run/php-fpm.pid
  error_log = /usr/local/php-fpm/var/log/php-fpm.log
  [www]
  listen = /tmp/php-fcgi.sock
  listen.mode = 666
  user = php-fpm
  group = php-fpm
  pm = dynamic
  pm.max_children = 50
  pm.start_servers = 20
  pm.min_spare_servers = 5
  pm.max_spare_servers = 35
  pm.max_requests = 500
  rlimit_files = 1024
[root@blog php-7.3.3]# chmod 755 /etc/init.d/php-fpm
[root@blog php-7.3.3]# chkconfig --add php-fpm
[root@blog php-7.3.3]# chkconfig php-fpm on
[root@blog php-7.3.3]# systemctl start php-fpm
[root@blog php-7.3.3]# ps -aux | grep php
root      8261  0.1  1.2 255752 12336 ?        Ss   01:42   0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)
php-fpm   8262  0.0  1.0 255752 10960 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8263  0.0  1.0 255752 10964 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8264  0.0  1.0 255752 10964 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8265  0.0  1.0 255752 10968 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8266  0.0  1.0 255752 10968 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8267  0.0  1.0 255752 10968 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8268  0.0  1.0 255752 10976 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8269  0.0  1.0 255752 10968 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8270  0.0  1.0 255752 10972 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8271  0.0  1.0 255752 10976 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8272  0.0  1.0 255752 10980 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8273  0.0  1.0 255752 10976 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8274  0.0  1.0 255752 10976 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8275  0.0  1.0 255752 10976 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8276  0.0  1.0 255752 10976 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8277  0.0  1.0 255752 10976 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8278  0.0  1.0 255752 10980 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8279  0.0  1.0 255752 10980 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8280  0.0  1.0 255752 10980 ?        S    01:42   0:00 php-fpm: pool www
php-fpm   8281  0.0  1.0 255752 10980 ?        S    01:42   0:00 php-fpm: pool www
root      8283  0.0  0.2 112724  2300 pts/1    S+   01:43   0:00 grep --color=auto php

可能遇到的问题

问题1:
configure: error: no acceptable C compiler found in $PATH
[root@blog php-7.3.3]# yum -y install gcc

问题2:
configure: error: libxml2 not found. Please check your libxml2 installation.
[root@blog php-7.3.3]# yum -y install libxml2-devel.x86_64

问题3:
configure: error: Cannot find OpenSSL's <evp.h>
[root@blog php-7.3.3]# yum -y install openssl-devel.x86_64

问题4:
checking for cURL 7.10.5 or greater... configure: error: cURL version 7.10.5 or later is required to compile php with cURL support
[root@blog php-7.3.3]# yum -y install libcurl-devel

问题5:
configure: error: jpeglib.h not found.
[root@blog php-7.3.3]# yum -y install libjpeg-turbo-devel.x86_64

问题6:
configure: error: png.h not found.
[root@blog php-7.3.3]# yum -y install libpng-devel.x86_64

问题7:
configure: error: freetype-config not found.
[root@blog php-7.3.3]# yum -y install freetype-devel.x86_64

问题8:
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
[root@blog php-7.3.3]# yum -y install libicu-devel

问题9:
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
[root@blog php-7.3.3]# yum -y install glibc-headers gcc-c++

问题10:
configure: error: Cannot find ldap.h
[root@blog php-7.3.3]# yum -y install openldap openldap-devel

问题11:
configure: error: Cannot find ldap libraries in /usr/lib.
[root@blog php-7.3.3]# cp -frp /usr/lib64/libldap* /usr/lib/

问题12:
configure: error: Please reinstall the libzip distribution
[root@blog php-7.3.3]# yum install -y libzip-devel

问题13:
checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
[root@blog php-7.3.3]# yum -y remove libzip
[root@blog php-7.3.3]# cd /usr/local/src/
[root@blog src]# wget https://nih.at/libzip/libzip-1.2.0.tar.gz
[root@blog src]# tar -zxvf libzip-1.2.0.tar.gz
[root@blog src]# cd libzip-1.2.0
[root@blog libzip-1.2.0]# ./configure
[root@blog libzip-1.2.0]# make && make install
[root@blog libzip-1.2.0]# cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
[root@blog php-7.3.3]# echo '/usr/local/lib64
> /usr/local/lib
> /usr/lib
> /usr/lib64'>>/etc/ld.so.conf
[root@blog php-7.3.3]# ldconfig -v

到此,php7.3 源码包安装完成!


文章作者: Runfa Li
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Linux 小白鼠
Linux Linux php php7 php7.3
觉得文章不错,打赏一点吧,1分也是爱~
打赏
微信 微信
支付宝 支付宝