Enable shmop extension for PHP to implement shared memory

不言
Release: 2023-04-02 17:42:02
Original
2118 people have browsed it

This article mainly introduces the implementation of shared memory by enabling shmop extension for PHP. It has certain reference value. Now I share it with you. Friends in need can refer to it.

During project development, if you want To implement the function of sharing data between multiple PHP processes, so that client connections can share a state, you need to enable the shared memory function shmop. If you anticipate encountering this need, it is best to add the --with-shmop option when compiling PHP. However, it was not added during compilation and can only be configured after recompiling.

1. Find the extension directory in the php source code package and enter shmop

# cd /usr/local/src/php-7.1.10/ext/shmop/
Copy after login

2. Execute phpize to generate the configuration

# phpize
Copy after login
[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
Copy after login

3. Execute the command to start compilation

# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
Copy after login
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/
Copy after login

4. Modify php.ini to enable the extension

Copy the returned line path:/usr /local/php/lib/php/extensions/no-debug-non-zts-20160303/

# vim /usr/local/php/etc/php.ini
Copy after login
rrree

Restart php

Enable shmop extension for PHP to implement shared memory

The above is the entire article Content, I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Understand the concept and advantages and disadvantages of php shared memory

The above is the detailed content of Enable shmop extension for PHP to implement shared memory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!