溫馨提示×

溫馨提示×

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

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

如何給PHP開啟shmop擴展實現(xiàn)共享內(nèi)存

發(fā)布時間:2021-03-04 13:43:31 來源:億速云 閱讀:148 作者:小新 欄目:編程語言

小編給大家分享一下如何給PHP開啟shmop擴展實現(xiàn)共享內(nèi)存,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

給PHP開啟shmop擴展實現(xiàn)共享內(nèi)存

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

一、找到php源碼包里的擴展目錄,進入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開啟擴展

復制返回的那行路徑:/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

如何給PHP開啟shmop擴展實現(xiàn)共享內(nèi)存

看完了這篇文章,相信你對“如何給PHP開啟shmop擴展實現(xiàn)共享內(nèi)存”有了一定的了解,如果想了解更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細節(jié)

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

AI