Windows环境下PHP5开发配置指南
Windows环境下PHP5开发配置指南
开发平台:WindowsXP + php-5.1.6-Win32 + mysql-5.0.18-win32+ Smarty-2.6.14 + Date-1.4.6.tar + DB-1.7.6.tar + MDB2-2.3.0.tar + Validate-0.6.5.tar + DB_DataObject-1.8.4.tar工具:phpMyAdmin-2.9.0.2--<目次>—
一、;PHP的安装与配置;31、;PHP5的下载和安装;32、;配置PHP;3二、配置IIS服务器;3三、;phpMyAdmin的配置;41、;新建WEB虚拟目录;42、;解压缩。;43、;配置;44、测试;4四、;smarty的配置;41、;安装;42、;配置;43、测试;5五、;DataObject的配置;51、;下载;52、;安装;63、;配置;64、;测试;7
一、PHP的安装与配置
PHP配置步骤1、PHP5的下载和安装将解压缩后的php-5.1.6-Win32中的文件拷贝到C://php5/下面。2、配置PHP复制 C:PHP5目录下的 php5ts.dll 文件到c:winntsystem32目录中。将C:PHP5目录下的php.ini-recommended文件拷贝到c:WINDOWS中,并改名为php.ini。注意:如果使用了 NTFS,确保运行 webserver 的用户对 php.ini 有读取的权限(例如使其对 Everyone 可读,即将c:WINDOWS设置为WEB共享)。以下正确加载对MySQL数据库等的支持模块。 复制 C:PHP5 目录下的libmysql.dll文件到 C:windowssystem32 目录中。用记事本打开编辑php.ini文件,找到并修改下面两行: ; Directory in which the loadable extensions (modules) reside. extension_dir = "./" 改成: ; Directory in which the loadable extensions (modules) reside. extension_dir = "c:php5ext"再找到下面两行:;Windows Extensions ;Note that ODBC support is built in, so no dll is needed for it.将; extension=php_mbstring.dll ;extension=php_mysql.dll; extension=php_gd2.dll
前的分号去掉,然后保存文件并退出。 二、配置IIS服务器 依次点击“开始/设置/控制面板/管理工具/Internet服务管理器/主目录。 在“主目录中点击“配置按钮,在应用程序映射中添加一个新的条目。用 php5isapi.dll 的路径作为可执行文件(Executable),用 .php 作为文件后缀。其实,就是在默认站点下建立虚拟目录:命名为test,指向D:wwwtest。 (请记住,这个目录很重要,下面的配置要用到。)如果你不用 PHP 进行 HTTP 认证的话,你可以不设置ISAPI筛选器。 完全停止 IIS 服务,再重新启动IIS服务。如果还是出现问题,则重新启动电脑。
三、;phpMyAdmin的配置1、;新建WEB虚拟目录新建WEB虚拟目录phpMyAdmin指向D:wwwphpMyAdmin。2、;解压缩。将解压缩的phpMyAdmin-2.9.0.2文件夹中的所有文件拷贝到该目录下。3、;配置将该目录下的config.sample.inc.php文件改名为config.inc.php。并用记事本打开编辑以下项目:$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin/';$cfg['Servers'][$i]['host']; = 'localhost'; $cfg['Servers'][$i]['port']; = ''$cfg['Servers'][$i]['socket'];;;;;= ''$cfg['Servers'][$i]['connect_type']; = 'tcp';;;;;$cfg['Servers'][$i]['extension'];;= 'mysql';;;$cfg['Servers'][$i]['compress'];;;= FALSE;$cfg['Servers'][$i]['controluser']= ''$cfg['Servers'][$i]['controlpass']= '';$cfg['Servers'][$i]['auth_type'];;= 'cookie';$cfg['Servers'][$i]['user']; = 'root';;;;// MySQL user$cfg['Servers'][$i]['password'];;;= 'rootroot'// MySQL password (only needed)4、测试开启浏览器,输入http://localhost/phpMyAdmin/done ...
四、;smarty的配置1、;安装在D:wwwtest下新建目录comm。从http://smarty.php.net/do_download.php下载最新包,将libs中所有文件 拷入comm目录,完成基本安装.2、配置在D:wwwtest下新建目录cache、config、templates、templates_c在D:wwwtest下新建PHP程序文件index.php。如下:<?php
require 'comm/Smarty.class.php';$smarty = new Smarty;
$smarty->template_dir = 'templates';$smarty->compile_dir = 'templates_c';$smarty->config_dir = 'config';$smarty->cache_dir = 'cache';
$smarty->caching = false;
$smarty->left_delimiter = "<!--";
$smarty->right_delimiter = "-->";
$var = 'Hello World!';$smarty->assign('hello',$var);
$smarty->display('index.tpl');
?>
在D:wwwtest templates下新建模板程序文件index.tpl。如下:<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<title>Smarty</title></head><body><!--$hello--></body></html>3、测试打开浏览器,输入 http://localhost/test/index.phpdone …
五、;DataObject的配置1、;下载DataObject是PEAR的一部分。它与另外4个模块相关。所以在安装它之前,要先安装PEAR,然后安装其他4个模块:DB、DATE、MDB2、和Validate。如果是PHP5安装包的话,在C:PHP5 目录下会带有go-pear.bat工具。点击运行它,然后在C:PHP5目录下会看到pear.bat(真多余,但没办法。。。)到http://pear.php.net/packages.php下载5个包,我下的是DB-1.7.6.tar、Date-1.4.6.tar、MDB2-2.3.0.tar、Validate-0.6.5.tar和DB_DataObject-1.8.4.tar。拷贝到C:PHP5 目录下。这里面,我们要用到的DB_DataObject包必须最后安装。2、;安装依次安装DB、DATE、MDB2、和Validate,最后是DataObject。在命令行模式下,转到C:PHP5。运行:Pear install DB-1.7.6.tar Pear install Date-1.4.6.tar Pear install MDB2-2.3.0.tar Pear install Validate-0.6.5.tar Pear install DB_DataObject-1.8.4.tar OK!3、;配置我的数据库为mysql://custom:123456@localhost/db_bt编写配置文件config.php,放到C:PHP5PEAR目录下。<?phprequire_once 'DB/DataObject.php';$config = parse_ini_file('db_bt.ini',TRUE);
foreach($config as $class=>$values) {;$options = &PEAR::getStaticProperty($class,'options');;$options = $values;}?>
编写INI文件db_bt.ini放到D:wwwtest目录下。[DB_DataObject]database =; mysql://custom:123456@localhost/db_btschema_location; = /dataobjects/schema/class_location= /dataobjects/require_prefix= /dataobjects/class_prefix;;= DataObjects_extends_location = DB/DataObject.phpextends; = DB_DataObject
在命令行模式下,转到C:PHP5。运行:C:PHPPEARDBDataObject>php createTables.php D:wwwtestdb_bt.ini
4、;测试编写测试文件test.php放到D:wwwtest目录下,(假设你的数据库中有'tbBT_User'这个表);<?phprequire_once('DB/DataObject.php');require('config.php');$tbBT_User = DB_DataObject::factory('tbBT_User');
echo "OK!";?>
打开浏览器,输入 http://localhost/test/test.php
相关文章: