CentOS 7 安装PHP7.3.2 - 编译安装(并安装redis扩展)

版权声明:使用中有任何问题,可以留言。能解答尽量解答。 https://blog.csdn.net/liyyzz33/article/details/87881310

1 安装扩展包并更新系统内核

yum install epel-release -y
yum update

2 YUM安装PHP依赖组件(包含Nginx依赖):

yum -y install php-mcrypt libmcrypt-devel libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxslt libxslt-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib m4 autoconf gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel wget net-tools zip 

3 编译安装配置PHP
3.1 下载应用软件包
下载地址:http://www.php.net/downloads.php
php-7.3.2.tar.gz (sig) [18,954Kb]
3.2 解压应用软件包

tar -xvf php-7.3.2.tar.gz

3.3 编译

./configure --prefix=/opt/php/php7.3 \
--with-config-file-path=/opt/php/php7.3/etc \
--with-curl \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-openssl \
--with-pcre-regex \
--with-pdo-sqlite \
--with-pear \
--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 \
--enable-static \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--disable-debug \
--disable-fileinfo 

此过程如果出错可以参考下面我遇到错误的解决方法
3.4 安装

make clean && make -j 4 && make install

3.5配置

cp /root/php-7.3.2/php.ini-production /opt/php/php7.3/etc/php.ini
cp /opt/php/php7.3/etc/php-fpm.conf.default /opt/php/php7.3/etc/php-fpm.conf
cp /opt/php/php7.3/etc/php-fpm.d/www.conf.default /opt/php/php7.3/etc/php-fpm.d/www.conf
cp /root/php-7.3.2/sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service
cp /opt/php/php7.3/bin/php /usr/local/bin/php

3.6启动PHP

systemctl start php-fpm.service
systemctl enable php-fpm.service

安装时遇到的错误解决方法
错误1

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

错误2

configure: error: Please reinstall the libzip distribution
解决方法:
yum remove libzip -y
yum -y remove libzip-devel
wget https://libzip.org/download/libzip-1.3.2.tar.gz
tar xvf libzip-1.3.2.tar.gz
cd libzip-1.3.2
./configure
make -j 4
make install

安装redis扩展

1.下载php7的phpredis扩展库

php官网下载redis扩展页面:http://pecl.php.net/package/redis

wget http://pecl.php.net/get/redis-4.0.2.tgz

2、编译安装phpredis扩展库

tar -xzvf redis-4.0.2.tgz
cd redis-4.0.2
/opt/php/php7.3/bin/phpize
./configure --with-php-config=/opt/php/php7.3/bin/php-config
make && make install

3.添加配置

vim /opt/php/php7.3/etc/php.ini
#文件尾增加下面代码
extension=redis.so

猜你喜欢

转载自blog.csdn.net/liyyzz33/article/details/87881310
今日推荐