龙空技术网

PHP的安装、添加Redis扩展

snail 185

前言:

此刻我们对“设置php扩展路径”大体比较讲究,朋友们都想要知道一些“设置php扩展路径”的相关知识。那么小编也在网摘上网罗了一些对于“设置php扩展路径””的相关文章,希望我们能喜欢,小伙伴们一起来学习一下吧!

1、安装依赖

# yum -y install gcc gcc-c++ autoconf automake make# yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-develyum install -y libxml2-devel libcurl-devel libpng-devel freetype-devel libxslt-devel libicu-devel bzip2 bzip2-devel gmp-devel libmcrypt libmcrypt-devel openldap openldap-devel libc-client-devel
2、下载
# 官网: 安装说明: 
3、解压
tar -xf php-8.3.13.tar.gz
4、切换目录
cd php-8.3.13
5、配置

如果出现报错,缺失sqlite、oniguruma

# 报错:缺少sqlite、onigurumayum -y install sqlite-devel oniguruma-devel

配置:

./configure  --prefix=/usr/local/php \    --with-config-file-path=/usr/local/php/etc \    --with-bz2 \    --with-curl=/usr/local/curl \    --with-freetype-dir \    --with-gd \    --with-gettext \    --with-gmp \    --with-iconv-dir \    --with-imap \    --with-imap-ssl \    --with-kerberos \    --with-ldap \    --with-libdir=lib64 \    --with-libxml-dir \    --with-mcrypt \    --with-mysqli \    --with-pdo-sqlite \    --with-openssl \    --with-pcre-regex \    --with-pdo-mysql \    --with-pear \    --with-png-dir \    --with-xmlrpc \    --with-xsl \    --with-zlib \    --enable-fpm \    --enable-bcmath \    --enable-calendar \    --enable-exif \    --enable-intl \    --enable-inline-optimization \    --enable-libxml \    --enable-mbregex \    --enable-mbstring \    --enable-opcache \    --enable-pcntl \    --enable-shmop \    --enable-soap \    --enable-sockets \    --enable-sysvsem \    --enable-wddx \    --enable-xml \    --enable-zip
6、编译、安装
make && make install
7、复制配置文件
cp php.ini-production /usr/local/php/etc/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/ /usr/local/php/etc/php-fpm.d/
8、创建软链接
ln -s /usr/local/php/bin/php /usr/local/bin/php
9、编写php脚本
<?php// 文件所在路径:/usr/local/nginx/html/phpinfo.phpphpinfo();
10、启动php-fpm
/usr/local/php/sbin/php-fpm
11、配置nginx.conf
# 详见: 修改location        location / {            root   html;            index  index.php index.html index.htm;        }# php配置location ~* \.php$ {    fastcgi_index   index.php;    fastcgi_pass    127.0.0.1:9000;    include         fastcgi_params;    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;}
12、浏览器访问 或者 curl命令访问
curl 127.0.0.1/phpinfo.php
13、安装Redis扩展13.1、下载
# 官网: 
13.2、解压
tar -xf redis-6.0.0.tgz
13.3、切换目录
cd redis-6.0.0 
13.4、配置、编译、安装
/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake install
13.5、修改php.ini文件
# vi /usr/local/php/etc/php.ini,在963行添加extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20230831/";extension="redis.so";
13.6、使用php -m查看
php -m | grep redis
13.7、重启php-fpm
ps aux|grep phpkill -USR2 进程id
13.8、浏览器访问
curl 127.0.0.1/phpinfo.php

标签: #设置php扩展路径