溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

給 PHP開啟 shmop擴(kuò)展實(shí)現(xiàn)共享內(nèi)存的方法

發(fā)布時(shí)間:2020-10-16 14:10:23 來源:億速云 閱讀:146 作者:小新 欄目:編程語言

這篇文章將為大家詳細(xì)講解有關(guān)給 PHP開啟 shmop擴(kuò)展實(shí)現(xiàn)共享內(nèi)存的方法,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

在項(xiàng)目開發(fā)中,想要實(shí)現(xiàn)PHP多個(gè)進(jìn)程之間共享數(shù)據(jù)的功能,讓客戶端連接能夠共享一個(gè)狀態(tài),需要開啟共享內(nèi)存函數(shù)shmop。如果預(yù)期考慮會(huì)遇到這方面需求,那么最好在編譯PHP的時(shí)候添加--with-shmop選項(xiàng)。但是編譯的時(shí)候沒有添加,只能在重新編譯配置了。

一、找到php源碼包里的擴(kuò)展目錄,進(jìn)入shmop

# cd /usr/local/src/php-7.1.10/ext/shmop/

二、執(zhí)行phpize,生成配置

# phpize
[root@bogon shmop]# ls
acinclude.m4    build         config.h.in  config.nice    configure     CREDITS     libtool    Makefile.fragments  missing        package2.xml  README         shmop.la
aclocal.m4      config.guess  config.log   config.status  configure.in  include     ltmain.sh  Makefile.global     mkinstalldirs  package.xml   run-tests.php  shmop.lo
autom4te.cache  config.h      config.m4    config.sub     config.w32    install-sh  Makefile   Makefile.objects    modules        php_shmop.h   shmop.c        tests

三、執(zhí)行命令開始編譯

# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
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/php/lib/php/extensions/no-debug-non-zts-20160303/

四、修改php.ini開啟擴(kuò)展

復(fù)制返回的那行路徑:/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.dll
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/shmop.so   //添加此行代碼,后面跟上shmop.so

重啟php

關(guān)于給 PHP開啟 shmop擴(kuò)展實(shí)現(xiàn)共享內(nèi)存的方法就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

php
AI