doutuobao4004
2013-12-05 10:20
浏览 60
已采纳

memcache(d)不适用于ubuntu 13.10

I'm trying to use memcache on my apache. (Xubuntu 13.10) I installed Apache 2.4, Php5, Mysql5, php pear etc like here: https://www.digitalocean.com/community/articles/how-to-install-and-use-memcache-on-ubuntu-12-04

php -m

root@benjamin:~# php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
memcache
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

ps aux

root@benjamin:~# ps aux | grep memcached
www-data 16113  0.0  0.0 325400   916 ?        Ssl  12:10   0:00 memcached -d -m 128 -l 127.0.0.1 -p 11211 -vv -u www-data
root     16178  0.0  0.0  18008   956 pts/1    S+   12:16   0:00 grep --color=auto memcached

and sample php code that i use

<?php 
  $memcache = new Memcache;
  $memcache->connect("localhost",11211); # You might need to set "localhost" to "127.0.0.1"
  echo "Server's version: " . $memcache->getVersion() . "<br />
";
  $tmp_object = new stdClass;
  /*
  $tmp_object->str_attr = "test";
  $tmp_object->int_attr = 123;
  $memcache->set("key",$tmp_object,false,50);
  */
  $stat = $memcache->getExtendedStats();
  echo "Store data in the cache (data will expire in 10 seconds)<br />
";
  echo "<pre>";
  print_r($stat);

   echo "Data from the cache:<br />
";

  print_r($memcache->get("key"));

?>

Problem is, nothing happens. Totally white page. How can i achive this? P.S : I also tried to connect 127.0.0.1 instead of localhost.

Update, I configured php.ini and I can get error now.

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

Fatal error: Unknown: Failed opening required '/var/www/memcache.php' (include_path='.:/usr/share/php') in Unknown on line 0

图片转代码服务由CSDN问答提供 功能建议

我正在尝试在我的apache上使用memcache。 (Xubuntu 13.10) 我在这里安装了Apache 2.4,Php5,Mysql5,php pear等: https://www.digitalocean.com/community/articles/how-to-install-and-use-memcache-on-ubuntu-12-04

php -m

  root @ benjamin:〜#php -m 
 [PHP Modules] 
bcmath \  nbz2 
calendar \ NCORE 
ctype 
curl 
date \ NDBA 
dom 
ereg 
exif 
fileinfo 
filter 
ftp \ NGD 
gettext 
hash 
iconv 
json 
libxml 
mbstring 
memcache 
mhash 
mysql 
mysqli 
openssl \  npcntl 
pcre 
PDO 
pdo_mysql 
Phar 
posix 
readline 
Reflection 
session 
shmop 
SimpleXML 
soap 
sockets 
SPL 
standard 
sysvmsg 
sysvsem 
sysvshm 
tokenizer 
wddx 
xml 
xmlreader 
xmlwriter 
Zend OPcache 
zip  
 
 
 
 
 
 [n] [Zend Modules] 
Zend OPcache 
   
 
 

ps aux

  root @ benjamin:  〜#ps aux |  grep memcached 
 -www 16113 0.0 0.0 325400 916?  Ssl 12:10 0:00 memcached -d -m 128 -l 127.0.0.1 -p 11211 -vv -u www-data 
root 16178 0.0 0.0 18008 956 pts / 1 S + 12:16 0:00 grep --color =  auto memcached 
   
 
 

我使用的示例php代码

 &lt;?php 
 $ memcache = new  Memcache; 
 $ memcache-&gt; connect(“localhost”,11211);  #您可能需要将“localhost”设置为“127.0.0.1”
 echo“Server的版本:”。  $ memcache-&gt; getVersion()。  “&lt; br /&gt; 
”; 
 $ tmp_object = new stdClass; 
 / * 
 $ tmp_object-&gt; str_attr =“test”; 
 $ tmp_object-&gt; int_attr = 123; 
 $  memcache-&gt; set(“key”,$ tmp_object,false,50); 
 * / 
 $ stat = $ memcache-&gt; getExtendedStats(); 
 echo“将数据存储在缓存中(数据将在 10秒)&lt; br /&gt; 
“; 
 echo”&lt; pre&gt;“; 
 print_r($ stat); 
 
 echo”来自缓存的数据:&lt; br /&gt; 
  “; 
 
 print_r($ memcache-&gt; get(”key“)); 
 
?&gt; 
   
 
 

问题是,没有任何反应 。 完全白页。 我怎么能做到这一点? P.S:我也尝试连接127.0.0.1而不是localhost。

更新,我配置了php.ini,我现在可以收到错误。

 警告:未知:未能打开流:第0行的未知权限被拒绝
 
发生错误:未知:未能打开所需的'/var/www/memcache.php'( 第0行的未知中的include_path ='。:/ usr / share / php')
   
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douqi5079 2013-12-05 11:05
    已采纳

    Hej bencagri,

    make sure you have installed php5-memcache, (php5-memcached if you areon debian).

    create a phpinfo.php file and write

    <?php
     echo phpinfo();
    ?>
    

    and have memcache, if you can't find anything, you'll have to

    sudo a2enmod mem_cache
    

    module in apache2.

    restart your apache and try again.

    Patrick

    点赞 评论

相关推荐 更多相似问题