php 無法串連 memcache

來源:互聯網
上載者:User
昨天在 linux 虛擬機器裝了一個 memcache,在 php 可以正常存取資料。 今天重啟 linux, 卻發現 php 無法串連memcache, 但 telnet 可以串連, 可以存取資料。 希望有大俠幫解答一下,解決問題,馬上結貼,給意見、幫頂都給分。

我的 php 代碼如下
$memcache = new Memcache;
$memcache->connect('localhost', 11211);
$memcache->set('key', 'test');
$get_value = $memcache->get('key');
echo $get_value;


回複討論(解決方案)

是不是連接埠沒佔了?

代?正常。
telnet 成功可以表示連接埠正常。

telnet localhost 11211
set key 0 0 3
123
看看能否存?。

無法串連。總會有錯誤資訊的吧。貼出來瞅瞅。

貼個串連給你:
http://stackoverflow.com/questions/18420113/memcache-for-php-unable-to-connect

求錯誤資訊。

同求 你這沒有錯誤資訊 怎麼破啊

謝謝microlab2009、fdipzone、ohmygirl、nowphp、u010541899,
通過設定,php顯示了錯誤提示, 是selinux的問題, 開啟的時候,會禁止 php 串連 memcache,關閉後一切正常。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.