需要安裝擴展shmop
找到php安裝源文件目錄
復制代碼 代碼如下:
# cd /usr/local/php-5.4.0/ext/shmop
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
編譯安裝成功
復制代碼 代碼如下:
# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
多出一個 shmop.so
在php.ini增加shmop.so
extension=shmop.so
; Module Settings ;
phpinfo()輸出
寫數據
復制代碼 代碼如下:
<?php
$shmid = shmop_open(864, 'c', 0755, 1024);
shmop_write($shmid, "Hello World!", 0);
phpinfo();
?>
讀數據
復制代碼 代碼如下:
<?php
$shmid = shmop_open(864, 'c', 0755, 1024);
shmop_write($shmid, "Hello World!", 0);
echo shmop_read($shmid, 0, 11);
?>