php 7.3 在Centos6.x下的安装过程

分类:PHP |

提示unrecognized options: –with-mcrypt, –enable-gd-native-ttf

表示php7.3不支持这两个选项,

编译准备工作:

yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libzip

yum -y install gcc automake autoconf libtool make

yum -y install gcc gcc-c++ glibc

yum -y install pcre-devel updatedb

yum install -y cmake

yum install -y cmake3

yum install zlib-devel



正式编译:

./configure --prefix=/opt/php73/ --with-config-file-path=/etc/php73/ --with-libdir=lib64 --with-gd --with-iconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-curl --with-openssl --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite=shared --enable-xml --enable-pcntl --enable-mbregex --enable-mbstring --enable-bcmath --enable-inline-optimization --enable-zip --enable-ftp --enable-sockets --enable-shmop --enable-sysvsem --enable-sysvmsg --enable-sysvshm --disable-rpath --disable-debug --without-gdbm --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-maintainer-zts --enable-soap

make && make install



cp php.ini-production /opt/php73/etc/php.ini

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

cp /opt/php73/etc/php-fpm.d/www.conf.default /opt/php73/etc/php-fpm.d/www.conf

chmod 755 /etc/init.d/php-fpm

service php-fpm restart




相关资料:

编译PHP7.3

错误: 

Starting php-fpm /opt/php73/sbin/php-fpm: error while loading shared libraries: libzip.so.5: cannot open shared object file: No such file or directory

failed


#checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11


方法1:


检测到没有安装libzip5, 请先安装 libzip5,
1. 下载安装方法: wget http://rpmfind.net/linux/remi/enterprise/6/remi/x86_64/libzip5-1.5.1-1.el6.remi.x86_64.rpm
2. rpm安装: rpm -ivh libzip5-1.5.1-1.el6.remi.x86_64.rpm


方法2: 


#下载编译安装
wget https://libzip.org/download/libzip-1.3.0.tar.gz
tar -zxvf libzip-1.3.0.tar.gz
cd libzip-1.3.0
./configure
make && make install
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
报错configure: error: off_t undefined; check your library configuration
解决方案:
or
Starting php-fpm /opt/php73/sbin/php-fpm: error while loading shared libraries: libzip.so.5: cannot open shared object file: No such file or directory
failed
# 添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v
 
报错configure: error: Please reinstall the libzip distributio 或  configure: error: system libzip must be upgraded to version >= 0.11。
解决方案:
yum remove libzip -y
 
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
 
make && make install
 
# 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
 
报错/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory
解决方案:
 
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
 
 报错/package/php-7.3.7/ext/zip/php_zip.c:3318:48: error: ‘LIBZIP_VERSION’ undeclared (first use in this function)
解决方案:
重新正确安装 libzip
[root@BobServerStation twemproxy]# autoconf
 
configure.ac:8: error: Autoconf version 2.64 or higher is required
 
configure.ac:8: the top level
 
autom4te: /usr/bin/m4 failed with exit status: 63
 
Redis 扩展安装: 
git clone https://github.com/igbinary/igbinary.git 
whereis php 
phpize && ./configure CFLAGS="-O2 -g" --enable-igbinary --with-php-config=/opt/php73/bin/php-config 
make -j4 && make install 
git clone https://github.com/nicolasff/phpredis.git 
cd phpredis/ 
phpize && ./configure CFLAGS="-O2 -g" --enable-redis-igbinary --with-php-config=/opt/php73/bin/php-config && make -j4 && sudo make install 
php-config 
php --ini 
vim /usr/local/php/etc/php.ini 
ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/ 
ll 
yum install libtool 
查询当前版本
rpm -qf /usr/bin/autoconf
autoconf-2.63-5.1.el6.noarch
 
卸载当前版本
rpm -e --nodeps autoconf-2.63
 
安装最新版本
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz
tar zxvf autoconf-2.68.tar.gz
cd autoconf-2.68
./configure --prefix=/usr/
make && make install
 
查看当前版本
/usr/bin/autoconf -V
autoconf (GNU Autoconf) 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
 
至此,autoconf已升级到2.68。
安装memcahce 扩展: 
然后就去翻查了一下资料,pecl好像不支持安装memcache扩展。这样只能找其他办法解决了,在期间也踩了很多坑,后来找到了一个github上的可支持php7的memcache扩展
接下来就是安装步骤了:
拉去memcache扩展
cd /usr/local/src/
git clone https://github.com/websupport-sk/pecl-memcache
编译安装memcache扩展
cd pecl-memcache/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
Installing shared extensions:    /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/
上面已经安装完成memcache扩展,接下来把它加入php.ini中
vim  /etc/php.ini
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/"
extension = "memcache.so"
重启php-fpm使配置生效
/etc/init.d/php-fpm reload



安装 mcypt 扩展安装: ( https://pecl.php.net/package/mcrypt )

mcrypt 在 php7.1 就废弃了.

@since 4.0.2  @since 5.0 @deprecated 7.1

wget https://pecl.php.net/get/mcrypt-1.0.3.tgz

tar -xvf mcrypt-1.0.3.tgz

cd  mcrypt-1.0.3

/opt/php73/bin/phpize

./configure --with-php-config=/opt/php73/bin/php-config

make && make install