大佬教程收集整理的这篇文章主要介绍了Centos7下编译安装php扩展redis5.0.2,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
安装环境:centos7 + PHP 7.2.19
1. 下载地址:http://pecl.PHP.net/get/redis-5.0.2.tgz
wget -O /mydata/download/redis-5.0.2.tgz http://pecl.PHP.net/get/redis-5.0.2.tgz
2. 解压
tar zxf redis-5.0.2.tgz
cd redis-5.0.2 ls arrays.markdown cluster.markdown config.w32 CREDITS library.c README.markdown redis_array_impl.c redis_cluster.c redis_commands.h tests cluster_library.c common.h COPYING INSTALl.markdown library.h redis_array.c redis_array_impl.h redis_cluster.h redis_session.c cluster_library.h config.m4 crc16.h liblzf PHP_redis.h redis_array.h redis.c redis_commands.c redis_session.h
4. 阅读INSTALl.markdown,了解详细的安装步骤与说明
5. 开始安装
# PHPize会根据本地的PHP环境生成configure文件 PHPize Configuring for: PHP Api Version: 20170718 Zend Module Api No: 20170718 Zend Extension Api No: 320170718 # 查看configure帮助信息,了解详细的安装参数 ./configure --Help `configure' configures this package to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGs...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --Help display this Help and exit --Help=short display options specific to this package --Help=recursive display the short Help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print `checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, `make install' will install all the files in `/usr/local/bin', `/usr/local/lib' etc. You can specify an installation prefix other than `/usr/local' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --da@R_75_2301@otdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DA@R_75_2301@OTDIR] --infodir=DIR info documentation [DA@R_75_2301@OTDIR/info] --localedir=DIR locale-dependent data [DA@R_75_2301@OTDIR/locale] --mandir=DIR man documentation [DA@R_75_2301@OTDIR/man] --docdir=DIR documentation root [DA@R_75_2301@OTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] Optional Features and Packages: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-libdir=NAME Look for libraries in .../NAME rather than .../lib --with-PHP-config=PATH Path to PHP-config PHP-config --enable-redis Enable redis support --disable-redis-session Disable session support --disable-redis-json Disable json serializer support --enable-redis-igbinary Enable igbinary serializer support --enable-redis-msgpack Enable msgpack serializer support --enable-redis-lzf Enable lzf compression support --with-liblzf=DIR Use system liblzf --enable-shared=PKGS Build shared libraries default=yes --enable-static=PKGS Build static libraries default=yes --enable-fast-install=PKGS Optimize for fast installation default=yes --with-gnu-ld Assume the C compiler uses GNU ld default=no --disable-libtool-lock Avoid locking (might break parallel builds) --with-pic Try to use only PIC/non-PIC objects default=use both --with-tags=TAGS Include additional configurations automatic Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir> LIBS libraries to pass to the linker, e.g. -l<library> CPPFLAGS (ObjectivE) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor Use these variables to override the choices made by `configure' or to Help it to find libraries and programs with nonstandard names/LOCATIOns. Report bugs to the package provider. # 设置配置参数 ./configure \ --with-PHP-config=/usr/local/PHP7.2/bin/PHP-config \ --enable-redis # 编译与安装 make && make install # 出现下面的信息(部分),说明安装成功 ... ... ... ... ---------------------------------------------------------------------- Libraries have been installed in: /mydata/download/redis-5.0.2/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/PHP7.2/lib/PHP/extensions/debug-non-zts-20170718/
6. 配置PHP.ini,添加extension=redis.so
; redis extension extension=redis.so
7. 重启PHP-fpm
service PHP-fpm restart RedirecTing to /bin/systemctl restart PHP-fpm.service # PHP-fpm.service文件位置 /usr/lib/systemd/system/PHP-fpm.service # PHP-fpm.service文件内容 [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [service] Type=simple PIDFile=/usr/local/PHP7.2/var/run/PHP-fpm.pid ExecStart=/usr/local/PHP7.2/sbin/PHP-fpm --nodaemonize --fpm-config /usr/local/PHP7.2/etc/PHP-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target
8. 检测redis扩展是否安装成功
# 查看PHP中已安装模块,显示redis,说明安装成功 PHP -m|grep redis redis
9. 关于扩展的使用说明,可以查看:https://github.com/PHPredis/PHPredis/#classes-and-methods
以上是大佬教程为你收集整理的Centos7下编译安装php扩展redis5.0.2全部内容,希望文章能够帮你解决Centos7下编译安装php扩展redis5.0.2所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。