1
我在PHP上遇到Shmop問題。當我在shell中運行簡單的代碼時,我可以在內存中編寫和讀取我想要的內容,但是,服務器使用相同的腳本並且什麼都不會發生。PHP共享內存不在lighttpd中,只是在shell中工作
這是我的代碼(write.php)
<?php
$KEY = 672213396;
$smid = shmop_open($KEY, "c", 0644, 5);
$text = "test";
echo shmop_write($smid, $text, 0);
?>
(read.php)
<?php
$KEY = 672213396;
$smid = shmop_open($KEY, "a", 0644, 100);
echo shmop_read($smid,0,5);
?>
我的系統:覆盆子PI A +,Raspbian傑西,PHP 5.6.30-0 + deb8u1 (cli),使用mod fastcgi和mod fastcgi-php啓用lightpd。
如果返回False,第一步可能會嘗試打印[shmop_open()](http://php.net/manual/en/function.shmop-open.php)的返回碼,這很可能是一個指示的權限問題。 –
(mod_fastcgi.c.2702)FastCGI-stderr:PHP警告:shmop_open():無法附加或創建共享內存段 –
ipcs -m ------共享內存段------- - key shmid owner perms bytes nattch status 0x28112994 0 pi 644 15 0 0x28112995 32769 www-data 644 15 0 –