Windows中APACHE開啟fastcgi後無法串連資料庫

來源:互聯網
上載者:User

標籤:io   os   sp   檔案   資料   on   cti   ad   ef   

環境:
Windows server 2003 x64
Apache 2.2.14
mod_fcgid-2.2b-w32.zip
PHP VC9 x86 Non Thread Safe(用Visual C++ 2008 Redistributable Package x86來編譯的)

我用下面的配置能使FASTCGI啟動:
LoadModule fcgid_module modules/mod_fcgid.so
<Directory "C:/www">
AllowOverride None
Order allow,deny
Options FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FCGIWrapper "c:/php/php-cgi.exe" .php
Allow from all
</Directory>

<IfModule mod_fcgid.c>
IPCCommTimeout 40
IPCConnectTimeout 10
MaxProcessCount 8
OutputBufferSize 64
ProcessLifeTime 240
MaxRequestsPerProcess 500
</IfModule>

但會發生下面的一些錯誤:
1、echo gethostbyname(‘google.com‘);
上面只會返回"google.com"而不是正常返回的IP。
2、$connection1=mysql_connect("localhost",‘root‘,‘password‘);
上面這個會報錯 mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:/www/test.php on line 11

這是因為FASTCGI未取到環境變數的原因,解決辦法是在Apache設定檔增加如下語句:
DefaultInitEnv PATH "PHP程式目錄;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
DefaultInitEnv SystemRoot "C:/Windows"
DefaultInitEnv SystemDrive "C:"
DefaultInitEnv TEMP "C:/WINDOWS/Temp"
DefaultInitEnv TMP "C:/WINDOWS/Temp"
DefaultInitEnv windir "C:/WINDOWS"

Windows中APACHE開啟fastcgi後無法串連資料庫

聯繫我們

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