Windows環(huán)境下PHP5開發(fā)配置指南
Windows環(huán)境下PHP5開發(fā)配置指南
開發(fā)平臺(tái):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服務(wù)器;3三、;phpMyAdmin的配置;41、;新建WEB虛擬目錄;42、;解壓縮。;43、;配置;44、測(cè)試;4四、;smarty的配置;41、;安裝;42、;配置;43、測(cè)試;5五、;DataObject的配置;51、;下載;52、;安裝;63、;配置;64、;測(cè)試;7
一、PHP的安裝與配置
PHP配置步驟1、PHP5的下載和安裝將解壓縮后的php-5.1.6-Win32中的文件拷貝到C://php5/下面。2、配置PHP復(fù)制 C:PHP5目錄下的 php5ts.dll 文件到c:winntsystem32目錄中。將C:PHP5目錄下的php.ini-recommended文件拷貝到c:WINDOWS中,并改名為php.ini。注意:如果使用了 NTFS,確保運(yùn)行 webserver 的用戶對(duì) php.ini 有讀取的權(quán)限(例如使其對(duì) Everyone 可讀,即將c:WINDOWS設(shè)置為WEB共享)。以下正確加載對(duì)MySQL數(shù)據(jù)庫等的支持模塊。 復(fù)制 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
前的分號(hào)去掉,然后保存文件并退出。 二、配置IIS服務(wù)器 依次點(diǎn)擊“開始/設(shè)置/控制面板/管理工具/Internet服務(wù)管理器/主目錄。 在“主目錄中點(diǎn)擊“配置按鈕,在應(yīng)用程序映射中添加一個(gè)新的條目。用 php5isapi.dll 的路徑作為可執(zhí)行文件(Executable),用 .php 作為文件后綴。其實(shí),就是在默認(rèn)站點(diǎn)下建立虛擬目錄:命名為test,指向D:wwwtest。 (請(qǐng)記住,這個(gè)目錄很重要,下面的配置要用到。)如果你不用 PHP 進(jìn)行 HTTP 認(rèn)證的話,你可以不設(shè)置ISAPI篩選器。 完全停止 IIS 服務(wù),再重新啟動(dòng)IIS服務(wù)。如果還是出現(xiàn)問題,則重新啟動(dòng)電腦。
三、;phpMyAdmin的配置1、;新建WEB虛擬目錄新建WEB虛擬目錄phpMyAdmin指向D:wwwphpMyAdmin。2、;解壓縮。將解壓縮的phpMyAdmin-2.9.0.2文件夾中的所有文件拷貝到該目錄下。3、;配置將該目錄下的config.sample.inc.php文件改名為config.inc.php。并用記事本打開編輯以下項(xiàng)目:$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、測(cè)試開啟瀏覽器,輸入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、測(cè)試打開瀏覽器,輸入 http://localhost/test/index.phpdone …
五、;DataObject的配置1、;下載DataObject是PEAR的一部分。它與另外4個(gè)模塊相關(guān)。所以在安裝它之前,要先安裝PEAR,然后安裝其他4個(gè)模塊:DB、DATE、MDB2、和Validate。如果是PHP5安裝包的話,在C:PHP5 目錄下會(huì)帶有g(shù)o-pear.bat工具。點(diǎn)擊運(yùn)行它,然后在C:PHP5目錄下會(huì)看到pear.bat(真多余,但沒辦法。。。)到http://pear.php.net/packages.php下載5個(gè)包,我下的是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。在命令行模式下,轉(zhuǎn)到C:PHP5。運(yùn)行: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、;配置我的數(shù)據(jù)庫為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
在命令行模式下,轉(zhuǎn)到C:PHP5。運(yùn)行:C:PHPPEARDBDataObject>php createTables.php D:wwwtestdb_bt.ini
4、;測(cè)試編寫測(cè)試文件test.php放到D:wwwtest目錄下,(假設(shè)你的數(shù)據(jù)庫中有'tbBT_User'這個(gè)表);<?phprequire_once('DB/DataObject.php');require('config.php');$tbBT_User = DB_DataObject::factory('tbBT_User');
echo "OK!";?>
打開瀏覽器,輸入 http://localhost/test/test.php
相關(guān)文章:
1. ThinkPHP5 通過ajax插入圖片并實(shí)時(shí)顯示(完整代碼)2. Vue中nvm-windows的安裝與使用教程(親測(cè))3. ThinkPHP5.0之底層運(yùn)行原理執(zhí)行流程分析4. windows java.exe內(nèi)存暴漲解決、idea跑java tomcat內(nèi)存無限增長(zhǎng)5. php5.6不能擴(kuò)展redis.so的解決方法6. .NET6打包部署到Windows Service的全過程7. windows下python 3.9 Numpy scipy和matlabplot的安裝教程詳解8. ThinkPHP5中如何實(shí)現(xiàn)模板完全靜態(tài)化詳解9. Thinkphp5文件包含漏洞解析10. php代碼審計(jì)之ThinkPHP5的文件包含漏洞詳解
