php做网站--配置

来源:互联网 发布:crapapi 源码的安装 编辑:程序博客网 时间:2024/06/05 18:53

    由于是在window上做开发,需要配置window下php的开发环境


  1. 下载Apache的服务器 解压安装 我用的是Apache2.2,端口号可在配置文件中修改

           在conf下httpd.conf中查找Listen 修改监听的端口 ,以防端口冲突 

       访问http://127.0.0.1:port/ 出现it works 则说明访问成功

  2. 下载php包

      下载地址 http://windows.php.net/download/ ,在此地址左侧栏中有这么一段说明

      

Which version do I choose?

If you are using PHP with Apache 1 or Apache2 from apache.org you need to use the VC6 versions of PHP

If you are using PHP with IIS you should use the VC9 versions of PHP

VC6 Versions are compiled with the legacy Visual Studio 6 compiler

VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64)installed

Do NOT use VC9 version with apache.org binaries

VC9 versions of Apache can be fetched at Apache Lounge. We use their binaries to build the Apache SAPIs.

    如果以apache服务器的话就下载vc6的

那么我就下载了 PHP 5.2 (5.2.17) 下  VC6 x86 Thread Safe (2011-Mar-22 13:29:30)

为什么要下载Thread Safe呢 是因为

Non Thread Safe版的php在安装过程中,没有Apache的选项
  3. 都安装完成后 就可以开始修改配置文件 完成php的配置
        在环境变量中 path中增加 F:/php;f:/php/ext;
       在F:/php(php解压目录)下 找到 php.ini-dist       然后copy改名为php.ini 然后打开 其余的参数就不说了也没仔细研究
     找到extension 然后在extension=php_mysql.dll 去掉前面的分号 因为要使用mysql作为数据库,其余的扩展可自行去掉注释,看自己的使用需求。
     还有extension_dir = "F:/php/ext" 改为这样 以防找不到扩展dll
     然后保存php.ini 然后copy一份到c:/windows下去 如果出现这模块或那模块不支持的错误 可在将用到的ddl    copy到一份去c:/windwos/system32下
   4.开始配置apache的配置 使之支持php
          在conf下httpd.conf中查找DirectoryIndex 修改为
            <IfModule dir_module>                    DirectoryIndex index.php index.html  index.htm          </IfModule>
       此为首页加载顺序。
    再找到 DocumentRoot 此为网站目录 即你放置php文件的位置 根据自己的需求修改 默认指向 Apache2.2/htdocs。
    在查找AddType 在此下 增加AddType application/x-httpd-php .php .phtml 可根据需求增加支持 ,此配置说明此服务器可解析php的文件类型 如果添加txt则文本文件也可支持php
 最后就是和php的结合了 查找LoadModule 增加两行配置
LoadModule php5_module "F:/php/php5apache2_2.dll"PHPIniDir "F:/php/"
       对php的支持
此时配置就完成了 保存 重启apache服务器
                     
        然后在F:\Program Files\Apache Software Foundation\Apache2.2\htdocs目录 
编辑test.php 此目录为我设定访问php的目录
        在test.php中 输入
 <?php   phpinfo();?>
      访问http://localhost:8180/test.php 8180是我设置的服务器端口号 则会看到一大堆的php信息 则说明配置成功,然后就可以开发或运行php的软件或文件
 备注:将php目录下的libmysql.dll , php5ts.dll       php/ext目录下的php_gd2.dll ,php_mbstring.dll,php_mysql.dll
copy到c:/windows/system32下,否则可能出现 httpd.exe的错误 导致mysql使用出现问题等
    
 
  
    

   

原创粉丝点击