• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Windows下PHP+Apache2开发环境搭建

php 搞代码 3年前 (2022-01-23) 18次浏览 已收录 0个评论

Windows下PHP+Apache2开发环境搭建

PHP线程安全与非线程安全版本选择 ####

参考: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.

结论:
+ IIS服务器:非线程安全的PHP版本
+ Apache服务器:线程安全的PHP版本

PHP下载

http://windows.php.net/download/
个人PC环境为:2位的win7,使用Apache服务器。
所以下载目前最新版本:
PHP 5.6 (5.6.9)的“VC11 x86 Thread Safe (2015-May-14 18:29:57)”的压缩包

Apache下载

http://www.apachelounge.com/download/
目前最新的为:Apache 2.4.12 Win32

PHP+Apache的配置

参考:http://php.net/manual/zh/install.windows.apache2.php

修改Apache的基本配置信息

在{apache}/conf/httpd.conf中修改 ServerRoot 和 DocumentRoot 的路径:

<code>#服务器文件路径ServerRoot "c:/bin/Apache24"#项目文件路径DocumentRoot "c:/bin/htdocs"#   ...</Directory</code>

以Apache handler方式安装

在{apache_path}/conf/httpd.conf中添加如下信息:

<code># 以Apache handler方式安装运行PHPLoadModule php5_module "C:/bin/php5.6/php5apache2_4.dll"    AddHandler application/x-httpd-php .php    # 配置 php.ini 的路径    PHPIniDir "C:/bin/php5.6"    # 配置处理文件的格式            SetHandler application/x-httpd-php    </code>

以Apache handler方式安装

下载fast-cgi模块:http://www.apachelounge.com/download/win32/
解压到apche的modules目录中。

在 {apache_path}/conf/httpd.conf 中添加如下fast-cgi的配置信息:

<code># 加载fast-cgi模块LoadModule fcgid_module modules/mod_fcgid.so# fast-cgi模块配置     # 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     FcgidMaxProce<div>)本文来源gaodai.ma#com搞#代!码网_</div><strong>搞代gaodaima码</strong>sses 1000     FcgidOutputBufferSize 64     FcgidProcessLifeTime 120     FcgidMaxRequestsPerProcess 10000     FcgidMinProcessesPerClass 0     FcgidFixPathinfo 1     # Global Config Example              Options Indexes FollowSymLinks ExecCGI         AddHandler fcgid-script .php         FcgidWrapper "c:/bin/php5.6/php-cgi.exe" .php      </code>

下载的fast-cgi模块压缩包中readme.txt有详细的配置信息

启动Apache服务器

在cmd命令行中执行 {apache_path}/bin/httpd.exe 即可

在phpinfo()中,通过phpinfo()的”Server API”的值判断运行模式:

  • CGI/FastCGI : Fast-cg模式
  • Apache 2.0 Handler : Apache handler模式

若在httpd.cnf中对apache hanlder和fast-cgi都进行了配置,则使用apache handler模式

以上就介绍了Windows下PHP+Apache2开发环境搭建,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Windows下PHP+Apache2开发环境搭建

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址