Win7 under the manual build Wamp environment, encountered several pits summarized under,
1. Normal access to PHP and HTML type files, but access to the project file is always connected to be reset, and then summarized as a database problem, write test cases test PHP can successfully call the database,
1<?PHP2 Echo"MySQL";3 4 $mysql _conf=Array(5' Host ' = ' 127.0.0.1 ',6' db ' = ' drupal628 ',7' Db_user ' = ' root ',8' Db_pwd ' = ' admin ',9 );Ten $mysql _conn= @mysql_connect($mysql _conf[' Host '],$mysql _conf[' Db_user '],$mysql _conf[' Db_pwd ']); One if(!$mysql _conn) { A EchoFailed; - die("Could not connect to the database:\n".Mysql_error());//Diagnosing Connection Errors -}Else{ the Echo"Connection succeeded"; - } - -?>
MySQL Test
1<?PHP2 Echo"Mysqli";3 4 $mysql _conf=Array(5' Host ' = ' 127.0.0.1 ',6' db ' = ' drupal628 ',7' Db_user ' = ' root ',8' Db_pwd ' = ' admin ',9 );Ten One $mysqli= @NewMysqli ($mysql _conf[' Host '],$mysql _conf[' Db_user '],$mysql _conf[' Db_pwd ']); A if($mysqli-Connect_errno) { - EchoFailed; - die("Could not connect to the database:\n".$mysqli->CONNECT_ERROR);//Diagnosing Connection Errors the}Else{ - EchoSuccess; - } - +?>
mysqli Test
The actual is mysqli can connect successfully, MySQL connection is not successful, phpinfo.php also display module has been loaded normally, baffled its solution, until find the answer of the great God.
Workaround 1:
- Added in Apache configuration file httpd.conf: LoadFile D:/php/php5.2.13/libmysql.dll (Good try, I don't have 2 errors)
- Modify the \windows\system32\drivers\etc\hosts file, point localhost to 127.0.0.1 (due to Windows7 resolvable IPv6, default localhost point is:: 1 not 127.0.0.1)
2. Cannot automatically locate the homepage
Add DirectoryIndex index.html index.php in httpd.conf <directory "F:/php_projects" ></Directory> default.html default.php Specify default home page
WINDOWS7 environment Apache connection mysql Prompt "Connection reset" workaround