It took two days of experimentation to finally figure out how to connect PHP to SQL Server database, and how to redirect by modifying the VirtualHost file, because there are more detours, so I would like to share this journey.
First step: Install Wamp and other similar integrated software
I'm using wampserver2.4-x86, the integration package.
(All the Wampserver2.4 inside of the php5.4,wampserver2.5 I met were php5.5)
It contains the apache/2.4.4 (WIN32) php/5.4.16 mysql/5.5
After installing this package, you can enter 127.0.0.1 this test address in the browser, if the following interface appears
This means that the software is installed properly.
Step Two: Install related components and download related extensions
The local computer installs the corresponding Microsoft SQL Server Native Client (software called sqlncli.msi), otherwise it can install the sqlsrv extension but cannot connect to the database
Before installing sqlsrv, please watch http://www.microsoft.com/en-us/download/details.aspx?id=20098 carefully.
Step three: Modify the relevant configuration in Wamp
1.\wamp\bin\apache\apache2.4.4\bin\php.ini
Add the appropriate extension file name, such as
Extension=php_pdo_sqlsrv_54_ts.dll
Extension=php_sqlsrv_54_ts.dll
Extension=php_memcache.dll
Here, the php.ini that actually works in Wamp is the php.ini in Wamp\bin\apache\apache2.4.4\bin\php.ini and not wamp\bin\php\php5.4.16
2.wamp\bin\php\php5.4.16\ext
Add the corresponding extension source files, such as
Php_pdo_sqlsrv_54_ts.dll
Php_sqlsrv_54_ts.dll
Php_memcache.dll
3.wamp\bin\apache\apache2.4.4\conf\httpd.conf
Modify documentroot and directory as follows (here I put my project in the E:/www directory)
DocumentRoot "E:/www"
<directory "E:/www" >
Turn on the Load module
LoadModule Rewrite_module modules/mod_rewrite.so
LoadModule Vhost_alias_module modules/mod_vhost_alias.so
Include conf/extra/httpd-vhosts.conf
4.wamp\bin\apache\apache2.4.4\conf\extra\httpd-vhosts.conf
Modified to look like this,
<virtualhost 127.0.0.1:80>
DocumentRoot "e:/www/"
ServerName localhost
</VirtualHost>
<virtualhost 127.0.0.2:80>
DocumentRoot "E:/www/webdev2/m/trunk/web"
ServerName mm.test.fang.com
Rewriteengine on
#海外rewrite规则
Rewriterule ^/world/dgnews.html$/world/index.php?c=world&a=dgnews [L]
Rewriterule ^/world/zynews.html$/world/index.php?c=world&a=zynews [L]
</VirtualHost>
Note: You can copy the two files in the wamp\www to the E:/www directory so that you can view the corresponding version information later, but after copying to modify the inside of the index.php file, not many, two places
$wampConfFile = '. /wampmanager.conf ';
$aliasDir = '. /alias/';
Change the relative path here to the absolute path
5. C:\Windows\System32\Drivers\etc
Modify the host file to the following form
127.0.0.1 localhost
127.0.0.2 mm.test.fang.com
127.0.0.3 map1.test.fang.com
127.0.0.4 nmap.test.fang.com
To restart Apache after the modification, and then enter 127.0.0.1 in the Address bar, the following interface will appear
The red part is the newly added extension.
See here can only show that your extension is connected, can not connect to SQL Server database also see you before the Microsoft SQL Server Native client is not the same as your operating system, and finally use the program to connect to the database only to explain the real well.
Details:
1. The PHP version and the extension you downloaded are not the same;
2. PHP is divided into security thread version (TS) and non-thread version (NTS), some extensions also divide this, so you try to see which extension fits
Php_pdo_sqlsrv_54_ts.dll
Php_sqlsrv_54_ts.dll
also have
Php_pdo_sqlsrv_54_nts.dll
Php_sqlsrv_54_nts.dll
3. Be sure to look before installing the sqlsrv extension
http://www.microsoft.com/en-us/download/details.aspx?id=20098
Official Document Description
4.SQL Server Driver for PHP2.0 version (Sqlserver20.exe)
Support database version: SQL Server 2005, SQL Server 2008
Support for PHP version: php5.2, php5.3
. SQL Server Driver for PHP3.0 version (Sqlserver30.exe)
Support database version: SQL Server 2005, SQL Server, SQL Server 2012
Support for PHP version: php5.3, php5.4
SQL Server Driver for PHP3.1 version (Sqlserver31.exe)
Support for PHP version: php5.5
Summarize:
Microsoft Stuff really TM too people
PHP installation sqlsrv and memcache extension steps