您好,欢迎访问一九零五行业门户网

怎么给PHP开启shmop扩展实现共享内存

给php开启shmop扩展实现共享内存
在项目开发中,想要实现php多个进程之间共享数据的功能,让客户端连接能够共享一个状态,需要开启共享内存函数shmop。如果预期考虑会遇到这方面需求,那么最好在编译php的时候添加--with-shmop选项。但是编译的时候没有添加,只能在重新编译配置了。
一、找到php源码包里的扩展目录,进入shmop
# cd /usr/local/src/php-7.1.10/ext/shmop/
二、执行phpize,生成配置
# phpize
[root@bogon shmop]# lsacinclude.m4    build         config.h.in  config.nice    configure     credits     libtool    makefile.fragments  missing        package2.xml  readme         shmop.laaclocal.m4      config.guess  config.log   config.status  configure.in  include     ltmain.sh  makefile.global     mkinstalldirs  package.xml   run-tests.php  shmop.loautom4te.cache  config.h      config.m4    config.sub     config.w32    install-sh  makefile   makefile.objects    modules        php_shmop.h   shmop.c        tests
三、执行命令开始编译
# ./configure --with-php-config=/usr/local/php/bin/php-config# make && make install
see any operating system documentation about shared libraries formore 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/php/lib/php/extensions/no-debug-non-zts-20160303/
四、修改php.ini开启扩展
复制返回的那行路径:/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
# vim /usr/local/php/etc/php.ini
;extension=php_pdo_sqlite.dll;extension=php_pgsql.dllextension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/shmop.so   //添加此行代码,后面跟上shmop.so
重启php
推荐:php视频教程
以上就是怎么给php开启shmop扩展实现共享内存的详细内容。
其它类似信息

推荐信息