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数学运算
Dec 30 PHP
PHP获取中英混合字符串长度的方法
Jun 07 PHP
初识laravel5
Mar 02 PHP
php实现二进制和文本相互转换的方法
Apr 18 PHP
php实现Session存储到Redis
Nov 11 PHP
php通过文件头判断格式的方法
May 28 PHP
Thinkphp微信公众号支付接口
Aug 04 PHP
Laravel 5.5基于内置的Auth模块实现前后台登陆详解
Dec 21 PHP
tp框架(thinkPHP)实现三次登陆密码错误之后锁定账号功能示例
May 24 PHP
PHP APP微信提现接口代码
Sep 30 PHP
不常用但很实用的PHP预定义变量分析
Jun 25 PHP
php实现自动生成验证码的实例讲解
Nov 17 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
Laravel配置全局公共函数的方法步骤
2019/05/09 PHP
PHP利用pdo_odbc实现连接数据库示例【基于ThinkPHP5.1搭建的项目】
2019/05/13 PHP
docker-compose部署php项目实例详解
2019/07/30 PHP
PHP单文件上传原理及上传函数的封装操作示例
2019/09/02 PHP
js压缩工具 yuicompressor 使用教程
2010/03/31 Javascript
High Performance JavaScript(高性能JavaScript)读书笔记分析
2011/05/05 Javascript
JS隐藏参数post传值实例
2013/04/18 Javascript
js实现在字符串中提取数字
2013/11/05 Javascript
JavaScript将XML转成JSON的方法
2015/03/12 Javascript
JS+CSS实现简易的滑动门效果代码
2015/09/24 Javascript
JavaScript构造函数详解
2015/12/27 Javascript
javascript实现随机显示星星特效
2016/01/28 Javascript
JavaScript实现短暂提示框功能
2018/04/04 Javascript
vue better scroll 无法滚动的解决方法
2018/06/07 Javascript
js与jQuery实现获取table中的数据并拼成json字符串操作示例
2018/07/12 jQuery
JavaScript实现图片轮播特效
2019/10/23 Javascript
实现vuex原理的示例
2020/10/21 Javascript
Nuxt的路由动画效果案例
2020/11/06 Javascript
[15:07]lgd_OG_m2_BP
2019/09/10 DOTA
[48:31]完美世界DOTA2联赛PWL S3 DLG vs Phoenix 第二场 12.17
2020/12/19 DOTA
Python实现竖排打印传单手机号码易撕条
2015/03/16 Python
Python中字符串的格式化方法小结
2016/05/03 Python
Python数据分析之真实IP请求Pandas详解
2016/11/18 Python
python实现根据文件格式分类
2019/10/31 Python
python实现计算图形面积
2021/02/22 Python
建筑装饰学院室内设计专业个人自我评价
2013/12/07 职场文书
给女朋友的道歉信
2014/01/10 职场文书
数控专业自荐书范文
2014/03/16 职场文书
2014年电厂工作总结
2014/12/04 职场文书
中秋联欢会主持词
2015/07/04 职场文书
户外拓展训练感想
2015/08/07 职场文书
《颐和园》教学反思
2016/02/19 职场文书
如何使用Python实现一个简易的ORM模型
2021/05/12 Python
python 对图片进行简单的处理
2021/06/23 Python
《艾尔登法环》Boss腐烂树灵很有可能是《黑暗之魂3》的一个废案
2022/04/11 其他游戏
python实现双向链表原理
2022/05/25 Python