首 页   · 站长博客 · 用户注册 · 会员登陆  · 会员排行  ·最新主题  ·最近回复  精华区  版权声明  ·论坛管理
  当前登录身份:游客,请先登录。  笔名: 口令: 验证码:   
楼 主  index »  PHP安装/语法/函数 » [原创]Apache+PHP5+MySQL安装指南  


  作者:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

  nqp@nqp.me
  4304410
  www.nqp.me

 

 发表:2004-08-07 19:05:20 阅读 3427 次 回复 5 次 得分3  |   字号 字色
[原创]Apache+PHP5+MySQL安装指南
-----------------------------------------------------
站长按:最近,咨询有关php5和mysql,apache的问题比较多。
由于php5尚为测试版本,迄今为止php最稳定版本为php4.3.7
所以站长一直没有对php5下功夫,但是最近php5使用渐广,
因此站长搜集此文章,以飨读者。
-----------------------------------------------------


WinXp sp1 + apache2.0.47 + php5.0.0b1 + mysql-4.0.14 + phpMyAdmin-2.5.3-rc1 安装全功略 
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.

--------------------------------------------------------
到 www.jetdown.com 下载下面三种软件,做好安装准备

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:phpdlls目录下的所有文件到windows安装目录的系统文件夹里
(win9x/me是system目录,winNT,2k/winXP,2003是system32目录)

复制C:phpphp.ini-dist到windows安装目录下(如:c:windows),并将其改名为php.ini。用记事本打开,修改一下信息:
  搜索extension_dir = ./ 这行,并将其路径指到你的PHP目录下的extensions目录,比如:
  extension_dir = C:phpextensions

  如若想支持更多模块,,搜索:
;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 FilesApache GroupApache2confhttpd.conf 文件。
2.用记事本打开C:Program FilesApache GroupApache2confhttpd.conf
找到:
#NameVirtualHost *
修改为:
NameVirtualHost 127.0.0.1 //或localhost
找到:
<VirtualHost 127.0.0.1>
修改下面几行:
ServerAdmin (你刚才安装时候输入的管理员信箱)
DocumentRoot C:Program FilesApache GroupApache2htdocs
ServerName Apache2
ErrorLog C:Program FilesApache GroupApache2logserror_log
CustomLog C:Program FilesApache GroupApache2logsaccess_log common
</VirtualHost>
找到:
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:phpsapiphp4apache2.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 FilesApache GroupApache2htdocs目录下,这个目录就是你的站点跟目录,命名为phpinfo.php.然后在浏览器中输入http://localhost/phpinfo.php 就可以看到想尽的关于PHP的信息了。

phpinfo.php代码如下: 
<?php

phpinfo();

?> 

<4>安装mysql 

1.按默认安装在C:mysql

Copy the following files to the Apache modules directory:

phpphp4ts.dll
phpsapiphp4apache2.dll
phpdllsiconv.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 'cphpextensionsphp_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:phpextensionsphp_mysql.dll" - The specified procedure could not be found."

Start Apache and everything should be fine.

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

+-----------+ 
│ Databases │ 
+-----------+ 
│ mysql │ 
│ test │ 
+-----------+ 

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

2.更改MySQL系統之管理者密碼(新密碼的地方,換成您要設定的密碼)
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 FilesApache GroupApache2htdocsphpMyAdminconfig.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'; 將 『 config 』改為 『 cookie 』或 『 http 』
找到$cfg['Servers'][$i]['host'] = 'localhost'; 视情况做相应修改
找到$cfg['Servers'][$i]['user'] = 'root'; 视情况做相应修改
找到$cfg['Servers'][$i]['password'] = ''; 视情况做相应修改
找到$cfg['Servers'][$i]['port'] = '3306'; 视情况做相应修改

其它略.

如要转载,请保证文章完整
Document BY:Daniel John
QQ:1381717;172000
E-mail:gigifan@msn.com
latest update:18:41 2003-9-10
 
 1#楼  
 
  回复人:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

   
 1#楼 发表于2004-08-07 19:29:51  评分:× 

文章开始有一段英文,对理解该文章有重要用途,因此站长粗略翻译如下,仅供参考:

 ---------------------------------------------------
  我终于使得这个(php5环境)可以工作了,所以我把我的发现贴到这里。
  对于php5,windows版本的需要一个MYSQL DLL(动态连接库)。
  php5.0并不伴随(come with)mysql支持,你必须自己获得这些库文件。
  我想你可以从mysql.com获得它们(mysql库)。

  对于PHP 5 Beta 2 
  文件 php_mysql.dll 与php5 beta 2 的一些 snapshots 同时发行,这个php_mysql.dll好像是一个新版本的libmySQL.dll(站长注:libmysql.dll是mysql系统最重要的一个动态连接库,里面提供了所有的mysql函数接口) 
 所以我建议你完全升级到beta2,而最好不要仅仅解压缩php_mysql.dll而继续使用beta1。

 ---------------------------------------------------

以上解释,可以使大家对安装PHP5有一定的了解。尤其是关于php_mysql.dll的问题,大家必须有一个认识。php5不再直接支持mysql,需要你下载相关组件。

 2#楼  
 
  回复人:阿代
  注册时间:2004-11-04
  主题/回复:22/32
  积分:542
  等级:★★☆(五级)
  称号:略有小成

   
 2#楼 发表于2004-11-06 21:17:56  评分:1 

站长:
    上文中有很多细微的错误,我按照其设置,但apache根本就不工作!
 3#楼  
 
  回复人:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

   
 3#楼 发表于2004-11-10 17:23:33  评分:× 

哦?这个是按照PHP5配置的。
不知道你的是不是?
如果哪些地方有错误,可以给他纠正一下,贴出来让大家都看一下,避免犯同样的错误。
 4#楼  
 
  回复人:moodboy
  注册时间:2004-11-22
  主题/回复:24/33
  积分:553
  等级:★★★(六级)
  称号:声名鹊起

   
 4#楼 发表于2004-11-25 23:12:18  评分:1 

如果MYSQL不和PHP设置就不能访问了吗?
 5#楼  
 
  回复人:achang
  注册时间:2008-01-25
  主题/回复:0/4
  积分:31
  等级:★(二级)
  称号:初出茅庐

   
 5#楼 发表于2008-01-25 22:18:16  评分:1 

回复给4#楼

 如果你指的是:


.编辑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 设置管理员的口令

那么不配置是可以访问的。

 

  页数1/1首页 « 1 » 末页
  发表回复:您还没有登陆,无法发表回复。请先[登陆]

一起PHP技术联盟 主办:一起PHP 联系方式:站长QQ:4304410 QQ群:8423742 20159565 站长博客 E-mail: nqp@nqp.me 执行时间:0.018sec
SimsmaBBS 2008 (v6.0) Developed by 17php.com,Copyright(C)2003-2010 All rights reserved. 副本授权:一起PHP官方专用版