美文网首页
centos7 编译安装 php8 --redis扩展

centos7 编译安装 php8 --redis扩展

作者: 无味wy | 来源:发表于2022-09-20 15:53 被阅读0次

安装依赖

yum install -y gcc gcc-c++ autoconf

yum -y install libsodium-devel libwebp-devel freetype-devel glib2-devel cairo-devel libxml2-devel libjpeg-devel  libpng libpng-devel libmcrypt-devel libicu-devel openldap openldap-devel bzip2-devel libcurl-devel gmp-devel libevent-devel readline-devel libxslt-devel net-snmp-devel aspell-devel unixODBC-devel libc-client-devel freetype-devel libXpm-devel libvpx-devel enchant-devel sqlite-devel libzip-devel epel-release oniguruma oniguruma-devel  openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel sqlite-devel

创建work用户

groupadd work
useradd -g work work  --no-create-home -s /bin/false

安装

mkdir -p /opt/php
 
cd /opt/php
 
wget https://mirrors.sohu.com/php/php-8.0.11.tar.gz --no-check-certificate

编译

tar xvf php-8.0.11.tar.gz
cd php-8.0.11
./configure  --prefix=/opt/local/php8 --with-config-file-path=/opt/local/php8/etc --enable-fpm --with-fpm-user=work --with-fpm-group=work --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mcrypt --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --enable-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --with-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache --enable-bcmath --enable-pcntl
 
make && make install

报错

configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

解决

configure出现这个问题,不要慌,我来告诉你怎么解决
根据字面意思,是libzip包有问题,且libzip应该大于0.11版本且不等于1.3.1或者1.7.0

#卸载自带的libzip
yum remove libzip -y

#获取libzip包
wget https://libzip.org/download/libzip-1.3.2.tar.gz

#解压安装
tar zxf libzip-1.3.2.tar.gz
cd libzip-1.3.2/
./configure && make && make install

#查看libzip位置
[root@VM-8-9-centos php-7.4.28]# whereis libzip
libzip: /usr/local/lib/libzip.la /usr/local/lib/libzip.a /usr/local/lib/libzip.so

#配置libzip库,使configure可以找到它
vim /etc/profile
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" 
source /etc/profile

#再次编译
./configure  --prefix=/opt/local/php8 --with-config-file-path=/opt/local/php8/etc --enable-fpm --with-fpm-user=work --with-fpm-group=work --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mcrypt --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --enable-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --with-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache --enable-bcmath --enable-pcntl
 
make && make install

复制配置文件

cp /opt/local/php8/etc/php-fpm.conf.default /opt/local/php8/etc/php-fpm.conf
cp /opt/local/php8/etc/php-fpm.d/www.conf.default /opt/local/php8/etc/php-fpm.d/www.conf
cp /opt/php/php-8.0.11/php.ini-development /opt/local/php8/etc/php.ini
cp /opt/php/php-8.0.11/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
sudo chmod 777 /etc/init.d/php-fpm

配置环境变量

vim /etc/profile
export PATH=$PATH:/opt/local/php8/bin:$PATH
source /etc/profile

服务启停

#查看版本
php -v
 
#服务启停
service php-fpm start|stop|restart|status
#开机启动
chkconfig php-fpm  on

安装redis扩展

cd /opt/php/
wget http://pecl.php.net/get/redis-5.3.4.tgz --no-check-certificate
tar xf redis-5.3.4.tgz
cd redis-5.3.4
phpize
./configure --with-php-config=/opt/local/php8/bin/php-config
sudo make && make install
echo "extension=redis.so" >> /opt/local/php8/etc/php.ini
service php-fpm restart
php -m

相关文章

网友评论

      本文标题:centos7 编译安装 php8 --redis扩展

      本文链接:https://www.haomeiwen.com/subject/fsabortx.html