Home > Article > Backend Development > Building PHP+Apache2 development environment under Windows
PHP+Apache2 development environment construction under Windows
Reference: http://windows.php.net/download/
If you are using PHP as FastCGI with IIS you should use the Non-Thread Safe (NTS) versions of PHP
With Apache you have to use the Thread Safe (TS) versions of PHP.
Conclusion:
+ IIS Server: Non-thread-safe PHP version
+ Apache Server: Thread-safe PHP version
http://windows.php.net/download/
Personal PC environment is: 2-bit win7, using Apache server.
So download the latest version:
Compressed package of "VC11 x86 Thread Safe (2015-May-14 18:29:57)" for PHP 5.6 (5.6.9)
http://www.apachelounge.com/download/
The latest one is currently: Apache 2.4.12 Win32
PHP+Apache configuration
Reference: http://php.net/manual/zh/install.windows.apache2.php
Modify the paths of ServerRoot and DocumentRoot in {apache}/conf/httpd.conf:
<code>#服务器文件路径 ServerRoot "c:/bin/Apache24" #项目文件路径 DocumentRoot "c:/bin/htdocs" <Directory "c:/bin/htdocs"> # ... </Directory </code>
Add the following information in {apache_path}/conf/httpd.conf:
<code># 以Apache handler方式安装运行PHP LoadModule php5_module "C:/bin/php5.6/php5apache2_4.dll" <IfModule php5_module> AddHandler application/x-httpd-php .php # 配置 php.ini 的路径 PHPIniDir "C:/bin/php5.6" # 配置处理文件的格式 <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> </IfModule> </code>
Download the fast-cgi module: http://www.apachelounge.com/download/win32/
Unzip it into the modules directory of apche.
Add the following fast-cgi configuration information in {apache_path}/conf/httpd.conf:
<code># 加载fast-cgi模块 LoadModule fcgid_module modules/mod_fcgid.so # fast-cgi模块配置 <IfModule fcgid_module> # Where is your php.ini file? FcgidInitialEnv PHPRC "c:/bin/php5.6/" FcgidInitialEnv PATH "C:/bin/php5.6;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;" FcgidInitialEnv SystemRoot "C:/Windows" FcgidInitialEnv SystemDrive "C:" FcgidInitialEnv TEMP "C:/WINDOWS/TEMP" FcgidInitialEnv TMP "C:/WINDOWS/TEMP" FcgidInitialEnv windir "C:/WINDOWS" FcgidIOTimeout 40 FcgidConnectTimeout 10 FcgidMaxProcesses 1000 FcgidOutputBufferSize 64 FcgidProcessLifeTime 120 FcgidMaxRequestsPerProcess 10000 FcgidMinProcessesPerClass 0 FcgidFixPathinfo 1 # Global Config Example <Files ~ "\.php$"> Options Indexes FollowSymLinks ExecCGI AddHandler fcgid-script .php FcgidWrapper "c:/bin/php5.6/php-cgi.exe" .php </Files> </IfModule> </code>
The readme.txt in the downloaded fast-cgi module compressed package has detailed configuration information
Execute {apache_path}/bin/httpd.exe in the cmd command line.
In phpinfo(), judge the running mode by the value of "Server API" of phpinfo():
If both apache hanlder and fast-cgi are configured in httpd.cnf, use apache handler mode
The above introduces the establishment of PHP+Apache2 development environment under Windows, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.