1、准备好自己的linux环境或者虚拟机环境
准备好需要的插件
yum -y install libxml2
yum -y install libxml2-devel
yum -y install openssl
yum -y install openssl-devel
yum -y install curl
yum -y install curl-devel
yum -y install libjpeg
yum -y install libjpeg-devel
yum -y install libpng
yum -y install libpng-devel
yum -y install freetype
yum -y install freetype-devel
yum -y install pcre
yum -y install pcre-devel
yum -y install libxslt
yum -y install libxslt-devel
yum -y install bzip2
yum -y install bzip2-devel
2、进入linux环境中,建立 mkdir www ====>切换成 cd /www
3、 进入主题
下载 wget http://cn2.php.net/distributions/php-7.3.3.tar.gz(其他版本自己选择下载)
解压 tar -xzf php-7.3.3.tar.gz
改名称 mv php-7.3.3 php73
切换目录 cd php73
编译php
./configure --prefix=/usr/local/php73 \
--with-config-file-path=/usr/local/php73/etc \
--with-config-file-scan-dir=/usr/local/php7/etc/php.d \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
执行以上命令
如果编译肯定报错出现 。system libzip must be upgraded to version >= 0.11
请卸载 yum -y remove libzip-devel
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -xzf libzip-1.2.0.tar.gz
./configure
make
/================================/
再去执行 ./configure.......
----------------------------end-------------------------
出现以下则表示编译成功
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
然后执行:make
中间出现问题自己百度解决,编译是个漫长的过程,这时间内请挂机处理其他事,偶尔切换界面看下是否编译完成
如果出现这问题
====================================================================================
/www/php73/ext/iconv/iconv.c:1135: undefined reference to `libiconv_close'
ext/xmlrpc/libxmlrpc/.libs/encodings.o: In function `convert':
/www/php73/ext/xmlrpc/libxmlrpc/encodings.c:65: undefined reference to `libiconv_open'
/www/php73/ext/xmlrpc/libxmlrpc/encodings.c:72: undefined reference to `libiconv'
/www/php73/ext/xmlrpc/libxmlrpc/encodings.c:88: undefined reference to `libiconv_close'
/www/php73/ext/xmlrpc/libxmlrpc/encodings.c:88: undefined reference to `libiconv_close'
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
不要慌
vim Makefile(最好提前检查这句,没有就加上去,免得重新编译等待)
EXTRA_LIBS = ..... -lcrypt 在最后加上 -liconv,例如: EXTRA_LIBS = ..... -lcrypt -liconv 然后重新再次 make 即可,
=====================================================================================
最后执行 make install
当前页面复制
cp php.ini-development /usr/local/php73/lib/php.ini
cp /usr/local/php73/etc/php-fpm.conf.default /usr/local/php73/etc/php-fpm.conf
ln -s /usr/local/php73/sbin/php-fpm /usr/local/bin
groupadd www
useradd -g www www
cp /usr/local/php73/etc/php-fpm.d/www.conf.default /usr/local/php73/etc/php-fpm.d/www.conf
vi /usr/local/php73/etc/php-fpm.d/www.conf
#修改如下内容
user=www
group=www
root@lib]# /usr/local/bin/php-fpm
[root@lib]# yum install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be updated
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================
Updating:
net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k
Transaction Summary
=============================================================================================================================================================================
Upgrade 1 Package
Total download size: 306 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : net-tools-2.0-0.25.20131004git.el7.x86_64 1/2
Cleanup : net-tools-2.0-0.22.20131004git.el7.x86_64 2/2
Verifying : net-tools-2.0-0.25.20131004git.el7.x86_64 1/2
Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 2/2
Updated:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
Complete!
[root@ lib]# netstat -tln | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
[root@ lib]# netstat -tln | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
[root@izuf62e8zcq06j5cywzpsuz lib]# ps -aux | grep php
root 31853 0.0 0.6 224960 6448 ? Ss 15:35 0:00 php-fpm: master process (/usr/local/php73/etc/php-fpm.conf)
www 31854 0.0 0.5 224960 6004 ? S 15:35 0:00 php-fpm: pool www
www 31855 0.0 0.5 224960 6004 ? S 15:35 0:00 php-fpm: pool www
root 31935 0.0 0.0 112708 980 pts/0 S+ 15:36 0:00 grep --color=auto php
确认开启了php-fpm
[root@localhost ~]# vi /etc/profile export
PATH="$PATH:/usr/local/php73/bin"
[root@localhost ~]# source /etc/profile
[root@ lib]# php -v
PHP 7.3.12 (cli) (built: Jan 9 2021 15:13:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
出现这种现象,说明你的php已经写进了环境变量,助你ok!!