(1) 下载php7.3源码包
(2)解压文件并安装
#进入/usr/local/src 目录 [root@iz25vpndgurz src]# tar -xf php-7.3.10.tar.gz [root@iz25vpndgurz src]# ll | grep php-7.3.10 drwxr-xr-x 17 mysql mysql 4096 Feb 22 16:27 php-7.3.10 -rw-r--r-- 1 root root 19590757 Oct 15 08:33 php-7.3.10.tar.gz #进入php目录 [root@iz25vpndgurz src]# cd php-7.3.10 #编译代码 [root@iz25vpndgurz src]# ./configure --prefix=/usr/local/php/php7.3 --with-config-file-path=/usr/local/php/php7.3/etc --with-mysqli=/usr/local/mysql5.5/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.5 --with-freetype-dir=/usr/local/freetype2.7.1 -enable-mbstring --enable-ftp --enable-fpm --with-curl --with-mhash --enable-zip --with-pcre-regex --with-gd --with-jpeg-dir -with-gettext --enable-xml --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-opcache --enable-maintainer-zts #创建php安装目录 mkdir -p /usr/local/php/php7.3 #make 安装 make && make install
解释说明:
--prefix php安装所在的目录
--with-config-file-path php配置文件所在目录
--with-mysqli
--with-pdo-mysql 数据库目录
安装完成截图:
/usr/local/php/php7.3/bin/phpize /usr/local/php/php7.3/bin/php-config
安装openssl扩展
进入目录 /usr/local/src/php-7.3.10/ext/openssl
1)将 config0.m4 更名为 config.m4
mv config0.m4 config.m4
2)执行phpize
/usr/local/php/php7.3/bin/phpize
3)编辑安装
./configure --with-php-config=/usr/local/php/php7.3/bin/php-config
4)安装完成
make && make install Libraries have been installed in: /usr/local/src/php-7.3.10/ext/openssl/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Build complete. Don't forget to run 'make test'. Installing shared extensions: /usr/local/php/php7.3/lib/php/extensions/no-debug-zts-20180731/
5)在php.ini中添加已生成的扩展 so 文件
vim /usr/local/php/php7.3/etc/php.ini extension=openssl.so
到此为止 openssl 安装完成。
安装php7.3遇到的问题及注意事项
1、php安装执行configure报错error: off_t undefined; check your library configuration
vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效
2、checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11问题解决
# cmake 和 cmake3都要安装
yum install -y cmake
yum install -y cmake3
wget https://libzip.org/download/libzip-1.5.0.tar.gz
tar -zxvf libzip-1.5*
cd libzip-1.5*
mkdir build && cd build && cmake3 .. && make && make install