Windows XP 下 IIS + APACHE2 + PHP5 + MYSQL5 + PHPMYADMIN 安装配置

2009-03-22 11:20:52 by 【6yang】, 130 visits, 收藏 | 返回

Windows XP 下 IIS + APACHE2 + PHP5 + MYSQL5 + PHPMYADMIN 安装配置

参考了很多文章!当然大多数是别人写的。我写了PHP安装部分,改了一些别人写的不对的地方,添加了一些遇到的问题解决。把一个比较完整的配置方案供大家参考以下。我自己已经全面测试过,没有任何问题。如果有遇到的问题,予以更新。欢迎留言讨论

APACHE 2.0.55

PHP 5.1.2

MYSQL 5.0.19

PHPMYADMIN 2.8.0.2

Winxp 默认安装目录 c:


一、安装IIS

在WinXp中,通过 “开始->设置->控制面板->管理工具->Internet 信息服务”来打开它。Windows的“添加删除组件”来安装它。Internet 信息服务(IIS)

然后打开控制面板中的管理工具 选择Internet 信息服务点击 属性

 

然后选择“ISAPI筛选器”标签,单击“添加”安钮。在弹出的对话框中输入筛选器名称为PHP

再单击“浏览”,选择可执行文件为C:phpphp5isapi.dll,单击“确定

 

接下来再选择“主目录”标签,单击“浏览”按钮 选择c:PHPTest (你的目录)

单击“配置”按钮,在弹出的对话框中选择“添加”,

可执行文件还是C:phpphp5isapi.dll文件,扩展名为.php,然后单击“确定

 

在“默认网站属性”中的配置到这里就基本结束了,

另外你还可以选择“文档”标签将index.php文件设置为默认内容文档。

然后做一个index.php,代码如下:

<?php
phpinfo();
?>

在IE上输入:http://127.0.0.1/index.php 来查看是否可用

安装完成以后,你就可以直接在你自己的机器上运行、调试各类PHP程序了。

  


二、安装PHP5

解压PHP5 的压缩文件到c:PHP


三、安装apache 并配置支持PHP

点击安装文件APACHE 2.0.55

安装依次选择Next, Standard, 选择安装目录为c:PHP

Please enter the address of your SMTP server 填写:localhost

下面的Please enter the “from” address for the mail function. 填写:me@localhost.com

Server选择:Apache 然后Next到底就安装完成了。

注意:

一般最常见的错误就是端口有冲突,Apache默认的端口是80,如果你的80端口被另一个程序(如IIS)占用了的话,就会出现无法启动的情况。出现这种情况,你可以按照下面的方法来修改:点击"开始->程序-> Apache HTTP Server 2.0.55->Configure Apache Server->Edit the Apache httpd.conf Configuration File"会打开一个Apache的配置文件,你可以用文本编辑器来打开它。

然后在这个文件的第120行,你会发现"Listen 80"。现在只要把这个80改成你想要的端口即可,当然在你用浏览器浏览的时候也不要忘了加上端口哦。

 Listen 90

提示:

这样如果用apache当作服务器的时候测试网页 http://127.0.0.1:90/index.php

因为我的设置是用一个目录测试网页即c:PHPTest 目录下

这样用IIS的时候用http://127.0.0.1/index.php

用apache当作服务器的时候测试网页 http://127.0.0.1:90/index.php

当然你也可以不用同一个目录。

也许你会碰到下面的输出结果:

 Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.
For more information as to why this behaviour exists, see the manual page for CGI security.
For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.

因为现在PHP在IIS中是以Cgi方式运行的,而你的php配置文件中这一项又没有打开。如果你看到上面的一段警告,你需要打开你的php.ini文件,然后查找"cgi.force_redirect = 1"这样一句,把这一句前面的分号去掉,然后把1改成0就OK了,现在再来刷新一下你刚才的页面,如果没有什么意外的话,你的屏幕上的结果应该和我下面的截屏差不多。到此,PHP在IIS上的安装过程已经完成了

将apache安装在 c:pache2 目录(随自己喜好)下
将php-5.1.12-Win32.zip 里内容解压到 c:php 里
找到 php目录里的 php.ini-dist 重命名为 php.ini 并拷到 windows目录里(即 c:windows)
复制php.ini到 c:windows目录
再将php目录里的 php5ts.dll,libmysql.dll 拷到 系统目录(system32) 如我的是c:windowssystem32里

配置apache里的httpd.conf
打开 c:Apache2confhttpd.conf 这个文件
找到 AddDefaultCharset ISO-8859-1 将其改为 AddDefaultCharset GB2312 (让默认语言编码为简体中文)
找到 DocumentRoot "C:/Apache2/htdocs" 将其改为你的WEB目录(可不改)如我的为 DocumentRoot "C:/ PHPTest"
找到 DirectoryIndex index.html index.html.var 在后面加入 index.htm index.php

选择安装模式: 模块化模式安装 或 CGI模式安装 (选一样即可)

--------------模块化安装配置------------------------------------------
找到 #LoadModule ssl_module modules/mod_ssl.so 这行,

在此行后加入一行
LoadModule php5_module C:/php/php5apache2.dll
(其中C:/php/php5apache2.dll 为你php目录中php5apache2.dll所在的位置)

找到 AddType application/x-gzip .gz .tgz 这行

在此行后加入一行
AddType application/x-httpd-php .php
----------------------------------------------------------------------------

--------------CGI安装配置---------------------------------------------
找到 AddType application/x-gzip .gz .tgz 这行,加入如下即可
ScriptAlias /php/ "C:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"
----------------------------------------------------------------------------

此时PHP环境基本已经配置成功
在WEB根目录(如我的C:PHPTest)里建一个名为test.php的文件内容如下
<?php

phpinfo();

?>
重新启动apache服务
用浏览器打开 http://localhost/test.php 或者 http://127.0.0.1/test.php

如果可以看到php配置输出信息就OK了


四、安装mysql

MYSQL 5.0.19

选择用户自定义安装(custom),定义安装目录为: c:mysql

(如下载的是非安装的mysql压缩包,直接解压到指定目录就可以了)
在开始菜单里面找到安装的Mysql的安装目录文件夹,选择

MySQL Server 5.0- MySQL Server Instance Config Wizard

选择Next—Standard Configuration

Service Name:MySQL

选中include Bin Directory in Windows Path.

选择Next

填写用户名,密码 (随便填不必在意)

选中Enable root access from remote machines

选择Next

然后选择Execute,当看到对勾都勾上了以后

说明服务器已经打开了

修改mysql数据库的root密码
用cmd进入命今行模式输入如下命令: ( 注: c:mysql 为mysql安装目录)
cd c:mysqlin
mysqladmin -u root -p password 123456
回车出现
Enter password: ( 注:这是叫你输入原密码. 刚安装时密码为空,所以直接回车即可)
此时mysql 中账号 root 的密码 被改为 123456 安装完毕


五、配置php.ini并测试mysql(php.ini为 c:windows下的 php.ini)

找到extension_dir = "./" 改为 extension_dir = "c:php/ext"
找到
;extension=php_mysql.dll
将';'去掉改为
extension=php_mysql.dll
找到
;session.save_path = "/tmp"
将';'去掉 设置你保存session的目录,如
session.save_path = "C:php/session_temp";

(如果没有的话可以自己添加一个目录)

重启apache服务
在Web根目录下(如 C:website)建立testdb.php文件内容如下:
<?php
$link=mysql_connect('localhost','root','123456');
if(!$link) echo "fail";
else echo "success";
mysql_close();
?>
用浏览器打开http://localhost/testdb.php 或者 http://127.0.0.1/test.php

如果输出success就OK了


六、phpmyadmin的安装配置

将phpMyAdmin-2.8.0..zip解压到PHPtest根目录中去,重命名文件夹为phpmyadmin或其它
打开phpmyadmin 目录中的config.default.php (C:PHPTestphpmyadminlibraries)
找到
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '123456';
分别填上你mysql的用户和密码即可

如不是本地使用,最好加上验证


打开http://127.0.0.1:90/phpmyadmin/index.php
如果发现:
The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.

把php.ini 中的 extension=php_mbstring.dll
把 php_mbstring.dll (C:PHPext) 复制到system32 重新启动服务器即可


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

[error] (OS 2)The system cannot find the file specified. : No installed service named "Apache2".

说明没有装Apache2 手动安装:

RUN= Windows key + R

"C:Program FilesApache GroupApache2inpache" -k install -n "Apache2"

(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Note the errors or messages above, and press the key to exit. 26...

端口被占用,换一个就可以了

分享到:
share

    图片原图

    loading

    loading