php 開啟socket配置

來源:互聯網
上載者:User

標籤:

我在Windows命令列輸入命令:C:\wamp\bin\php\php5.2.6\php.exe getXml.php以執行php檔案。

出現錯誤:Fatal error: Call to undefined function socket_create() in C:\wamp\www\getXml.php on line 13

網上搜了挺多論壇上的Q&A貼子,答案基本上是:
1. 找到php.ini,看  extension=php_sockets.dll 擴充是否開啟,將前面的注釋; 刪去。
2. 看phpInfo()顯示的內容裡,socket模組是否為enable;

還有說是少了一些dll檔案,但是下了php4ts.dll、php5ts.dll、php_mime_magic.dll並將它們拷到目錄C:/Windows/system32下,並確認php目錄下的ext檔案夾下存在php_sockets.dll檔案,結果還是沒有解決問題。

解決方案: 這是在一個英文論壇上看到的方案,經過實踐證明是可行的。

原文是:

The command prompt uses a different php.ini file to the apache server.

The Apache php.ini file is accessible via the taskbar icon, and is located at:
X:\WAMP INSTALL DIR\Apache2\bin\php.ini

The command prompt php.ini file is located at:
X:\WAMP INSTALL DIR\php\php.ini

Once I’d enabled sockets in this file, by uncommenting the line:
extension=php_sockets.dll
and restarted the server, everything worked great.

在兩個目錄下都有php.ini  我們使用wamp 的管理介面直接修改的php.ini是位於:

C:\wamp\bin\apache\apache2.2.8\bin\php.ini 下的(因個人安裝的目錄而不同),事實證明我確實在這個php.ini檔案中修改了php_sockets.dll前面的注釋符號”;”  ,但為什麼沒有用呢?

那是因為在另外一個目錄: C:\wamp\bin\php\php5.2.6\php.ini(也因個人的安裝而不同)中的擴充沒有修改, 而我們只需修改它,就行了,  再拷一份修改後的php,ini檔案到目錄C:\Windows\目錄下。

php 開啟socket配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.