首页 > 编程技术 > php

Windows2000下安装PHP4及MySQL大揭密

发布时间:2016-11-25 15:28

我的php4和mysql的软件包是php-4.0.1pl2-Win32.zip、mysql-3.23.19-beta-win.zip。

先安装mysql,用winzip8.0打开软件包进行完全安装,默认安装路径为:c:mysql;
安装完成后,打开“开始”按钮中的“运行”,输入命令:C:mysqlinmysqld-nt.exe --install,并执行;
打开“开始”按钮下的“程序”=》“治理工具”=》“服务”,找到“mysql”服务,启动它;
至此,mysql安装完成,重启win2000adanced server。您还可以打开C:mysqlinwinmysqladmin.exe,在第一次用它时,需要建立治理员名及密码,我分别设置为root和(yourpassword)。关闭它后,程序自动在状态行下建立一个“红绿灯”的小图标。
现在开始安装php4,将软件包先用winzip解压到c:php4下,再将目录下的所有dll文件拷到c;winntsystem32下,不要覆盖已有的dll文件;接着将目录下的php.exe和php.ini-dist两个文件拷到c:winnt下;
将c:winntphp.ini-dist改名为php.ini,并打开它,找到;Windows Extensions,将extension=php_calendar.dll、extension=php_zlib.dll、extension=php_ldap.dll前的“;”去掉,关闭该文件。
打开“开始”按钮下的“程序”=>“治理工具”=>“internet服务治理器”,选中“默认web站点”,打开它的“属性”窗口。在“web站点”页下,改变“IP地址”:“全部未分配”为“(您机子的ip地址,例如:202.195.243.131)”;“TCP端口”为“80”。
接着,选中“主目录”页,单击“应用程序设置”下的“配置”按钮后,在新窗口下单击“添加”按钮;在“可执行文件”中输入“C:WINNTphp.exe %s %s”,在“扩展名”中输入“.php”,点击“确定”。
接着,选中“ISAPI筛选器”页,单击“添加”按钮;在“筛选器名称”中输入“php”,在“可执行文件”中输入“C:WINNTsystem32php4isapi.dll”,点击“确定”。
接着,选中“文档”页,单击“添加”按钮;在“默认文档名”中输入“index.php”,点击“确定”,并将其提高到最高级。您还可以添加常用的php文件名,如:“default.phtml”、“index.php3”等。
关闭所有窗口,重启系统后,可打开IE浏览器进行测试。

软件获得:国外http://www.php.net;国内http://www.111cn.net, http://phpuser.com等得到压缩包以后解压缩到c:php4目录下.
拷贝php4ts.dll,msvcrt.dll到C:windowssystem
把php.ini-dist改名为php.ini拷贝到c:windows
编辑这个文件,很简单,只要更改少许几个选项.
extension_dir = c:php4
extension =php_ldap.dll
extension =php_zlib.dll
extension =php_calendar.dll
extension =php_exif.dll
extension =php_ftp.dll
extension =php_mssql70.dll
extension =php_imap.dll
有就去掉前面的分号,没有就自己加上。建议先不要更改这个部分,否则轻易出现错误.
这里出现:

X-Powered-By: PHP/4.0.0
Content-type: text/html

就是因为在php.ini文件中指定加载了无效的或者不存在的php_*.dll 文件,加载这些错误信息还可能导致浏览器寻找不到服务器.在经历了漫长而艰苦的等待以后,IE对你说:
兄弟! 找不到服务器!请节哀顺便.....哈哈!
完了就这么简单,还有了,
假如你用的WEB Server是PWS, 那么还要更改一个地方!
browscap = C:windowssysteminetsrvrowscap.ini
并且修改一下PWS-php4.reg 文件
".php"=" [PUT PATH HERE]\php4isapi.dll"
改为
".php"="C:\php4\ php4isapi.dll"
只需指出php4isapi.dll文件的位置
还可以填加对其他后缀名,具体文件为:
REGEDIT4
[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices
w3svcparametersScript Map]
".php"="C:\php4\ php4isapi.dll"
".php3"="C:\php4\ php4isapi.dll"
".php4"="C:\php4\ php4isapi.dll"
".phtml"="C:\php4\ php4isapi.dll"

保存退出,双击执行,写入注册表!
其他细部设置:
asp_tags = On ; 答应使用ASP风格的标记<% %>
upload_max_filesize = 2097152;上载文件的最大字节
mysql.default_host = localhost;
mysql.default_user = root;
mysql.default_password= yourpasswd;
以上关于mysql的设置可以在my.cnf中完成.这里只给出了很少的部分,其它内容的设置还要靠大家自己去摸索!
include_path = path1;path2;path3....
在您使用include函数时,只有被指定的目录下的文件才可以被包含.
关于doc_root与user_dir的设置方法.
设置了doc_root以后,只有doc_root目录下面的php文件可以执行!
比如doc_root=c:php4 est
那么PHP文件只有放到这个目录下面才能被解释执行.
当没设置user_dir时,被控制文件读取的是doc_root。
如http://localhost/doc.php3这个URL,打开了 c:php4 est下面的doc.php3文件,而不是c:program
files....htdocs下面的doc.php3文件。关于 user_dir的设置问题,本人还是没有搞清楚,希望高手指教!
2.安装APACHE1.3.12

软件获得:http://www.apache.org;http://www.111cn.net; http://phpuser.com;http://www.phpsite.net。

软件的安装很简单,下载完后直接双击执行安装.
配置conf目录下的httpd.conf文件.
#BindAddress *改为 BindAddress 127.0.0.1
#Servername new.host.name改为Servername localhost
出现类似的错误的原因可能就是没有指定servername.
"cannot determine local host name,use servername to set it manually"

好了,你的apache已经可以运行了!
运行你的apache.应该显示:
Apache/1.3.12 (Win32) running...
注重,这里假设您的APACHE是安装在默认目录下即:
C:/Program Files/Apache Group/Apache
否则文档中的serverroot以及docmentroot 等也要更改。比如你是安装在c:apache下.那么
serverroot = c:/apache docmentroot = c:/apache/htdocs
其他选项依次类推
假如你的机器还安装了别的服务器程序,而你又希望他们共同为你效劳那么你就必须改一下port ,默认为80,你可以改为81或者8080. 不要使用其他一些常用的端口比如21,23,
25等(废话^_^).

好了,下面让你的APACHE来支持PHP4. 加上下面这么几句,基本上就可以了!

ScriptAlias /php4/ "C:/php4/"
AddType application/x-httpd-php4 .php
AddType application/x-httpd-php4 .php3
AddType application/x-httpd-php4 .php4
Action application/x-httpd-php4 "/php4/php.exe"

;不要写成
;Action application/x-httpd-php4 "c:/php4/php.exe"
;否则会出错的.
在httpd.conf中分别找到相似的行,加进去,这样轻易维护一些. 关于默认启动文档:apache的默认启动文档为index.html DirectoryIndex
index.html 把它改为你想要的默认启动文档
想要支持更多文档要象这样:
DirectoryIndex index.htm
DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.php4
完成了! 写一个测试文件:

<?
phpinfo();
?>
保存为info.php

在浏览器中输入http://localhost/info.php
别忘了要先运行APACHE啊!
3.安装PWS
软件获得:WIN98光盘add-onspws目录内。呵呵,直接setup就可以了,无须配置!安装完了后,运行PWS,点高级建立一个虚拟目录,点编辑属性修改其属性.默认为读取和脚本中间还有一个执行,在前面打上勾,把它选上 .这个目录下面的PHP4文件就可以运行了!

注重在PHP.INI文件中设置
browscap = C:windowssysteminetsrvrowscap.ini
假如没有设置的话,PHP4是不可能跑起来的.
4.安装MYSQL(mysql-3.23.21-beta-win)

软件获得:国外http://www.mysql.com; 国内http://www.111cn.net;http://phpuser.com, http://www.phpsite.net。

运行setup文件执行安装,完毕后应该没有任何提示,这时mysql
已经安装到你的系统中去了,默认目录为:c:mysql
在c:mysql下有一个文件my-example.cnf改名为 my.cnf拷贝到c:下面.
无须修改!!!
可以加入用户名,密码,登陆主机,数据库和端口等信息!
到c:mysqlin目录下. 双击mysqld执行!正常情况下DOS窗口一闪而过. 建议打开一个MS-DOS窗口在c:mysqlin>提示符下输入

内容:一、 安装APACHE1.3.9(配置conf目录下的httpd.conf文件)
1.#BindAddress * 改为 BindAddress 127.0.0.1
#Servername new.host.name 改为 Servername localhost
2.让你的APACHE来支持PHP4. 加上下面这么几句:
ScriptAlias /php4/ "C:/php4/"
AddType application/x-httpd-php4 .php
AddType application/x-httpd-php4 .php3
AddType application/x-httpd-php4 .php4
Action application/x-httpd-php4 "/php4/php.exe"
3.设置Apache虚拟目录,加入以下行:
Alias /test/ "c:/php3/test/"
Alias /jjjj/ "d:/timenet/"
4.增加默认启动文档:
DirectoryIndex index.html
DirectoryIndex index.htm
DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.php4
5.测试文件info.php:
在浏览器中输入http://localhost/info.php
二、php4安装(php-4.0.2pl2-Win32.zip)
1. 将软件包解压到c:\php4下。
2. 再将目录下的所有dll文件拷到c;\winnt\system32下,不要覆盖已有的dll文件。将目录下的php.exe和php.ini-dist两个文件拷到c:\winnt下;
3. 将winnt\php.ini-dist改名为php.ini,并找到;Windows Extensions项将
extension_dir = c:\php4
extension=php_zlib.dll
extension =php_ldap.dll
extension =php_zlib.dll
extension =php_calendar.dll
extension =php_exif.dll
extension =php_ftp.dll
extension =php_mssql70.dll (这一项不要加,没有MSSQL7.0呀)
extension =php_imap.dll
有就去掉前面的分号,没有就自己加上。这个部分轻易出现错误,是因为在php.ini文件中指定加载了无效的或者不存在的php_*.dll文件,加载这些错误信息还可能导致浏览器寻找不到服务器。
4. PHP.INI其他设置:
asp_tags = On ; 答应使用ASP风格的标记
upload_max_filesize = 2097152;上载文件的最大字节
(关于mysql的设置)
mysql.default_host = localhost;
mysql.default_user = root;
mysql.default_password= yourpasswd; 以上
(在您使用include函数时,只有被指定的目录下的文件才可以被包含)
include_path = \path1;\path2;\path3....
(只有c:\php4\test目录下面的php文件才可以执行)
doc_root= c:\php4\test
三、MySQL安装(mysql-3.23.27-beta-win.zip)
1. 先安装mysql,默认安装路径为:c:\mysql
2. 打开“运行”输入C:\mysql\bin\mysqld-nt.exe ?install
3. 打开“治理工具”->“服务”,找到“mysql”服务,启动它。重启windows2000。

 

 

FCKeditor目前最新的版本是2.5.1,我花了点时间将里面一些文件进行了修改,更适合实际的应用.具体的修改过程请看说明,也可以直接下载修改后的程序,见附件.

1.删除editor/_source 目录
这是FCKeditor的源码,可以删除

2.删除editor/lang 目录中除en/zh/zh-cn的语言文件

3.删除editor/filemanage/connectors 除php的目录

4.修改fckconfig.js

修改默认语言.注:这一步应该可以忽略,FCKeditor好像会自动匹配浏览器的语言
找到


FCKConfig.DefaultLanguage = 'en' ;
修改为:


FCKConfig.DefaultLanguage = 'zh-cn' ;
扩展字体,增加常用中文字体
找到


FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
修改为:


FCKConfig.FontNames = '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
修改字号,FCKeditor中的字号是用"smaller;larger;xx-small;"等名称表示,不够直观,我们将其改成数字+px的形式
找到


FCKConfig.FontSizes = 'smaller;larger;xx-small;x-small;small;medium;large;x-large;xx-large' ;
修改为


FCKConfig.FontSizes  = '9px;10px;11px;12px;13px;14px;16px;18px;24px;36px' ;
5.修改editor/filemanage/connectors/php/config.php
FCKeditor默认是关闭文件上传的,如果要打开,必须修改这个文件
找到


$Config['Enabled'] = false ;
修改为


$Config['Enabled'] = true ;
6.修改editor/filemanage/connectors/php/io.php
FCKeditor在上传文件是不对文件名进行重命名,这会影响到用中文名命名的文件
找到

PHP代码:
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( $sNewFileName )
{
 global $Config ;
 $sNewFileName = stripslashes( $sNewFileName ) ;
 // Replace dots in the name with underscores (only one dot can be there... security issue).
 if ( $Config['ForceSingleExtension'] )
  $sNewFileName = preg_replace( '/\.(?![^.]*$)/', '_', $sNewFileName ) ;
 // Remove  / | : ? * " < >
 $sNewFileName = preg_replace( '/\\|\/|\||\:|\?|\*|"|<|>/', '_', $sNewFileName );
 return $sNewFileName ;
}


修改为

PHP代码:
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( $sNewFileName )
{
 global $Config ;
 $sNewFileName = stripslashes( $sNewFileName ) ;
 // Replace dots in the name with underscores (only one dot can be there... security issue).
 if ( $Config['ForceSingleExtension'] )
  $sNewFileName = preg_replace( '/\.(?![^.]*$)/', '_', $sNewFileName ) ;
 $sExtension = substr( $sNewFileName, ( strrpos($sNewFileName, '.') + 1 ) ) ;
 $sNewFileName = my_setfilename().'.'.$sExtension;
 return $sNewFileName ;
}
function my_setfilename(){
 $gettime = explode(' ',microtime());
 $string = 'abcdefghijklmnopgrstuvwxyz0123456789';
 $rand = '';
 for ($x=0;$x<6;$x++)
  $rand .= substr($string,mt_rand(0,strlen($string)-1),1);
 return date("ymdHis").substr($gettime[0],2,6).$rand;
}


7.FCKeditor在上传文件时出现的一些提示框为英文,为了方便使用,可以选择将这些提示汉化,如果不需要,可以忽略这一步
具体是修改以下文件:
editor/filemanage/connectors/php/commands.php
editor/filemanage/connectors/php/connector.php
editor/filemanage/connectors/php/upload.php
editor/dialog/fck_flash/fck_flash.js
editor/dialog/fck_image/fck_image.js
editor/dialog/fck_link/fck_link.js

昨天公司突然要一个上传文件带附件,还要一个带图片上传功能并且要生成缩略图效果,下面我就把我的代码贴出来吧.

首先来看看up.htm文件,代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<form action="s.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <input type="file" name="image" id="image" />
  <label>
  <input type="submit" name="button" id="button" value="提交" />
  </label>
</form>
<label></label>
</body>
</html>
其实上页就是一个简单的htm 文件,把信息post给我们下面要讲到的文件s.php

if($_FILES['image']['name']){
    if($_FILES['image']['size']){
    if($_FILES['image']['type'] == "image/pjpeg"){
     $im = @imagecreatefromjpeg($_FILES['image']['tmp_name']);
     $n_bmp.='.jpg';
    }elseif($_FILES['image']['type'] == "image/x-png"){
     $im = @imagecreatefrompng($_FILES['image']['tmp_name']);
     $n_bmp.='.png';
    }elseif($_FILES['image']['type'] == "image/gif"){
     $im = @imagecreatefromgif($_FILES['image']['tmp_name']);
     $n_bmp.='.gif';
    }    
    }
    ResizeImage($im,120,60,md5(date("Y-m-d H:i:s")));    
    ImageDestroy ($im);
    $tag=1;
   }

 

function ResizeImage($im,$maxwidth,$maxheight,$name){
   $width = imagesx($im);
   $height = imagesy($im);
  if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
   if($maxwidth && $width > $maxwidth){
   $widthratio = $maxwidth/$width;
   $RESIZEWIDTH=true;
   }
   if($maxheight && $height > $maxheight){
   $heightratio = $maxheight/$height;
   $RESIZEHEIGHT=true;
   }
  if($RESIZEWIDTH && $RESIZEHEIGHT){
  if($widthratio < $heightratio){
   $ratio = $widthratio;
   }else{
   $ratio = $heightratio;
   }
  }elseif($RESIZEWIDTH){
  $ratio = $widthratio;
  }elseif($RESIZEHEIGHT){
  $ratio = $heightratio;
  }
  $newwidth = $width * $ratio;
  $newheight = $height * $ratio;
  if(function_exists("imagecopyresampled")){
  $newim = imagecreatetruecolor($newwidth, $newheight);
  imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  }else{
  $newim = imagecreate($newwidth, $newheight);
  imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  }
  ImageJpeg ($newim,$name . ".jpg");
  ImageDestroy ($newim);
  }else{
  ImageJpeg ($im,$name . ".jpg");
  }
  }

 

就这么简单了,上页这种就是生成文件到目录了,还有一种就生成二进制在网页显示,当然你也可以保存到数据库了.然后读出.

标签:[!--infotagslink--]

您可能感兴趣的文章: