Windows下PHP+Apache2开发环境搭建

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 的路径:

#服务器文件路径
ServerRoot "c:/bin/Apache24"
#项目文件路径
DocumentRoot "c:/bin/htdocs"
<Directory "c:/bin/htdocs">
#   ...
</Directory
以Apache handler方式安装

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

# 以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>
以Apache handler方式安装

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

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

# 加载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>

下载的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模式

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值