views:

366

answers:

2

I configured PHP to use Apache mod_fcgid. PHP is working, but after changes in configuration I am not able to connect to mysql via php. How to fix this? Any ideas, which can hint me, are very desired!

To check mysql connection I use the following php code:

error_reporting(E_ALL);

$link = mysql_connect('127.0.0.1', 'root', 'password_here');
if (!$link) {
    die('Could not connect. Error message: <' . mysql_error() . '>');
}
echo 'Connected successfully';

Error message returned by mysql_error() is empty.

I use the following configuration in Apache:

LoadModule fcgid_module modules/mod_fcgid.so
<IfModule fcgid_module>  
AddHandler fcgid-script .fcgi .php  
DefaultInitEnv PHPRC "C:/Program Files/php5"
DefaultInitEnv PHP_FCGI_MAX_REQUESTS      1000  
MaxRequestsPerProcess       1000  
MaxProcessCount 15
IPCCommTimeout 120
IdleTimeout 120
FCGIWrapper "C:/PROGRA~1/php5/php-cgi.exe" .php  
AddType application/x-httpd-php .php  

DefaultInitEnv PATH "C:/PROGRA~1/MYSQL/MYSQLS~1.0/LIB/OPT;C:/PROGRA~1/APACHE~1/APACHE2.2/BIN;C:/WINDOWS/system32;C:/WINDOWS"
</IfModule>  

PHP 5.3.1, Apache/2.2.14 (Win32), MySQL 5.0.67-community-nt, Windows Vista Home Premium Service Pack 1. I downloaded binaries of mod_fcgid from http://www.apachelounge.com/download/mods/mod_fcgid-2.2b-w32.zip

EDIT:

I used phpinfo() to compare configuration. "Loaded Configuration File" is the same for both with and without mod_fcgid. mysql section is the same for both configs. What I found out that Environment section when mod_fcgid is turned on contains only FastCGI related variable (4 items only), while without mod_fcgid - much more...

If you need more info please let me know.

If somebody has successful installation of FastCGI for php, with Apache and mysql on Windows it could be very good to know about your experience.

EDIT:

I obtain the following warning:

Warning: mysql_connect() [function.mysql-connect]: in E:\ ... \testphp\mysql.php on line 7

EDIT

Error log of mysql contain no any errors on mysql_connect().

A: 

Have you tried running php_info() to see if the mysql module is present and configured for your CGI? The ini configuration can be different between CGI and other method of launching.

Jacob

TheJacobTaylor
I added "EDIT" in post, which describes the answer
sergdev
+1  A: 

Are you sure that Warning: mysql_connect() [function.mysql-connect]: in E:\ ... \testphp\mysql.php on line 7
is the full error ? Because that's unusual it should say what's wrong there.
Also please check your mysql server's log file for any anomalies and post them here. mysql error log documentation.

DCC
Yes, this is a full log when page executed, and that is why it is so difficult for me to realize how to fix.Concerning mysql logs: no any errors on mysql_connect().Offtop: I just installed apache module - it works. But FastCGI is much better for me because I also have bugzilla installed which uses perl
sergdev
Post your error logs here http://pastebin.org/ and let me look at them.
DCC
The mysql log is at http://pastebin.org/98615. Thanks for your assistance!!
sergdev
Concerning php log. I have error_log = C:/temp/php_errors.log in php.ini, but file is not created, I see error messages as output on the page parsed by php.
sergdev
Ok, completely uninstall Mysql and install again OR try to delete all logfiles from mysql (shutdown mysqld-nt, delete logfiles and start).If that doesn't work try and upload to pastebin.org the php errors.
DCC