1. automatically install Apache 2.2.17
Apache download page: http://httpd.apache.org/download.cgi
Test Apache: Access http: // localhost/
2. Manually install PHP 5.3.5
PHP download page: http://windows.php.net/download/
Download the vc6 ZIP file and decompress it to c: \ Program Files \ PHP \.
Copy c: \ Program Files \ PHP. ini-Development and paste it as c: \ Program Files \ PHP. ini
Modify c: \ Program Files \ PHP. ini
Search; extension_dir = "Ext"
Remove the semicolon and change it
Extension_dir = "C: \ Program Files \ PHP \ Ext"
Search
; Extension = php_pdo
Change
Extension = php_pdo_mysql.dll
Extension = php_pdo_sqlite.dll
Extension = php_mysql.dll
Extension = php_mysqli.dll
Extension = php_sqlite.dll
Extension = php_sqlite3.dll
Search
Timezone
Change
Date. timezone = Asia/Shanghai
Connect Apache to PHP:
Modify c: \ Program Files \ Apache Software Foundation \ apache2.2 \ conf \ httpd. conf
Add at the bottom:
# Begin PHP installer edits-remove only on uninstall
Phpinidir "C:/program files/PHP /"
Loadmodule php5_module "C:/program files/PHP/php5apache2_2.dll"
Addhandler application/X-httpd-PHP. php
# End PHP installer edits-remove only on uninstall
Search directoryindex
Change
Directoryindex index.html index. php
Restart Apache and test: Apache and PHP
Create a file c: \ Program Files \ Apache Software Foundation \ apache2.2 \ htdocs \ phpinfo. php
<? PHP
Phpinfo ();
?>
3. automatically install MySQL (check environment variables during installation)
Test MYSQL:
Use the command line: mysql-uroot-p1
Test PHP connection to MySQL:
<? PHP
Mysql_connect ("127.0.0.1", "root", "1") or die (mysql_error ());
Var_dump ($ connet);?>
Test PDO connection to MySQL:
<? PHP
Class dB extends PDO
{
Public static $ config_1 = Array
(
'Dbms '=> 'mysql ',
'Host' => '2017. 0.0.1 ',
'Db _ name' => 'mysql ',
'User' => 'root ',
'Pass' => '1 ',
'Db _ charset' => 'utf8 ',
);
Public Function _ construct ($ config_name = 'config _ 1 ')
{
Switch ($ config_name)
{
Case 'config _ 1 ':
$ Config = self: $ config_1;
Break;
Case 'config _ 2 ':
$ Config = self: $ config_2;
Break;
}
$ DSN = $ config ['dbms ']. ': host = '. $ config ['host']. '; dbname = '. $ config ['db _ name']. '; charset = '. $ config ['db _ charset'];
Try
{
Parent: :__ construct ($ DSN, $ config ['user'], $ config ['pass']);
PDO: exec ("set names 'utf8 ';");
}
Catch (pdoexception $ E)
{
Die ("error:". $ e->__ tostring (). "<br/> ");
}
}
Public final function query ($ SQL)
{
Try
{
Return parent: Query ($ this-> setstring ($ SQL ));
}
Catch (pdoexception $ E)
{
Die ("error:". $ e->__ tostring (). "<br/> ");
}
}
Private final function setstring ($ SQL)
{
Echo $ SQL. "<br/> ";
Return $ SQL;
}
}
$ Db = new dB ();
$ SQL = 'select * from user limit 1 ';
$ Result = $ db-> query ($ SQL );
$ Result-> setfetchmode (PDO: fetch_assoc );
$ Fetch_result = $ result-> fetchall ();
Var_dump ($ fetch_result );
?>
Important:
Do not use the PHP Automatic Installation Package (MSI suffix). The files in the package are different from those in the manual installation package (ZIP suffix. The automatic installation package may cause some strange problems because of file errors.
Note: libmysql. dll does not exist in PHP 5.3. You can directly connect to MySQL without any need. Now it is built-in.
References: http://www.cnblogs.com/veryinf/archive/2009/10/13/1537269.html
It took me a while. I hope my friends who passed by can see that there will be less detours.