﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-全世界的屋顶-文章分类-php</title><link>http://www.blogjava.net/honeybee/category/27800.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 04 Dec 2007 09:51:12 GMT</lastBuildDate><pubDate>Tue, 04 Dec 2007 09:51:12 GMT</pubDate><ttl>60</ttl><item><title>Apache2.2.*+Php5.2.*+Mysql5.*的配置说明</title><link>http://www.blogjava.net/honeybee/articles/165010.html</link><dc:creator>sun</dc:creator><author>sun</author><pubDate>Mon, 03 Dec 2007 13:26:00 GMT</pubDate><guid>http://www.blogjava.net/honeybee/articles/165010.html</guid><wfw:comment>http://www.blogjava.net/honeybee/comments/165010.html</wfw:comment><comments>http://www.blogjava.net/honeybee/articles/165010.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/honeybee/comments/commentRss/165010.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/honeybee/services/trackbacks/165010.html</trackback:ping><description><![CDATA[&nbsp;<span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">一．<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">软件安装</span>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（1）全部从官方下载，各版本如下：</span></p>
<p style="margin-left: 15pt; text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">Apache2.2.4</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">；</span></p>
<p style="margin-left: 15pt; text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">Php5.2.5</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">；</span></p>
<p style="margin-left: 15pt; text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">Mysql5.0</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">。</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（2）安装路径：</span></p>
<p style="text-indent: 36pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">F:"Program Files"Apache Software Foundation"Apache2.2</span></p>
<p style="text-indent: 36pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">F:"Program Files"PHP5.2</span></p>
<p style="text-indent: 36pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">F:"Program Files"MySQL</span></p>
<p style="margin-left: 36pt; text-indent: -36pt; tab-stops: list 36.0pt"><span style="font-size: 12pt; font-family: 宋体">二．<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">Php</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">配置</span></p>
<p style="text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">这一部分的配置的目的主要有两个：一是配置Php本身，二是把MySQL</span><span style="font-family: 宋体">与</span><span style="font-size: 12pt; font-family: 宋体">Php</span><span style="font-size: 12pt; font-family: 宋体">结合起来。</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（1）将F:"Program Files"PHP5.2"目录下的libmysql.dll和php5ts.dll两个文件复制到C:"WINDOWS"system32"下；</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（2）将F:"Program Files"PHP5.2"ext"目录下的php_gb2.dll、php_mysql.dll及 php_mbstring.dll复制到C:"WINDOWS"system32"下；</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（3）将F:"Program Files"PHP5.2"中的php.ini-dest或php.ini-recommended重命名为php.ini复制到C:"WINDOWS"system32"下；</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（4）改配置文件php.ini，具体包括：</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">i.</span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">extension_dir="<span style="color: black">/"</span></span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">改为 extension_dir = " F:/Program Files/PHP5.2/ext";</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">ii.</span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">去掉下面三个表达式前面的&#8220;;&#8221;,改后如下：</span></p>
<p style="text-indent: 24pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">extension=php_gd2.dll</span></p>
<p style="margin-left: 23.95pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">extension=php_mbstring.dll<br />
extension=php_mysql.dll</span></p>
<p style="margin-left: 36pt; text-indent: -36pt; tab-stops: list 36.0pt"><span style="font-size: 12pt; font-family: 宋体">三．<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">Apache</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">配置</span></p>
<p style="text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">这一部分是</span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">把apache与php绑起来，这样一但apache运行，他马上就会带上php一起运行。</span></p>
<p style="text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">对于<span style="color: black">Apache2.2.4<span style="color: black">，</span></span></span><span style="font-size: 9pt; color: black; font-family: 宋体">装好</span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">后，先<a href="http://localhost/" target="_blank"><span style="color: windowtext">http://localhost/</a>看看是否有所显示，好像apache2.2显示的是：&#8220;It world！&#8221;，与像之前的那些版本的提示页面有所不同。</span></span></p>
<p style="text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">Apache</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">配置通过更改F:"Program Files"Apache2.2"conf"目录下</span> <span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">httpd.conf </span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">文件实现，包括以下几个地方：</span></p>
<p style="text-indent: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（1）更改</span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">php</span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">代码存放目录, 默认的目录是F: /Program Files /Apache2.2/htdocs，为了便于存放PHP代码，最好还是重新设置目录，为此需要改动DocumentRoot和&lt;Directory　****&gt;两个地方，改后如下：</span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">DocumentRoot "D:/Study/PHP"<br />
&lt;Directory "D:/Study/PHP"</span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">（2）在下面这两行：<br />
&nbsp; &nbsp; &nbsp; &nbsp; AddType application/x-compress .Z<br />
&nbsp; &nbsp; &nbsp; &nbsp; AddType application/x-gzip .gz .tgz<br />
&nbsp; &nbsp; &nbsp; &nbsp; 在其之后加上：AddType application/x-httpd-php .php　<br />
<br />
</span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">（3）在 #LoadModule ssl_module modules/mod_ssl.so 之后加下下面这两行：</span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">PHPIniDir "F:/Program Files/PHP5.2" </span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">LoadModule php5_module "F:/Program Files/PHP5.2/php5apache2_2.dll"</span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">这两句的作用，显而易见是为了把Php5.2.*与Apache2.2.*　融合到一起。对于第一句，以前<span style="color: black">的版本是不需要的，但对于版本Php5.2.*与Apache2.2.*，需要加上，这点要特别注意。</span></span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">至此，Apache2.2.*+Php5.2.*+Mysql5.*已经配置好了。</span></p>
<p style="margin-left: 21pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">下面进行测试：</span></p>
<p style="margin-left: 57pt; text-indent: -36pt; tab-stops: list 57.0pt"><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">（1）<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span></span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">启动Mysql,找到mysql5/bin/mysqld-nt.exe;</span></p>
<p style="margin-left: 57pt; text-indent: -36pt; tab-stops: list 57.0pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">（2）<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </span></span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">在</span><span style="font-weight: normal; font-size: 12pt; font-family: 宋体">D:/Study/PHP</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">目录下，建立一个test.php测试文件，内容如下：</span></p>
<p style="margin-left: 52.5pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">&lt;?php</span></p>
<p style="margin-left: 52.5pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">$link=mysql_connect("localhost","root","</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">＊＊＊");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p style="margin-left: 52.5pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">if(!$link) echo "</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">失败!";</span></p>
<p style="margin-left: 52.5pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">else echo "</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">成功!";</span></p>
<p style="margin-left: 52.5pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">mysql_close();</span></p>
<p style="margin-left: 52.5pt"><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">?&gt;</span><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">　</span></p>
<p><span style="font-weight: normal; font-size: 12pt; color: black; font-family: 宋体">之后打开<a href="http://localhost/test.php">http://localhost/test.php</a>，若能出现&#8220;成功&#8221;，则成功。</span></p>
<img src ="http://www.blogjava.net/honeybee/aggbug/165010.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/honeybee/" target="_blank">sun</a> 2007-12-03 21:26 <a href="http://www.blogjava.net/honeybee/articles/165010.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>