WinXP + Apache +PHP5 + MySQL + phpMyAdmin安装全功略


Posted in PHP onJuly 09, 2006

I finally got this to work, so I will post my findings here. 

//PHP 5 : Windows build needs a MySQL DLL 
//PHP 5.0 doesn't come with mysql support... You have to get the librariesyourself...  
//I think u can get them from mysql.com 

// PHP 5 Beta 2  
//The file php_mysql.dll comes with these snapshots, as well as a new version of libmySQL.dll,  
//so I suggest a full upgrade to Beta 2 instead of just extracting php_mysql.dll for use with Beta 1. 

-------------------------------------------------------- 
下载下面三种软件,做好安装准备 

apache_2.0.47-win32-x86-no_ssl.msi 
mysql-4.0.14-win.zip 
phpMyAdmin-2.5.3-rc1-php.zip 
---------------------------------------------------------------------------------------------- 
PHP 5 Beta 2 http://snaps.php.net/win32/php5-win32-latest.zip size:5.87 MB (6,162,835 bytes) 
---------------------------------------------------------------------------------------------- 

<1>安装配置PHP 

1.解压缩PHP压缩包到C:\php\ 

2.复制C:\php\目录下的php4ts.dll及C:\php\dlls目录下的所有文件到windows安装目录的系统文件夹里 
(win9x/me是system目录,winNT,2k/winXP,2003是system32目录) 

复制C:\php\php.ini-dist到windows安装目录下(如:c:\windows),并将其改名为php.ini。用记事本打开,修改一下信息: 

搜索extension_dir = ./ 这行,并将其路径指到你的PHP目录下的extensions目录,比如: 

extension_dir = C:\php\extensions 

如若想支持更多模块,,搜索: 
;Windows Extensions 
;Note that MySQL and ODBC support is now built in, so no dll is needed for it. 

下面都用分号在前面注释掉了支持的扩展模块,如果你想PHP支持某个模块,请将前面的“;”去掉即可 
修改完成后,保存php.ini,到此完成PHP的安装和配置。 
我们在下面加入一行 

extension=php_mysql.dll 

//Note 1: The extension dir need not be ".\", as Hermawan mentioned. It works fine for me with the extensions subdir where the other extensions are located. 

//Note 2: The php.ini file need not be in the Apache root, as lars mentioned. It works fine for me in the Windows dir. 

<2>安装Apach2 
1.备份 C:\Program Files\Apache Group\Apache2\conf\httpd.conf 文件。 
2.用记事本打开C:\Program Files\Apache Group\Apache2\conf\httpd.conf 
找到: 

#NameVirtualHost * 


修改为: 

NameVirtualHost 127.0.0.1 //或localhost 


修改下面几行: 

ServerAdmin (你刚才安装时候输入的管理员信箱) 
DocumentRoot C:\Program Files\Apache Group\Apache2\htdocs 
ServerName Apache2 
ErrorLog C:\Program Files\Apache Group\Apache2\logs\error_log 
CustomLog C:\Program Files\Apache Group\Apache2\logs\access_log common 

找到: 
AddType application/x-tar .tgz 
在下面添加以下两行: 
AddType application/x-httpd-php .php 
AddType image/x-icon .ico 

找到: 
#LoadModule ssl_module modules/mod_ssl.so 
在下面添加一行: 
LoadModule php5_module C:\php\sapi\php4apache2.dll //这里php5_module是关键,如果php4_module apache就无法启动了  

增加默认文件: 
找到DirectoryIndex * 这行,可以这样修改,添加默认的文件名: 
DirectoryIndex index.php default.php index.htm index.html default.htm default.html 
保存文件,重起apache服务器。 

最后,在该文件末尾加上下面两行 

ScriptAlias /php/ "c:/php/" 
Action application/x-httpd-php "/php/php.exe“ 

到此Apache的PHP环境已经完全建立了。 

<3>测试: 

用记事本新建个文件,写下下面几行,保存到C:\Program Files\Apache Group\Apache2\htdocs目录下,这个目录就是你的站点跟目录,命名为phpinfo.php.然后在浏览器中输入http://localhost/phpinfo.php 就可以看到想尽的关于PHP的信息了。 

phpinfo.php代码如下:  

<?

phpinfo(); 

?>

  

<4>安装mysql  

1.按默认安装在C:\mysql 

Copy the following files to the Apache modules directory: 

  • php\php4ts.dll 
  • php\sapi\php4apache2.dll 
  • php\dlls\iconv.dll 

If any of these files are missing in the modules directory, Apache will fail to start. 

Be sure the extension can find the following files: 

  • php_mysql.dll  
  • iconv.dll 
  • libmySQL.dll 

If any of them can't be found, Apache will start but will issue a warning like this: "Unknown(): Unable to load dynamic library 'c\php\extensions\php_mysql.dll" - The specified module could not be found." 

php_mysql.dll should be in the extensions directory. 

iconv.dll should be in the Apache modules directory. 

libmySQL.dll must be either in the Apache root directory or the Windows system directory. I prefer the former because it's cleaner, as other applications don't necessarily use this MySQL library version. 

Note 3: Be sure to use the libmySQL.dll file bundled with PHP. In my case, trying to use the libmySQL.dll from the MySQL 4.1 alpha package resulted in this error message: "Unknown(): Unable to load dynamic library 'c:\php\extensions\php_mysql.dll" - The specified procedure could not be found." 

Start Apache and everything should be fine. 

2.运行C:\mysql\bin\winmysqladmin.exe 设定user 和password 
3.运行mysql,测试一下 
mysql> show databases; 

+-----------+  
| Databases |  
+-----------+  
| mysql |  
| test |  
+-----------+  

如果出现以上画面,表明mysql已经安装成功;  

2.更改MySQL系?之管理者密?(新密?的地方,?Q成您要?定的密?) 
mysql> UPDATE user SET password=password('新密?') where user='root'; 

3.编辑php5中的启动文件php.ini,将mysql和php5连接起来. 
mysql.default_port= 
mysql.default_host= 
mysql.default_user= 
mysql.default_password= 
改为: 
mysql.default_port=3306 说明的是mysql的缺省端口一般为3306  
mysql.default_host=localhost 说明的是mysql的缺省主机名称 
mysql.default_user=jinchao 说明的是mysql的缺省的用户名(root是最高级用户) 
mysql.default_password=666666 设置管理员的口令 

修改完后将apache重启,查看phpinfo页面. 

<5>安装phpmyadmin 

修改 C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin\config.inc.php  
查找以下这么一段: 
$i = 0; 
// The $cfg['Servers'] array starts with $cfg['Servers'][1]. Do not use $cfg['Servers'][0]. 
// You can disable a server config entry by setting host to ''. 
在这段之后再继续查找: 

找到 $cfg['Servers'][$i]['auth_type'] = 'cookie'; ??nbsp;『 config 』改??nbsp;『 cookie 』或 『 http 』 
找到$cfg['Servers'][$i]['host'] = 'localhost'; 视情况做相应修改 
找到$cfg['Servers'][$i]['user'] = 'root'; 视情况做相应修改 
找到$cfg['Servers'][$i]['password'] = ''; 视情况做相应修改 
找到$cfg['Servers'][$i]['port'] = '3306'; 视情况做相应修改 

PHP 相关文章推荐
PHP脚本的10个技巧(6)
Oct 09 PHP
PHP学习资料汇总与网址
Mar 16 PHP
PHP 危险函数解释 分析
Apr 22 PHP
PHP 5.3 下载时 VC9、VC6、Thread Safe、Non Thread Safe的区别分析
Mar 28 PHP
微信支付开发教程(一)微信支付URL配置
May 28 PHP
PHP间隔一段时间执行代码的方法
Dec 02 PHP
基于Swoole实现PHP与websocket聊天室
Aug 03 PHP
Yii框架创建cronjob定时任务的方法分析
May 23 PHP
PHP __call()方法实现委托示例
May 20 PHP
php实现session共享的实例方法
Sep 19 PHP
php中关于换行的实例写法
Sep 26 PHP
TP5框架model常见操作示例小结【增删改查、聚合、时间戳、软删除等】
Apr 05 PHP
使用Apache的rewrite技术
Jun 22 #PHP
php正则
Jul 07 #PHP
从零开始 教你如何搭建Discuz!4.1论坛
Jul 07 #PHP
php分页函数
Jul 08 #PHP
PHP初学者头疼问题总结
Jul 08 #PHP
最令PHP初学者头痛的十四个问题
Jul 12 #PHP
PHP截取中文字符串的问题
Jul 12 #PHP
You might like
php数组函数序列之array_flip() 将数组键名与值对调
2011/11/07 PHP
php爬取天猫和淘宝商品数据
2018/02/23 PHP
IE8中动态创建script标签onload无效的解决方法
2014/12/22 Javascript
jQuery实现仿Alipay支付宝首页全屏焦点图切换特效
2015/05/04 Javascript
JavaScript实现强制重定向至HTTPS页面
2015/06/10 Javascript
js表单中选择框值的获取及表单的序列化
2015/12/17 Javascript
详解JS正则replace的使用方法
2016/03/06 Javascript
实例讲解JavaScript中的this指向错误解决方法
2016/06/13 Javascript
Select下拉框模糊查询功能实现代码
2016/07/22 Javascript
BootStrap下拉框在firefox浏览器界面不友好的解决方案
2016/08/18 Javascript
基于bootstrap实现bootstrap中文网巨幕效果
2017/05/02 Javascript
Javascript实现的StopWatch功能示例
2017/06/13 Javascript
nodejs模块学习之connect解析
2017/07/05 NodeJs
JavaScript获取移动设备型号的实现代码(JS获取手机型号和系统)
2018/03/10 Javascript
Nuxt.js之自动路由原理的实现方法
2018/11/21 Javascript
vue多个元素的样式选择器问题
2019/11/29 Javascript
基于JS实现计算24点算法代码实例解析
2020/07/23 Javascript
Python实现的手机号归属地相关信息查询功能示例
2017/06/08 Python
python3+selenium实现qq邮箱登陆并发送邮件功能
2019/01/23 Python
解决Python找不到ssl模块问题 No module named _ssl的方法
2019/04/29 Python
PyQt QListWidget修改列表项item的行高方法
2019/06/20 Python
Tensorflow 多线程设置方式
2020/02/06 Python
python interpolate插值实例
2020/07/06 Python
基于python实现计算两组数据P值
2020/07/10 Python
高中英语教学反思
2014/02/04 职场文书
采购经理岗位职责
2014/02/16 职场文书
人力管理专业毕业生求职信
2014/02/27 职场文书
岗位职责风险点
2014/03/12 职场文书
入党积极分子学习两会心得体会范文
2014/03/17 职场文书
小学班干部竞选演讲稿
2014/04/24 职场文书
银行主办会计岗位职责
2014/08/13 职场文书
公司试用期员工自我评价
2014/09/17 职场文书
交警正风肃纪剖析材料
2014/10/29 职场文书
2015年中学元旦晚会活动方案
2014/12/09 职场文书
承诺书范本大全
2015/05/04 职场文书
MYSQL常用函数介绍
2022/05/05 MySQL