Under Windows, Apache and MySQL have automated installation programs, and this article focuses on choosing from Apache and PHP versions, PHP thread safety, Apache and MySQL installation startup services, Work environment configuration in these aspects to describe the construction of Windows Apache+php+mysql process.
Apache Download Address: http://httpd.apache.org/download.cgi
PHP Download Address: http://windows.php.net/download/
MySQL Download address: http://dev.mysql.com/downloads/mysql/
First, version selection
According to PHP official website, PHP version of different, choose compiler different, Apache installation package selection is also different.
Currently, the compiler used by php5.5 is vc11,php5.4 and php5.3 vc9,php5.2 is VC6, but php5.2 is no longer updated.
Here's a question to note: apache.org only provides VC6 compiled versions under Windows. In other words, if you choose the apache.org release, you can only choose php5.2, otherwise there may be a problem.
In addition, Windows run VC9 or VC11 compiled programs that need to install the Visual C + + runtime, which you can download on Windows official website to install Visual C + + 2008 (x86), Visual C + + 2008 (x64), Visual C + + (x86 or x64)
If you use the php5.3 version above, it is recommended to download Apache to apachelounge.com.
Second, thread safety
PHP thread safety is to ensure that PHP in a multithreaded environment does not occur inconsistent data, but not thread security is possible. Thread safety therefore controls the resource, adding additional overhead, which is less efficient in a single-threaded environment than is not thread safe.
So, how do you choose to use thread safe or Non thread safe version?
1, DSO (mod_php, ISAPI, etc.)
Used as DLL dynamic library, can be executed after the user request, after processing a user request will not disappear immediately, so the need for thread security checks, so as to improve the execution efficiency of the program, here Select the thread safe version;
2, CGI (CGI, FastCGI)
It takes a single thread to perform an operation, so there is no need for a thread security check, and the removal of thread security checks can improve execution efficiency, where the non-threaded version is selected.
Third, start the service
This ignores the installation package for the fool-mounted operation, if you manually install Apache and MySQL services, refer to the following command
Copy Code code as follows:
#安装apache2.2 Services
D:\apache2.2\bin\httpd.exe-k Install
#启动apache2.2 Services
D:\apache2.2\bin\httpd.exe-k start
#安装mysql服务
D:\mysql\bin\mysqld.exe-install
#启动mysql服务
SC start MySQL
Four, the configuration environment
1, configure Apache support PHP
Copy Code code as follows:
Phpinidir "D:\php\php.ini"
LoadModule php5_module "D:\php\php5apache2_2.dll"
AddType application/x-httpd-php. php
2. Configure PHP to support MySQL
Copy Code code as follows:
Extension_dir = "D:/php/ext"
Extension = Php_mysql.dll
3, PHP connection MySQL
Copy Code code as follows:
<?php
$link = mysql_connect (' localhost ', ' mysql_user ', ' Mysql_password ');
if (! $link) {
Die (' Could not connect: '. Mysql_error ());
}
Echo ' Connected successfully ';
Mysql_close ($link);
?>
If you build, Apache can not start, refer to this article "Solve apache/php problem", should be helpful to you.