<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Thu, 16 Nov 2023 09:37:45 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>php5.4升php7.3踩坑之路</title>
		<link>https://www.mudbest.com/php5-4%e5%8d%87php7-3%e8%b8%a9%e5%9d%91%e4%b9%8b%e8%b7%af/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Fri, 12 Mar 2021 18:24:51 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[mysql5.7]]></category>
		<category><![CDATA[php5升级php7]]></category>
		<category><![CDATA[php7]]></category>
		<guid isPermaLink="false">https://www.mudbest.com/?p=2200</guid>

					<description><![CDATA[6年没有更新博客了，近期计划内项目有一些web服务底层基于php7+、mysql5.7+开发的，而服务器的ph ... <a title="php5.4升php7.3踩坑之路" class="read-more" href="https://www.mudbest.com/php5-4%e5%8d%87php7-3%e8%b8%a9%e5%9d%91%e4%b9%8b%e8%b7%af/" aria-label="阅读 php5.4升php7.3踩坑之路">阅读更多</a>]]></description>
										<content:encoded><![CDATA[
<blockquote class="wp-block-quote is-style-default is-layout-flow wp-block-quote-is-layout-flow">
<p>6年没有更新博客了，近期计划内项目有一些web服务底层基于php7+、mysql5.7+开发的，而服务器的php版本停留在了5.4一直未更新(mysql.5.5)，导致环境无法部署，考虑到运行的服务比较关键致使升级的计划一而再被拖延。</p>
</blockquote>

<p>&nbsp;</p>
<p>&nbsp;</p>

<p class="wp-block-paragraph">这次决定将php5.4和mysql5.5升级至php7.3和mysq5.7做个记录，希望能帮助到其他类似需要升级的人。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>先说一下版本情况：</p>
<cite>centos6.8，php5.4，mysql5.7</cite></blockquote>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph"><strong>升级php7.3过程比较简单。</strong></p>



<p class="wp-block-paragraph">1、安装epel源</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum install epel-release
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">2、加载remirepo的php源(注意：centos7不是用这个源)</p>


<pre><pre class="brush: bash; title: ; notranslate">
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">2、安装php7.3</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum --enablerepo=remi-php73 install php
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">3、安装主要扩展包</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt php-fpm
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">4、安装完成后，重启php-fpm</p>


<pre><pre class="brush: bash; title: ; notranslate">
kill -USR2 `cat /var/run/php-fpm/php-fpm.pid`
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">5、以下非必要</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum update
</pre>



<p class="wp-block-paragraph">至此，php7.3安装完成，此处我遇到1个关于mysqli扩展的问题，默认php-fpm的配置是加载了mysqli的，但是不知道为什么我查看phpinfo是没有mysqli扩展信息的，后来在php.ini里开启了mysqli扩展才识别了，不知道其他人有没有遇到。</p>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph"><strong>接着就是升级mysql5.4至mysql5.7了。</strong></p>



<p class="wp-block-paragraph">首先备份数据库，升级MySQL通常不会丢失数据，但保险起见，我们需要做这一步。</p>



<p class="wp-block-paragraph">这种方式备份的侧重点是库与表，备份文件里面会有use db_name这样的语句，方便于恢复数据时知道要把表创建到哪个数据库。</p>


<pre><pre class="brush: bash; title: ; notranslate">
mysqldump -uroot -p &#x5B;--no-data] --databases db_name1 db_name2 &amp;amp;amp;amp;gt; /dir/backup.sql;  //--no-data指不备份数据，只备份库与表结构。
</pre>


<pre><pre class="brush: bash; title: ; notranslate">
mysqldump -u xxx -h xxx -P 3306 -p --all-databases &amp;amp;amp;amp;gt; databases.sql;   // 备份所有库
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">1、备份完数据库之后，开始卸载旧版本 MySQL</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum remove mysql mysql-*
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">2、确认mysql是否卸载完全</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum list installed | grep mysql
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">3、上面的情况是没有未删除部分，如果有的话可通过下面的命令删除：</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum remove mysql－libs
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">4、查看系统版本</p>


<pre><pre class="brush: bash; title: ; notranslate">
&#x5B;root@iZbp18bpfv23id1yoiv3f0Z include]# uname -r
2.6.32-754.35.1.el6.x86_64
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">5、mysql官方源太慢了，这里用第三方源(<a href="http://mirrors.sohu.com/mysql/MySQL-5.7/" target="_blank" rel="noreferrer noopener" data-type="URL" data-id="http://mirrors.sohu.com/mysql/MySQL-5.7/">传送门</a>)</p>



<p class="wp-block-paragraph">//贴图</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="824" height="635" class="wp-image-2203" src="https://www.mudbest.com/wp-content/uploads/2021/03/mysql-1.png" alt="" srcset="https://www.mudbest.com/wp-content/uploads/2021/03/mysql-1.png 824w, https://www.mudbest.com/wp-content/uploads/2021/03/mysql-1-558x430.png 558w, https://www.mudbest.com/wp-content/uploads/2021/03/mysql-1-768x592.png 768w" sizes="(max-width: 824px) 100vw, 824px" /></figure>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">6、然后根据自己系统配置选择对应的 rpm 包(我这里下载的是5.7.23)，鼠标右键打开复制链接，然后到软件包目录执行下载命令</p>


<pre><pre class="brush: bash; title: ; notranslate">
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.23-1.el6.x86_64.rpm-bundle.tar
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">7、解压包</p>


<pre><pre class="brush: bash; title: ; notranslate">
tar -zcvf mysql-5.7.23-1.el6.x86_64.rpm-bundle.tar
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">8、安装rpm以及相关依赖</p>


<pre><pre class="brush: bash; title: ; notranslate">
yum localinstall mysql-community-common-5.7.23-1.el6.x86_64.rpm
</pre>


<pre><pre class="brush: bash; title: ; notranslate">
yum localinstall mysql-community-libs-5.7.23-1.el6.x86_64.rpm
</pre>


<pre><pre class="brush: bash; title: ; notranslate">
yum localinstall mysql-community-client-5.7.23-1.el6.x86_64.rpm
</pre>


<pre><pre class="brush: bash; title: ; notranslate">
yum localinstall mysql-community-server-5.7.23-1.el6.x86_64.rpm
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">9、OK安装完成，查看版本</p>


<pre><pre class="brush: bash; title: ; notranslate">
&#x5B;root@*** include]# mysql -V
mysql  Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using  EditLine wrapper
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">10、重启mysql</p>


<pre><pre class="brush: bash; title: ; notranslate">
service mysqld start
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">11、如果重启mysql失败，初始化数据库。</p>


<pre><pre class="brush: bash; title: ; notranslate">
mysqld --initialize
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">12、基于mysql5.7的安全机制有变更，默认mysql是有密码的，查看默认密码。</p>


<pre><pre class="brush: bash; title: ; notranslate">
&#x5B;root@******************* include]# grep 'temporary password' /var/log/mysqld.log
2021-03-09T10:52:05.394381Z 1 &#x5B;Note] A temporary password is generated for root@localhost: *****?4#v
2021-03-09T10:54:04.766642Z 1 &#x5B;Note] A temporary password is generated for root@localhost: *****zyc6/(
2021-03-09T10:55:15.770123Z 1 &#x5B;Note] A temporary password is generated for root@localhost: *****Vy!y0!h
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">13、还是基于安全，默认登录到mysql命令控制台，执行任何有效命令都会提示重新设置密码。</p>


<pre><pre class="brush: bash; title: ; notranslate">
mysql -&amp;amp;amp;amp;amp;gt; select host from mysql.user where User='root';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">14、修改密码(5.7的密码验证要求高，密码过于简单会提示错误)</p>


<pre><pre class="brush: bash; title: ; notranslate">
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">15、密码过于简单报错</p>


<pre><pre class="brush: bash; title: ; notranslate">
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">16、最后让修改生效执行</p>


<pre><pre class="brush: bash; title: ; notranslate">
flush privileges;
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">至此，mysql的安装以及配置完成，剩下就是进入控制台 source导入上面备份的数据库就行了。</p>



<p class="wp-block-paragraph">==================================================我是分割线</p>



<p class="wp-block-paragraph">踩坑开始：</p>



<p class="wp-block-paragraph">由于论坛(<a href="https://bbs.mudbest.com" target="_blank" rel="noreferrer noopener">https://bbs.mudbest.com</a>)是基于discuz7.2开发的，很多函数在php7.3被废弃了甚至会报错，php7.3和mysql5.7升级完成之后，然后一脸懵逼。。论坛挂了。。。无法访问。</p>



<p class="wp-block-paragraph">现在回过头看discuz7的代码(无法言喻。。)，打开php-fpm的运行错误，在php-fpm.conf内添加以下内容，然后打开error_log就可以看到运行的错误信息了</p>


<pre><pre class="brush: bash; title: ; notranslate">
&#x5B;www]
catch_workers_output = yes
</pre>



<p class="wp-block-paragraph">坑整理：<br />1、set_magic_quotes_runtime 报致命错误。<br />2、ob_start('ob_gzhandler') 报致命错误。<br />3、preg_replace 带evel的 报致命错误。<br />4、php7 session不能传递的解决方案<br />5、….各种告警(修了70%，剩下30%不想修了，直接改告警登记屏蔽了，哈哈)</p>



<p class="wp-block-paragraph"><strong>关于问题3、4 的解决方式：</strong><br />1、针对 preg_replace evel替代方案就是将 全站用到 evel的换成preg_replace_callback，来个例子。</p>


<pre><pre class="brush: php; title: ; notranslate">
$message = preg_replace(&quot;/\s?&#x5B;code](.+?)&#x5B;\/code]\s?/ies&quot;, &quot;codedisp('\1')&quot;, $message);
</pre>



<p class="wp-block-paragraph">改写成</p>


<pre><pre class="brush: php; title: ; notranslate">
$message = preg_replace_callback(
&quot;/\s?&#x5B;code](.+?)&#x5B;\/code]\s?/is&quot;,
function ($matches) {
return codedisp($matches&#x5B;1]);
},
$message
);
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph"><em>扩展知识：</em></p>


<pre><pre class="brush: php; title: ; notranslate">
//适合单一任务
$template = preg_replace_callback( //处理eval
    &quot;/&#x5B;\n\r\t]*\{eval\s+(.+?)\}&#x5B;\n\r\t]*/is&quot;,
    function ($matches) { return str_replace(&quot;\\\&quot;&quot;, &quot;\&quot;&quot;, preg_replace(&quot;/\&amp;amp;amp;amp;amp;lt;\?\=(\\\$.+?)\?\&amp;amp;amp;amp;amp;gt;/s&quot;, &quot;\\1&quot;, &quot;&amp;amp;amp;amp;amp;lt;? $matches&#x5B;1] ?&amp;amp;amp;amp;amp;gt;&quot;)); },
    $template
);
 
//需要同一正则处理多个任务时  &#x5B;推荐]
function stripvtags($expr) {
    $expr = str_replace(&quot;\\\&quot;&quot;, &quot;\&quot;&quot;, preg_replace(&quot;/\&amp;amp;amp;amp;amp;lt;\?\=(\\\$.+?)\?\&amp;amp;amp;amp;amp;gt;/s&quot;, &quot;\\1&quot;, $expr));
    return $expr;
}
$template = preg_replace_callback( //处理eval
    &quot;/&#x5B;\n\r\t]*\{eval\s+(.+?)\}&#x5B;\n\r\t]*/is&quot;,
    function ($matches) { return stripvtags(&quot;&amp;amp;amp;amp;amp;lt;? $matches&#x5B;1] ?&amp;amp;amp;amp;amp;gt;&quot;); },
    $template
);
$template = preg_replace_callback( //处理echo
    &quot;/&#x5B;\n\r\t]*\{echo\s+(.+?)\}&#x5B;\n\r\t]*/is&quot;,
    function ($matches) { return stripvtags(&quot;&amp;amp;amp;amp;amp;lt;? echo $matches&#x5B;1] ?&amp;amp;amp;amp;amp;gt;&quot;); },
    $template
);
 
//与第一种差不多, 只不过是分开写
class Template {
    public function test() {
        $template = preg_replace_callback( //处理eval
            &quot;/&#x5B;\n\r\t]*\{eval\s+(.+?)\}&#x5B;\n\r\t]*/is&quot;,
            array($this, 'stripvtagsEval'),
            $template
        );
    }
    protected function stripvtagsEval($matches) {
        return str_replace(&quot;\\\&quot;&quot;, &quot;\&quot;&quot;, preg_replace(&quot;/\&amp;amp;amp;amp;amp;lt;\?\=(\\\$.+?)\?\&amp;amp;amp;amp;amp;gt;/s&quot;, &quot;\\1&quot;, &quot;&amp;amp;amp;amp;amp;lt;? $matches&#x5B;1] ?&amp;amp;amp;amp;amp;gt;&quot;)); 
    }
}
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">2、session问题只需要将php.ini内的session.use_trans_sid设置为1，并且将存放session的目录权限改为可写入。</p>


<pre><pre class="brush: bash; title: ; notranslate">
session.use_trans_sid=0
</pre>



<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">改为</p>


<pre><pre class="brush: bash; title: ; notranslate">
session.use_trans_sid=1
</pre>

<p>&nbsp;</p>

<p class="wp-block-paragraph">&nbsp;</p>

<p>验证码无法显示的原因，可以看查看一下session.save_path目录的权限，默认这个目录是给apache，如果nginx启动用户非apache则无法写入session 默认session.save_page目录为/var/lib/php</p>
<pre><pre class="brush: bash; title: ; notranslate">
drwxrwx--- 2 root apache   6 Aug  4 02:40 opcache
drwxr-xr-x 2 root root   116 Nov 15 16:43 peclxml
drwxrwx--- 2 root apache   6 Aug  4 02:40 session
drwxrwx--- 2 root apache   6 Aug  4 02:40 wsdlcache
</pre></pre>
<p>我这里nginx改了启动用户，将www改成自己配置的用户组即可。20231116</p>
<pre><pre class="brush: bash; title: ; notranslate">
chown www:www /var/lib/php -R
</pre></pre>

<p class="wp-block-paragraph">至此，从升级配置直至填坑恢复，用了2天，又掉了不少头发，赶紧洗洗睡了。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>VMware下Centos的lnmp编译安装</title>
		<link>https://www.mudbest.com/vmware%e4%b8%8bcentos%e7%9a%84lnmp%e7%bc%96%e8%be%91%e5%ae%89%e8%a3%85/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Tue, 29 Apr 2014 04:36:07 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[lnmp]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=2043</guid>

					<description><![CDATA[VMware安装Centos就不说了，接下来是Centos的相关配置，如果Centos有防火墙的话，则需要配置 ... <a title="VMware下Centos的lnmp编译安装" class="read-more" href="https://www.mudbest.com/vmware%e4%b8%8bcentos%e7%9a%84lnmp%e7%bc%96%e8%be%91%e5%ae%89%e8%a3%85/" aria-label="阅读 VMware下Centos的lnmp编译安装">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>VMware安装Centos就不说了，接下来是Centos的相关配置，如果Centos有防火墙的话，则需要配置防火墙，非Vm通用。</p>
<p><strong>一、开启80端口、3306端口</strong><span id="more-2043"></span></p>
<pre class="brush: bash; title: ; notranslate">
vi /etc/sysconfig/iptables   #编辑防火墙配置文件 
</pre>
<p>-A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 80 -j ACCEPT（允许80端口通过防火墙）<br />
-A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 3306 -j ACCEPT（允许3306端口通过防火墙）   </p>
<pre class="brush: bash; title: ; notranslate"> 
#特别提示：很多网友把这两条规则添加到防火墙配置的最后一行，导致防火墙启动失败
#正确的应该是添加到默认的22端口这条规则的下面，添加好之后防火墙规则如下所示：
#########################################################    
# Firewall configuration written by system-config-firewall    
# Manual customization of this file is not recommended.    
*filter    
:INPUT ACCEPT &#x5B;0:0]    
:FORWARD ACCEPT &#x5B;0:0]    
:OUTPUT ACCEPT &#x5B;0:0]    
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT    
-A INPUT -p icmp -j ACCEPT    
-A INPUT -i lo -j ACCEPT    
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT    
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT    
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT    
-A INPUT -j REJECT --reject-with icmp-host-prohibited    
-A FORWARD -j REJECT --reject-with icmp-host-prohibited    
COMMIT    
#########################################################    
/etc/init.d/iptables restart  #最后重启防火墙使配置生效 
</pre>
<p><strong>二、关闭SELINUX</strong></p>
<pre class="brush: bash; title: ; notranslate">
vim /etc/selinux/config  #编辑
#SELINUX=enforcing       #注释掉 
#SELINUXTYPE=targeted    #注释掉 
SELINUX=disabled         #增加 
:wq #保存退出
shutdown -r now   #重启系统
</pre>
<p><strong>三、系统约定</strong><br />
软件源代码包存放位置：/usr/local/src<br />
源码包编译安装位置：/usr/local/软件包名字</p>
<p><strong>四、源码包下载</strong><br />
1、pcre下载(支持nginx伪静态)<br />
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz</p>
<p>2、mysql下载<br />
http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz</p>
<p>3、libmcrypt-2.5.7<br />
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz</p>
<p>3.2、libiconv-1.9.2<br />
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz</p>
<p>3.3、zlib下载<br />
http://zlib.net/zlib-1.2.8.tar.gz</p>
<p>3.4、php下载<br />
http://ar2.php.net/distributions/php-5.5.11.tar.gz<br />
http://ar2.php.net/distributions/php-5.3.28.tar.gz</p>
<p>3.5、phpredis扩展下载<br />
https://github.com/nicolasff/phpredis/archive/master.zip</p>
<p>4、cmake下载(MySQL编译工具)<br />
http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz</p>
<p>5、nginx下载(稳定版本)<br />
http://nginx.org/download/nginx-1.4.7.tar.gz</p>
<p>安装编译工具及库文件（使用CentOS yum命令安装）</p>
<pre class="brush: bash; title: ; notranslate">
yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd  kernel keyutils  patch  perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch freetype-devel
</pre>
<p><strong>五、开始编译安装</strong><br />
1、编译准备工作</p>
<pre class="brush: bash; title: ; notranslate">
yum groupinstall &quot;Development tools&quot;
</pre>
<p>1.1、安装cmake</p>
<pre class="brush: bash; title: ; notranslate">
cd /usr/local/src 
tar zxvf cmake-2.8.8.tar.gz 
cd cmake-2.8.8 
./configure make  #编译 
make install   #安装
</pre>
<p>2、安装MySQL</p>
<pre class="brush: bash; title: ; notranslate">
groupadd mysql  #添加mysql组    
useradd -g mysql mysql -s /bin/false  #创建用户mysql并加入到mysql组，不允许mysql用户直接登录系统    
mkdir -p /data/mysql  #创建MySQL数据库存放目录    
chown -R mysql:mysql /data/mysql   #设置MySQL数据库目录权限    
mkdir -p /usr/local/mysql #创建MySQL安装目录    
cd /usr/local/src    
tar zxvf mysql-5.5.25.tar.gz  #解压    
cd mysql-5.5.25    
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/data/mysql/ -DSYSCONFDIR=/etc/  #配置    
make #编译    
make install  #安装    
cd /usr/local/mysql    
cp ./support-files/my-huge.cnf  /etc/my.cnf   #拷贝配置文件（注意：如果/etc目录下面默认有一个my.cnf，直接覆盖即可）    
vim /etc/my.cnf   #编辑配置文件,在 &#x5B;mysqld] 部分增加下面一行    
datadir = /data/mysql  #添加MySQL数据库路径    
:wq!  #保存退出    
cd /usr/local/mysql/ #share 初始化的sql在这里面,下面一句命令默认读取share路径是./share/...
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/ &amp; #生成mysql系统数据库,并定义数据data存放位置
cp ./support-files/mysql.server  /etc/rc.d/init.d/mysqld  #把Mysql加入系统启动    
chmod 755 /etc/init.d/mysqld   #增加执行权限    
chkconfig mysqld on  #设置开机启动    
vim /etc/rc.d/init.d/mysqld  #编辑    
basedir = /usr/local/mysql   #MySQL程序安装路径    
datadir = /data/mysql  #MySQl数据库存放目录    
service mysqld start  #启动    
vim /etc/profile   #把mysql服务加入系统环境变量：在最后添加下面这一行    
export PATH=$PATH:/usr/local/mysql/bin    
:wq! #保存退出    
</pre>
<p>下面这两行把myslq的库文件链接到系统默认的位置，在编译类似PHP等软件时可以不用指定mysql的库文件地址。 </p>
<pre class="brush: bash; title: ; notranslate">
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock #创建快捷方式

ln -s /usr/local/mysql/lib /usr/lib/mysql    
ln -s /usr/local/mysql/include/mysql /usr/include/mysql    
shutdown -r now     #需要重启系统，等待系统重新启动之后继续在终端命令行下面操作    
mysql_secure_installation    #设置Mysql密码    

mysql --socket=/var/lib/mysql/mysql.sock #指定sock链接


</pre>
<p>根据提示按Y 回车（默认密码为空）<br />
然后输入2次密码<br />
继续按Y 回车，直到设置完成<br />
或者直接修改密码</p>
<pre class="brush: bash; title: ; notranslate">
/usr/local/mysql/bin/mysqladmin -u root -p password &quot;123456&quot; #修改密码    
service mysqld restart  #重启    
</pre>
<p>到此，mysql安装完成。</p>
<p>3、安装pcre</p>
<pre class="brush: bash; title: ; notranslate">
cd /usr/local/src    
mkdir /usr/local/pcre  #创建安装目录    
tar  zxvf pcre-8.30.tar.gz    
cd pcre-8.30    
./configure  --prefix=/usr/local/pcre  #配置    
make    
make install
</pre>
<p>4、安装nginx</p>
<pre class="brush: bash; title: ; notranslate">
cd /usr/local/src    
groupadd  www  #添加www组    
useradd -g  www www -s /bin/false  #创建nginx运行账户www并加入到www组，不允许www用户直接登录系统    
tar  zxvf nginx-1.2.0.tar.gz    
cd nginx-1.2.0    
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.30    
#注意:--with-pcre=/usr/local/src/pcre-8.30指向的是源码包解压的路径，而不是安装的路径，否则会报错    
make    
make install    
/usr/local/nginx/sbin/nginx   #启动nginx    
</pre>
<pre class="brush: bash; title: ; notranslate">
vim /etc/rc.d/init.d/nginx    #设置nginx开启启动，编辑启动文件添加下面内容 
</pre>
<pre class="brush: bash; title: ; notranslate">
#################################################################    
#!/bin/bash    
# nginx Startup script for the Nginx HTTP Server    
# it is v.0.0.2 version.    
# chkconfig: - 85 15    
# description: Nginx is a high-performance web and proxy server.    
#              It has a lot of features, but it's not for everyone.    
# processname: nginx    
# pidfile: /var/run/nginx.pid    
# config: /usr/local/nginx/conf/nginx.conf    
nginxd=/usr/local/nginx/sbin/nginx    
nginx_config=/usr/local/nginx/conf/nginx.conf    
nginx_pid=/usr/local/nginx/logs/nginx.pid    
RETVAL=0    
prog=&quot;nginx&quot;    
# Source function library.    
.  /etc/rc.d/init.d/functions    
# Source networking configuration.    
.  /etc/sysconfig/network    
# Check that networking is up.    
&#x5B; ${NETWORKING} = &quot;no&quot; ]  exit 0    
&#x5B; -x $nginxd ] || exit 0    
# Start nginx daemons functions.    
start() {    
if &#x5B; -e $nginx_pid ];then    
  echo &quot;nginx already running....&quot;    
  exit 1    
fi    
  echo -n $&quot;Starting $prog: &quot;    
  daemon $nginxd -c ${nginx_config}    
  RETVAL=$?    
  echo    
  &#x5B; $RETVAL = 0 ]  touch /var/lock/subsys/nginx    
  return $RETVAL    
}    
# Stop nginx daemons functions.    
stop() {    
       echo -n $&quot;Stopping $prog: &quot;    
       killproc $nginxd    
       RETVAL=$?    
       echo    
       &#x5B; $RETVAL = 0 ]  rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid    
}    
reload() {    
   echo -n $&quot;Reloading $prog: &quot;    
   #kill -HUP `cat ${nginx_pid}`    
   killproc $nginxd -HUP    
   RETVAL=$?    
   echo    
}    
# See how we were called.    
case &quot;$1&quot; in    
start)    
       start    
       ;;    
stop)    
       stop    
       ;;    
reload)    
       reload    
       ;;    
restart)    
       stop    
       start    
       ;;    
               
status)    
       status $prog    
       RETVAL=$?    
       ;;    
*)    
       echo $&quot;Usage: $prog {start|stop|restart|reload|status|help}&quot;    
       exit 1    
esac    
exit $RETVAL    
#################################################################  
:wq!  #保存退出 
</pre>
<pre class="brush: bash; title: ; notranslate">   
chmod 775  /etc/rc.d/init.d/nginx  #赋予文件执行权限    
chkconfig nginx on    #设置开机启动    
/etc/rc.d/init.d/nginx restart  #重启    
</pre>
<p>5.1、安装libmcrypt</p>
<pre class="brush: bash; title: ; notranslate">
cd /usr/local/src    
tar zxvf  libmcrypt-2.5.7.tar.gz   #解压    
cd  libmcrypt-2.5.7 #进入目录    
./configure    #配置    
make             #编译    
make install   #安装  
</pre>
<p>5.2、安装libiconv</p>
<pre class="brush: bash; title: ; notranslate">
cd /usr/local/src    
tar -zxvf libiconv-1.9.2.tar.gz   #解压    
cd  libiconv-1.9.2 #进入目录    
./configure --prefix=/usr/local/iconv    #配置    
make             #编译    
make install   #安装  

#重新编译php 增加编译参数--with-iconv=/usr/local/iconv 
</pre>
<p>5.3、安装zlib</p>
<pre class="brush: bash; title: ; notranslate">
yum info zlib
cd /usr/local/src    
tar -zxvf zlib-1.2.8.tar.gz   #解压    
cd  zlib-1.2.8 #进入目录    
./configure --prefix=/usr/local/zlib    #配置    
make             #编译    
make install   #安装  

#重新编译php 增加编译参数--with-iconv=/usr/local/iconv 
</pre>
<p>5.4、php5需要的devel 包：</p>
<pre class="brush: bash; title: ; notranslate">
yum install libxml2-devel gd-devel libmcrypt-devel libcurl-devel openssl-devel
</pre>
<p>6、安装php</p>
<pre class="brush: bash; title: ; notranslate">
cd /usr/local/src    
tar -zvxf php-5.3.13.tar.gz    
cd  php-5.3.13    
mkdir -p /usr/local/php5  #建立php安装目录    
#5.3配置    
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv=/usr/local/iconv --with-zlib  --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex  --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir --with-freetype-dir    
#5.5配置    
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv=/usr/local/iconv  --with-zlib --with-zlib-dir=/usr/local/zlib  --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir --with-freetype-dir 

make   #编译    
make install    #安装    

ln -s -f /usr/local/php5/bin/phar.phar /usr/local/php5/bin/phar
</pre>
<pre class="brush: bash; title: ; notranslate">
cp  php.ini-production   /usr/local/php5/etc/php.ini  #复制php配置文件到安装目录 
</pre>
<pre class="brush: bash; title: ; notranslate">
rm -rf /etc/php.ini   #删除系统自带配置文件    
ln -s /usr/local/php5/etc/php.ini  /etc/php.ini    #添加软链接    
cp  /usr/local/php5/etc/php-fpm.conf.default   /usr/local/php5/etc/php-fpm.conf      #拷贝模板文件为php-fpm配置文件    
vim  /usr/local/php5/etc/php-fpm.conf  #编辑    
user = www    #设置php-fpm运行账号为www    
group = www   #设置php-fpm运行组为www    
pid = run/php-fpm.pid    #取消前面的分号    
cp /usr/local/src/php-5.3.13/sapi/fpm/init.d.php-fpm   /etc/rc.d/init.d/php-fpm  #设置 php-fpm开机启动，拷贝php-fpm到启动目录    
chmod +x /etc/rc.d/init.d/php-fpm  #添加执行权限    
chkconfig php-fpm on    #设置开机启动    
</pre>
<pre class="brush: bash; title: ; notranslate">
vim /usr/local/php5/etc/php.ini    #编辑配置文件  
</pre>
<p>找到：&#8221;disable_functions =&#8221;，修改为：</p>
<pre class="brush: bash; title: ; notranslate">
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname     
</pre>
<p>#列出PHP可以禁用的函数，如果某些程序需要用到这个函数，可以删除，取消禁用。</p>
<p>找到：&#8221;;date.timezone =&#8221;，修改为：</p>
<pre class="brush: bash; title: ; notranslate">
date.timezone = PRC   #设置时区   
</pre>
<p>找到：&#8221;expose_php = On&#8221;，修改为：</p>
<pre class="brush: bash; title: ; notranslate">
修改为：expose_php = OFF  #禁止显示php版本的信息    
</pre>
<p>注意：在编译PHP的过程中可能会报UNDEFINED REFERENCE TO `LIBICONV_OPEN 无法编译PHP LIBICONV错误</p>
<p>php5.4 php-fpm重启方法</p>
<p>master进程可以理解以下信号<br />
INT, TERM 立刻终止<br />
QUIT 平滑终止<br />
USR1 重新打开日志文件<br />
USR2 平滑重载所有worker进程并重新载入配置和二进制模块</p>
<p>示例：<br />
php-fpm 启动：</p>
<pre class="brush: bash; title: ; notranslate">
/usr/local/php5/sbin/php-fpm
</pre>
<p>php-fpm 关闭：</p>
<pre class="brush: bash; title: ; notranslate">
kill -INT `cat /usr/local/php5/var/run/php-fpm.pid`
</pre>
<p>php-fpm 重启：</p>
<pre class="brush: bash; title: ; notranslate">
kill -USR2 `cat /usr/local/php5/var/run/php-fpm.pid`
</pre>
<p>查看php-fpm进程数：</p>
<pre class="brush: bash; title: ; notranslate">
ps aux | grep -c php-fpm
</pre>
<p>6.1、phpredis扩展安装</p>
<pre class="brush: bash; title: ; notranslate">
cd /usr/local/src/phpredis-master
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config
make
make install
</pre>
<p>增加phpredis扩展</p>
<pre class="brush: bash; title: ; notranslate">
vim /usr/local/php5/etc/php.ini
</pre>
<p>在后面增加</p>
<pre class="brush: bash; title: ; notranslate">
extension=redis.so
</pre>
<p>测试</p>
<pre class="brush: php; title: ; notranslate">
$objRedis = new Redis();
$objRedis&gt;connect('127.0.0.1',6379)
$objRedis-&gt;set('test','ok');
echo $objRedis-&gt;get('test');
</pre>
<p>7、配置nginx支持php</p>
<pre class="brush: bash; title: ; notranslate">
vim /usr/local/nginx/conf/nginx.conf      #编辑配置文件     
</pre>
<pre class="brush: bash; title: ; notranslate">
user   www  www;          #首行user去掉注释,修改Nginx运行组为www www；必须与/usr/local/php5/etc/php-fpm.conf中的user,group配置相同，否则php运行出错    
index  index.php  index.html index.htm;    #添加index.php    
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000    
#    
location ~ \.php$ {    
   root           html;#此处和server下面root保持一致,默认为html    
   fastcgi_pass   127.0.0.1:9000;    
   fastcgi_index  index.php;    
   fastcgi_param  SCRIPT_FILENAME   /usr/local/nginx/html/$fastcgi_script_name;    
   include        fastcgi_params;          
</pre>
<p>注意：取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为/data/webroot/(此为网站根目录绝对路径)$fastcgi_script_name</p>
<pre class="brush: bash; title: ; notranslate">
/etc/init.d/nginx restart  #重启nginx  
</pre>
<p><a href="http://www.mudbest.com/vmware%e4%b8%8bcentos%e7%9a%84lnmp%e7%bc%96%e8%be%91%e5%ae%89%e8%a3%85/cmake-2-8-8-tar/" rel="attachment wp-att-2053">cmake-2.8.8.tar</a></p>
<p><a href="http://www.mudbest.com/vmware%e4%b8%8bcentos%e7%9a%84lnmp%e7%bc%96%e8%be%91%e5%ae%89%e8%a3%85/nginx-1-4-7-tar/" rel="attachment wp-att-2054">nginx-1.4.7.tar</a><br />
<a href="http://www.mudbest.com/vmware%e4%b8%8bcentos%e7%9a%84lnmp%e7%bc%96%e8%be%91%e5%ae%89%e8%a3%85/phpredis-master/" rel="attachment wp-att-2077">phpredis-master扩展</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>使用PHP将JS的unicode编码转换为可识别的汉字</title>
		<link>https://www.mudbest.com/%e4%bd%bf%e7%94%a8php%e5%b0%86js%e7%9a%84unicode%e7%bc%96%e7%a0%81%e8%bd%ac%e6%8d%a2%e4%b8%ba%e5%8f%af%e8%af%86%e5%88%ab%e7%9a%84%e6%b1%89%e5%ad%97/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Sun, 29 Dec 2013 08:14:49 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[unicode]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1943</guid>

					<description><![CDATA[今天抓数据的时候，发现js里的汉字全部为“\u738B\u6668”这样的字符串，没想到如何转到可识别的中文汉 ... <a title="使用PHP将JS的unicode编码转换为可识别的汉字" class="read-more" href="https://www.mudbest.com/%e4%bd%bf%e7%94%a8php%e5%b0%86js%e7%9a%84unicode%e7%bc%96%e7%a0%81%e8%bd%ac%e6%8d%a2%e4%b8%ba%e5%8f%af%e8%af%86%e5%88%ab%e7%9a%84%e6%b1%89%e5%ad%97/" aria-label="阅读 使用PHP将JS的unicode编码转换为可识别的汉字">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>今天抓数据的时候，发现js里的汉字全部为“\u738B\u6668”这样的字符串，没想到如何转到可识别的中文汉字，那么下面这段函数产生了……</p>
<p>直接贴code：<br />
<span id="more-1943"></span></p>
<pre class="brush: php; title: ; notranslate">
/**
 * 将js的unicode转换为中文
 * @param string $strHtml
 * @return string
 */
public function charReplace($strHtml){
	if(empty($strHtml)){
		return '';
	}
	$pregReg = '/(\\\u(&#x5B;\w]{4}))|(&#x5B;\x7f-\xff]+)/i';
	$arrTempData = array();
	preg_match_all($pregReg, $strHtml,$arrTempData);
	if(!empty($arrTempData)){
		//初始一个字符串变量
		$str = '';
		//循环处理
		for($i=0;$i&lt;count($arrTempData&#x5B;0]);$i++){
			$strTemp = $arrTempData&#x5B;0]&#x5B;$i];
			if (strpos($strTemp, '\\u') === 0){
				$strAry1 = base_convert(substr($strTemp, 2 , 2), 16, 10);
				$strAry2 = base_convert(substr($strTemp, 4), 16, 10);
				$strChr = chr($strAry1).chr($strAry2);
				//如果不是linux系统，则转换
				if(preg_match(&quot;/WIN/i&quot;,PHP_OS)){
					$strChr = iconv('UCS-2', 'UTF-8', $strChr);
				}
				//$str .= $strChr;
				$arrCharStartReplace&#x5B;] = $arrTempData&#x5B;0]&#x5B;$i];
				$arrCharEndReplace&#x5B;] = $strChr;
				//echo $arrTempData&#x5B;0]&#x5B;$i].'==='.$strCh.&quot;\r\n&quot;;
			}
		}
	}
	$strHtml = str_replace($arrCharStartReplace, $arrCharEndReplace, $strHtml);
	return $strHtml;
}
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHPExcel强大的Excel扩展处理类</title>
		<link>https://www.mudbest.com/phpexcel%e5%bc%ba%e5%a4%a7%e7%9a%84excel%e6%89%a9%e5%b1%95%e5%a4%84%e7%90%86%e7%b1%bb/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Mon, 08 Apr 2013 12:52:31 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[phpexcel]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1852</guid>

					<description><![CDATA[当对各种报表需要进行Excel导出或其他处理的时候，PHPExcel是一个不错的选择，它对office2007 ... <a title="PHPExcel强大的Excel扩展处理类" class="read-more" href="https://www.mudbest.com/phpexcel%e5%bc%ba%e5%a4%a7%e7%9a%84excel%e6%89%a9%e5%b1%95%e5%a4%84%e7%90%86%e7%b1%bb/" aria-label="阅读 PHPExcel强大的Excel扩展处理类">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>当对各种报表需要进行Excel导出或其他处理的时候，PHPExcel是一个不错的选择，它对office2007以及office2003能完美支持，解决了各种不兼容问题，那么今天就来介绍一下PHPExcel的使用方法吧，对于一个扩展最简单的理解就是如下步骤：引入->实例->使用。</p>
<p>PHPExcel是相当强大的 MS Office Excel 文档生成类库，当需要输出比较复杂格式数据的时候，PHPExcel 是个不错的选择。不过其使用方法相对来说也就有些繁琐。<span id="more-1852"></span></p>
<p>一、使用实例</p>
<pre class="brush: php; title: ; notranslate">
//保存目录
$file = str_replace('\\','/' , dirname(dirname(__file__)));
$fileCount = strlen($file);
//这里的目录是我的项目路径，其他自行更改
$fileName = substr_replace($file,'web/www/excel/'.$this-&gt;xmlFileName,$fileCount-7);

//设置时区为中国
date_default_timezone_set('PRC');
//核心部分
//载入核心库类
require_once('pto/outExcel/PHPExcel.php');
//实例
$objPHPExcel = new PHPExcel();

//设置文档属性 - 连贯操作
$objPHPExcel-&gt;getProperties()-&gt;setCreator(&quot;tieyou Kefu&quot;) //设置作者
-&gt;setLastModifiedBy(&quot;kefu User&quot;) //设置最后修改的人
-&gt;setTitle(&quot;$this-&gt;xmlFileName&quot;) //设置标题
-&gt;setSubject(&quot;Office 2007 XLSX Data&quot;) //设置主题
-&gt;setDescription(&quot;Test document for Office 2007 XLSX, generated using PHP classes.&quot;)//描述
-&gt;setKeywords(&quot;office 2007 openxml php&quot;)//设置关键字
-&gt;setCategory(&quot;data for Excel&quot;);//设置分类

//添加一些数据，并在这里使用一些公式
$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A5', 'Sum:'); //在Excel A列第5行写入“Sum:”字符串。

$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('B1', 'Range #1') //在B列1行 写入“Range #1”
                              -&gt;setCellValue('B2', 3) //在B列2行 写入 3
                              -&gt;setCellValue('B3', 7) //在B列3行 写入 7
                              -&gt;setCellValue('B4', 13) //在B列4行 写入 13
                              -&gt;setCellValue('B5', '=SUM(B2:B4)'); // 在B列5行 写入Excel原生计算公式“=SUM(B2:B4)”

$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A7', 'Total of both ranges:'); //在A列7行 写入“Total of both ranges:”
$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('B7', '=SUM(B5:C5)'); //在B列7行 写入Excel原生计算公式“=SUM(B5:C5)”

$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A8', 'Minimum of both ranges:');//在A列8行 写入 “Minimum of both ranges:”
$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('B8', '=MIN(B2:C4)'); //在A列8行 写入Excel原生计算公式“=MIN(B2:C4)”

$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A9', 'Maximum of both ranges:'); //在A列9行 写入“Maximum of both ranges:”
$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('B9', '=MAX(B2:C4)'); //在B列9行 写入Excel原生计算公式“=MAX(B2:C4)”

$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('A10', 'Average of both ranges:'); //在A列10行 写入“Average of both ranges:”
$objPHPExcel-&gt;getActiveSheet()-&gt;setCellValue('B10', '=AVERAGE(B2:C4)');//在B列10行 写入Excel原生计算公式“=AVERAGE(B2:C4)”

//Excel表格的起始页码 0
$objPHPExcel-&gt;setActiveSheetIndex(0);

//这个部位是为了实现点击下载至客户端 和 直接保存至服务端文件夹
if($strMakeType == 1){
	//保存目录
	$file = str_replace('\\','/' , dirname(dirname(__file__)));
	$fileCount = strlen($file);
	$fileName = substr_replace($file,'web/www/excel/'.$this-&gt;xmlFileName,$fileCount-7);
}else{
	//下载
	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: attachment;filename='.$this-&gt;xmlFileName);
	header('Cache-Control: max-age=0');
}

//以下部分为了让office2007和office2003互相兼容

//兼容office 2007
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter-&gt;save(str_replace('.php', '.xlsx', $fileName));

//兼容office 2003
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter-&gt;save(str_replace('.php', '.xls', $fileName));

//如果是 点击下载 至客户端
//$objWriter-&gt;save('php://output');
</pre>
<p>至此，最基本的实例已完成，可以从上例看出，对Excel原生支持还是不错的，对于php处理Excel总体来说，PHPExcel是不错的选择。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>windows下配置php+xdebug</title>
		<link>https://www.mudbest.com/windows%e4%b8%8b%e9%85%8d%e7%bd%aephpxdebug/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Fri, 02 Nov 2012 10:32:31 +0000</pubDate>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[xdebug]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[性能]]></category>
		<category><![CDATA[调试]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1661</guid>

					<description><![CDATA[前言： Xdebug最常用的就是错误提示，它可以将一些脚本错误的详细信息给展示出来，甚至到错误的变量。对于程序 ... <a title="windows下配置php+xdebug" class="read-more" href="https://www.mudbest.com/windows%e4%b8%8b%e9%85%8d%e7%bd%aephpxdebug/" aria-label="阅读 windows下配置php+xdebug">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>前言：<br />
Xdebug最常用的就是错误提示，它可以将一些脚本错误的详细信息给展示出来，甚至到错误的变量。对于程序最优它也有着必然的作用，配合Kcachegrind对Xdebug生成的日志文件进行性能分析，WINDOWS下常用Wincachegrind。</p>
<p>在这里再提示一下</p>
<pre class="brush: plain; title: ; notranslate">
PHP 5.2.X的版本用zend_extension_ts加载
PHP 5.3.X的版本要用 zend_extension加载 
</pre>
<p><span id="more-1661"></span><br />
首先下载php相对应的版本Xdebug，可以在页面输出</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
phpinfo();
?&gt;
</pre>
<p>将打印出来的所有字符串复制到http://www.xdebug.org/wizard.php进行自动检测，会根据当前PHP版本进行提示下载。</p>
<p>将下载后的DLL组件放在PHP目录的/ext目录，例如d:/webserver/php5.3/ext。</p>
<p>最终配置：</p>
<pre class="brush: plain; title: ; notranslate">
;zend_extension_ts=&quot;D:/web_server/xdebug/php_xdebug-2.2.1-5.3-vc9-nts.dll&quot;
zend_extension=&quot;D:/web_server/xdebug/php_xdebug-2.2.1-5.3-vc9.dll&quot;
xdebug.auto_trace=on
xdebug.collect_return=on
xdebug.trace_output_dir=&quot;D:/web_server/xdebug/tracelog&quot;
xdebug.profiler_enable=on
xdebug.profiler_output_dir=&quot;D:/web_server/xdebug/profilerlog&quot; 
xdebug.default_enable = On  
xdebug.show_exception_trace = On  
xdebug.show_local_vars = 1  
xdebug.max_nesting_level = 50  
xdebug.var_display_max_depth = 6  
xdebug.dump_once = On  
xdebug.dump_globals = On  
xdebug.dump_undefined = On  
xdebug.dump.REQUEST = *  
xdebug.dump.SERVER = REQUEST_METHOD,REQUEST_URI,HTTP_USER_AGENT  

xdebug.trace_format = 0  
xdebug.auto_trace = On  
xdebug.trace_output_name = trace.%c.%p  
xdebug.collect_params = 4 
xdebug.collect_includes = On  
xdebug.show_mem_delta = On  
</pre>
<pre class="brush: plain; title: ; notranslate">
;参数解释：
;zend_extension_ts=&quot;d:/webserver/php5/ext/php_xdebug.dll&quot;
;加载xdebug模块。这里不能用extension=php_xdebug.dll的方式加载，必须要以zend的方式加载，否则安装上后，phpinfo是显示不出xdebug这个项的。
;xdebug.auto_trace=on;
;自动打开“监测函数调用过程”的功模。该功能可以在你指定的目录中将函数调用的监测信息以文件的形式输出。此配置项的默认值为off。
;xdebug.collect_params=on;
;打开收集“函数参数”的功能。将函数调用的参数值列入函数过程调用的监测信息中。此配置项的默认值为off。
;xdebug.collect_return=on
;打开收集“函数返回值”的功能。将函数的返回值列入函数过程调用的监测信息中。此配置项的默认值为off。
;xdebug.trace_output_dir=”c:\Temp\xdebug”
;设定函数调用监测信息的输出文件的路径。
;xdebug.profiler_enable=on
;打开效能监测器。
;xdebug.profiler_output_dir=&quot;D:/web_server/xdebug/profilerlog&quot; 
;设定效能监测信息输出文件的路径。 

/*
xdebug.dump_once、xdebug.dump_globals、xdebug.dump_undefined 和 xdebug.dump_SUPERGLOBAL 设置（其中 SUPERGLOBAL 可以是 COOKIE、FILES、GET、POST、REQUEST、SERVER 或 SESSION）用于控制哪些 PHP 超全局变量将被包含在所有诊断结果中。  
  
将xdebug.dump_globals 设为 On 以转储名为 xdebug.dump_SUPERGLOBAL 设置中的超全局变量。例如，xdebug.dump_SERVER = REQUEST_METHOD,REQUEST_URI,HTTP_USER_AGENT 将打印 PHP 超全局变量 $_SERVER&#x5B;'REQUEST_METHOD']、$_SERVER&#x5B;'REQUEST_URI'] 和 $_SERVER&#x5B;'HTTP_USER_AGENT']。如果需要打印超全局变量数组中的所有值，请使用星号 (*)，例如 xdebug.dump_REQUEST=*。如果进一步将 xdebug.dump_undefined 设为 On 并且不设定指定的超全局变量，则仍用值 undefined 打印变量。  
  
即使捕捉到异常，代码行 xdebug.show_exception_trace = On 仍将强制执行异常跟踪。代码行 xdebug.show_local_vars = 1 将打印每个函数调用的最外围中的所有局部变量，包括尚未初始化的变量。而 xdebug.var_display_max_depth = 6 表示转储复杂变量的深度。  

跟踪代码  
  
解决错误 —— 如解开神秘谋杀之谜 —— 通常要求构造详细的时间线。例如，内存泄漏通常不会把自身表明为一个错误计算。相反，操作将正常进行，直至内存用尽，然后应用程序突然终止。如果内存泄漏由于某些请求而恶化，可能会不断出现错误并且难以预测。在内存使用量与时间之间建立映射的时间线将揭示泄漏的严重程度。一条精细的时间线 —— 比如，从函数到函数 —— 将进一步指出泄漏源。  
  
Xdebug 可以提供一条详细的时间线进行执行跟踪。当跟踪被启用后，Xdebug 将记录所有函数调用，包括每个函数的参数和返回值。您可以将每个日志或跟踪 的格式设为符合人类阅读习惯或者机器可读的格式。您最好使用前者，虽然您可能编写独立而特定的应用程序来分析后者。  
  
同转储一样，Xdebug 有若干个 php.ini 选项用于自定义跟踪内容。例如，下面一批设置将生成最详细的输出。  
  
xdebug.trace_format = 0  
xdebug.auto_trace = On  
xdebug.trace_output_dir=&quot;D:/web_server/xdebug/tracelog&quot;
xdebug.trace_output_name = trace.%c.%p  
  
xdebug.collect_params = 4  
xdebug.collect_includes = On  
xdebug.collect_return = On  
xdebug.show_mem_delta = On  
  
设定 xdebug.auto_trace = 1 将在执行所有 PHP 脚本之前先启用自动跟踪。另外，您可以通过代码设定 xdebug.auto_trace = 0，并分别使用 xdebug_start_trace() 和 xdebug_stop_trace() 函数启用和禁用跟踪。但是，如果 xdebug.auto_trace 为 1，则可以在包括配置好的 auto_prepend_file 之前先启动跟踪。  
  
选项 xdebug.trace_ouput_dir 和 xdebug.trace_output_name 用于控制保存跟踪输出的位置。在这里，所有文件都被保存到 /tmp/traces 中，并且每个跟踪文件都以 trace 为开头，后接 PHP 脚本的名称（%s）以及进程 ID（%p）。所有 Xdebug 跟踪文件都以 .xt 后缀结尾。  
  
默认情况下，Xdebug 将显示时间、内存使用量、函数名和函数调用深度字段。如果将 xdebug.trace_format 设为 0，则输出将符合人类阅读习惯（将参数设为 1 则为机器可读格式）。此外，如果指定 xdebug.show_mem_delta = 1，则可以查看内存使用量是在增加还是在减少，而如果指定 xdebug.collect_params = 4，则可以查看传入参数的类型和值。要监视每个函数返回的值，请设定 xdebug.collect_return = 1。  
*/
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>windows下手动搭建Apache+PHP+MySQL</title>
		<link>https://www.mudbest.com/windows%e4%b8%8b%e6%89%8b%e5%8a%a8%e6%90%ad%e5%bb%baapachephpmysql/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Tue, 30 Oct 2012 06:09:37 +0000</pubDate>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[下载]]></category>
		<category><![CDATA[安装]]></category>
		<category><![CDATA[配置]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1642</guid>

					<description><![CDATA[一、下载 http://pan.baidu.com/share/link?shareid=95859&#038 ... <a title="windows下手动搭建Apache+PHP+MySQL" class="read-more" href="https://www.mudbest.com/windows%e4%b8%8b%e6%89%8b%e5%8a%a8%e6%90%ad%e5%bb%baapachephpmysql/" aria-label="阅读 windows下手动搭建Apache+PHP+MySQL">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p><strong>一、下载</strong><br />
http://pan.baidu.com/share/link?shareid=95859&#038;uk=2349308099</p>
<p><strong>二、安装、解压</strong><br />
 1. Apache</p>
<p>　　主要配置Network Domain、Server Name、Email地址（我依次填的是localhost、localhost、邮箱随意）以及Apache服务的占用端口，默认为80端口，你可以根据需要配置在其他端口，Apache的安装目录你可以使用默认目录或根据需要自行选择安装目录（我安装到 D:\Apache）。<span id="more-1642"></span></p>
<p>　　在完成apache服务的安装后，在游览器中输入http://localhost/，出现It’s work!字样，说明Apache服务安装成功了。</p>
<p>2. PHP</p>
<p>　　只要解压php-5.3.4-Win32-VC6-x86.zip并重名为文件夹为php到某个盘即可完成PHP安装（我是将其解压复制到D盘目录下 D:\web_server\php5.3）</p>
<p> 3. MySQL</p>
<p>　　点击Mysql安装程序自动安装，在此期间你可以根据需要选择Mysql数据库的安装目录（我安装到 D:\web_server\MySQL），MySQL 安装完后会启动向导，你可以先取消，下一部的配置里有说。 </p>
<p><strong>三、配置 </strong><br />
<em><br />
 1. Apache（Apache配置文件httpd.conf在Apache安装目录下的conf文件夹里面）</em></p>
<p>(1)默认Apache服务器执行WEB主程序的目录为Apache2.2/htdocs，所以当你的WEB主程序目录变更时，我们需要修改相应的Apache配置（我改到D:\web_server\apache2.2\htdocs），即用文本编辑软件打开 httpd.conf 将 </p>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
&lt;Directory /&gt;
	Options FollowSymLinks
	AllowOverride None
	Order deny,allow
	Deny from all
&lt;/Directory&gt;
</pre>
<p>将其注释掉</p>
<pre class="brush: plain; title: ; notranslate">
#&lt;Directory /&gt;
#	Options FollowSymLinks
#	AllowOverride None
#	Order deny,allow
#	Deny from all
#&lt;/Directory&gt;
</pre>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
&lt;Directory &quot;D:/web_server/apache2.2/htdocs&quot;&gt;
	#
	# Possible values for the Options directive are &quot;None&quot;, &quot;All&quot;,
	# or any combination of:
	#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
	#
	# Note that &quot;MultiViews&quot; must be named *explicitly* --- &quot;Options All&quot;
	# doesn't give it to you.
	#
	# The Options directive is both complicated and important.  Please see
	# http://httpd.apache.org/docs/2.2/mod/core.html#options
	# for more information.
	#
	Options Indexes FollowSymLinks

	#
	# AllowOverride controls what directives may be placed in .htaccess files.
	# It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:
	#   Options FileInfo AuthConfig Limit
	#
	AllowOverride None

	#
	# Controls who can get stuff from this server.
	#
	Order allow,deny
	Allow from all

&lt;/Directory&gt;
</pre>
<p>将其注释</p>
<pre class="brush: plain; title: ; notranslate">
#&lt;Directory &quot;D:/web_server/apache2.2/htdocs&quot;&gt;
	#
	# Possible values for the Options directive are &quot;None&quot;, &quot;All&quot;,
	# or any combination of:
	#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
	#
	# Note that &quot;MultiViews&quot; must be named *explicitly* --- &quot;Options All&quot;
	# doesn't give it to you.
	#
	# The Options directive is both complicated and important.  Please see
	# http://httpd.apache.org/docs/2.2/mod/core.html#options
	# for more information.
	#
#	Options Indexes FollowSymLinks

	#
	# AllowOverride controls what directives may be placed in .htaccess files.
	# It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:
	#   Options FileInfo AuthConfig Limit
	#
#	AllowOverride None

	#
	# Controls who can get stuff from this server.
	#
#	Order allow,deny
#	Allow from all

#&lt;/Directory&gt;
</pre>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
#Include conf/extra/httpd-vhosts.conf
</pre>
<p>将注释去掉</p>
<pre class="brush: plain; title: ; notranslate">
Include conf/extra/httpd-vhosts.conf
</pre>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
#LoadModule rewrite_module modules/mod_rewrite.so
</pre>
<p>将注释去掉</p>
<pre class="brush: plain; title: ; notranslate">
#LoadModule rewrite_module modules/mod_rewrite.so
</pre>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
</pre>
<p>回车下一行增加以下内容</p>
<pre class="brush: plain; title: ; notranslate">
LoadModule php5_module &quot;D:/web_server/php5.3/php5apache2_2.dll&quot;
PHPIniDir &quot;D:/web_server/php5.3/&quot;
</pre>
<p>说明：在PHP目录下可以看到多个php5apache的DLL文件，由于我使用的是Apache2.2.17，所以我们当然需要使用php5apache2_2.dll，接着指定PHP的安装目录以及执行的程序扩展名。 </p>
<p><em> 2. PHP（配置文件php.ini在PHP安装目录下）</em></p>
<p>(1)把php.ini-development改名为php.ini，然后用文本编辑器修改php.ini，接下来的步骤都是在php.ini进行的。</p>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
; On windows:

; extension_dir = &quot;ext&quot;
</pre>
<p>修改为</p>
<pre class="brush: plain; title: ; notranslate">
; On windows:

extension_dir = &quot;D:/php/ext&quot;
</pre>
<p>表示指定PHP扩展包的具体目录，以便调用相应的DLL文件，这样就不用讲PHP的一些dll和php.ini复制到windows下了。</p>
<p>由于默认PHP并不支持自动连接Mysql，需开启相应的扩展库功能，比如php_mysql.dll等，即将 </p>
<pre class="brush: plain; title: ; notranslate">
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
;
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll 
; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
extension=php_openssl.dll
extension=php_pdo_firebird.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll

; The MIBS data available in the PHP distribution must be installed. 
; See http://www.php.net/manual/en/snmp.installation.php 
;extension=php_snmp.dll

;extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite.dll
extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
extension=php_xsl.dll
;extension=php_zip.dll

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
</pre>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
;session.save_path = &quot;/tmp&quot;
</pre>
<p>修改为</p>
<pre class="brush: plain; title: ; notranslate">
session.save_path = &quot;D:/web_server/php5.3/session&quot;
</pre>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
;upload_tmp_dir =
</pre>
<p>修改为</p>
<pre class="brush: plain; title: ; notranslate">
upload_tmp_dir = &quot;D:/web_server/php5.3/temp&quot;
</pre>
<p>找到</p>
<pre class="brush: plain; title: ; notranslate">
;date.timezone =
</pre>
<p>修改为</p>
<pre class="brush: plain; title: ; notranslate">
date.timezone = &quot;Asia/Shanghai&quot;
</pre>
<p><em>3. MySQL</em><br />
点击开始菜单下Mysql Server5.5菜单中的Mysql Server Instance Config Wizard，完成Mysql的配置向导。</p>
<p>点击 Next》 后出现3个选项：选择Mysql服务器的类型</p>
<p>Developer Machine</p>
<p>Server Machine</p>
<p>Dedicated MySQL Machine</p>
<p>我选第2个“Server Machine”</p>
<p>然后又是3个选项：Mysql数据库用途</p>
<p>Multifunctional Database</p>
<p>Transactional Database Only</p>
<p>Non-Transactional Database Only</p>
<p>我选第1个“Multifunctional Database”</p>
<p>选择Mysql数据库的并发连接数</p>
<p>Decision Support （DSS）/OLAP：最大20个连接并发数</p>
<p>Online Transaction Processing（OLTP）：最大500个并发连接数</p>
<p>Manual Setting：自定义</p>
<p>我选自定义，设置为50</p>
<p>选择Mysql服务的端口号，一般默认即可</p>
<p>选择Mysql数据库的字符集（推荐使用UTF8，比较通用，否则容易造成乱码。）</p>
<p>Standard Character Set</p>
<p>Best Support For Multilingualism</p>
<p>Manual Selected Default Character Set / Collation</p>
<p>我选“Manual Selected Default Character Set / Collation”，然后在 Character Set 选择 utf8</p>
<p>设置Mysql为Windows服务</p>
<p>在这里考虑开机速度的问题，我将自动登录Mysql服务取消了，一般你可以选择此选项，如果没有选，你可以使用net start mysql启动Mysql服务（停止就是net stop mysql）。</p>
<p>我的选择是“Install AS Windows Service”和“Include Bin Directory in Windows PATH”勾选，“Launch the MySQL Server automatically”去掉勾选</p>
<p>设置Mysql数据库root用户的密码</p>
<p>执行Mysql服务配置选项</p>
<p>Mysql数据库的配置文件保存在D:\MySQL\my.ini，如果今后有什么变动，你可以修改此文件。 </p>
<p>到此，所有配置完成。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHP常用设计模式</title>
		<link>https://www.mudbest.com/php%e5%b8%b8%e7%94%a8%e8%ae%be%e8%ae%a1%e6%a8%a1%e5%bc%8f/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Mon, 15 Oct 2012 06:42:51 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[设计模式]]></category>
		<category><![CDATA[软件开发]]></category>
		<category><![CDATA[软件设计]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1561</guid>

					<description><![CDATA[设计模式一书将设计模式引入软件社区，该书的作者是 Erich Gamma、Richard Helm、Ralph ... <a title="PHP常用设计模式" class="read-more" href="https://www.mudbest.com/php%e5%b8%b8%e7%94%a8%e8%ae%be%e8%ae%a1%e6%a8%a1%e5%bc%8f/" aria-label="阅读 PHP常用设计模式">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>设计模式一书将设计模式引入软件社区，该书的作者是 Erich Gamma、Richard Helm、Ralph Johnson 和 John Vlissides Design（俗称 &#8220;四人帮&#8221;）。所介绍的设计模式背后的核心概念非常简单。经过多年的软件开发实践，Gamma 等人发现了某些具有固定设计的模式，就像建筑师设计房子和建筑物一样，可以为浴室的位置或厨房的构造方式开发模板。使用这些模板或者说设计模式意味着可以更快地设计更好的建筑物。同样的概念也适用于软件。<span id="more-1561"></span></p>
<p>设计模式不仅代表着更快开发健壮软件的有用方法，而且还提供了以友好的术语封装大型理念的方法。例如，您可以说您正在编写一个提供松散耦合的消息传递系统，也可以说你正在编写名称为观察者的模式。</p>
<p>用较小的示例展示模式的价值是非常困难的。这往往有些大材小用的意味，因为模式实际上是在大型代码库中发挥作用的。本文不展示大型应用程序，所以您需要思索的是在您自己的大型应用程序中应用示例原理的方法 —— 而不是本文演示的代码本身。这不是说您不应该在小应用程序中使用模式。很多良好的应用程序都以小应用程序为起点，逐渐发展到大型应用程序，所以没有理由不以此类扎实的编码实践为基础。</p>
<p>既然您已经了解了设计模式以及它们的有用之处，现在我们来看看 PHP V5 的五种常用模式。</p>
<p><span style="color: #0000ff;"><strong>工厂模式</strong></span><br />
最初在设计模式 一书中，许多设计模式都鼓励使用松散耦合。要理解这个概念，让我们最好谈一下许多开发人员从事大型系统的艰苦历程。在更改一个代码片段时，就会发生问题，系统其他部分 —— 您曾认为完全不相关的部分中也有可能出现级联破坏。</p>
<p>该问题在于紧密耦合。系统某个部分中的函数和类严重依赖于系统的其他部分中函数和类的行为和结构。您需要一组模式，使这些类能够相互通信，但不希望将它们紧密绑定在一起，以避免出现联锁。</p>
<p>在大型系统中，许多代码依赖于少数几个关键类。需要更改这些类时，可能会出现困难。例如，假设您有一个从文件读取的 User 类。您希望将其更改为从数据库读取的其他类，但是，所有的代码都引用从文件读取的原始类。这时候，使用工厂模式会很方便。</p>
<p>工厂模式 是一种类，它具有为您创建对象的某些方法。您可以使用工厂类创建对象，而不直接使用 new。这样，如果您想要更改所创建的对象类型，只需更改该工厂即可。使用该工厂的所有代码会自动更改。</p>
<p><span style="text-decoration: underline;">清单 1 显示工厂类的一个示列。</span><br />
等式的服务器端包括两个部分：数据库和一组 PHP 页面，这些页面允许您添加反馈、请求反馈列表并获取与特定反馈相关的文章。</p>
<p>Factory1.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
interface IUser {
	function getName();
}

class User implements IUser {
	public function __construct($id) {
	}
	
	public function getName() {
		return &quot;Jack&quot;;
	}
}

class UserFactory {
	public static function Create($id) {
		return new User ( $id );
	}
}

$uo = UserFactory::Create ( 1 );
echo ($uo-&gt;getName () . &quot;\n&quot;);
?&gt;
</pre>
<p>IUser 接口定义用户对象应执行什么操作。IUser 的实现称为 User，UserFactory 工厂类则创建 IUser 对象。此关系可以用图 1 中的 UML 表示。<br />
图1：</p>
<div style="background: url('http://www.mudbest.com/wp-content/uploads/2012/10/design-patterns.png') no-repeat 0px 0px; width: 229px; height: 86px;"></div>
<p>测试代码会向工厂请求 User 对象，并输出 getName 方法的结果。</p>
<p>有一种工厂模式的变体使用工厂方法。类中的这些公共静态方法构造该类型的对象。如果创建此类型的对象非常重要，此方法非常有用。例如，假设您需要先创建对象，然后设置许多属性。此版本的工厂模式会将该进程封装在单个位置中，这样，不用复制复杂的初始化代码，也不必将复制好的代码在在代码库中到处粘贴。</p>
<p><span style="text-decoration: underline;">清单 2 显示使用工厂方法的一个示例。</span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
interface IUser {
	function getName();
}

class User implements IUser {
	public static function Load($id) {
		return new User ( $id );
	}

	public static function Create() {
		return new User ( null );
	}

	public function __construct($id) {
	}

	public function getName() {
		return &quot;Jack&quot;;
	}
}

$uo = User::Load ( 1 );
echo ($uo-&gt;getName () . &quot;\n&quot;);
?&gt;
</pre>
<p>这段代码要简单得多。它仅有一个接口 IUser 和一个实现此接口的 User 类。User 类有两个创建对象的静态方法。此关系可用图 2 中的 UML 表示。</p>
<p>图 2. IUser 接口和带有工厂方法的 user 类<br />
图2：</p>
<div style="background: url('http://www.mudbest.com/wp-content/uploads/2012/10/design-patterns.png') no-repeat 0px -89px; width: 95px; height: 113px;"></div>
<p>如上所述，有时此类模式在规模较小的环境中似乎有些大材小用。不过，最好还是学习这种扎实的编码形式，以便应用于任意规模的项目中。</p>
<p><span style="color: #0000ff;"><strong>单元素模式</strong></span><br />
某些应用程序资源是独占的，因为有且只有一个此类型的资源。例如，通过数据库句柄到数据库的连接是独占的。您希望在应用程序中共享数据库句柄，因为在保持连接打开或关闭时，它是一种开销，在获取单个页面的过程中更是如此。</p>
<p>单元素模式可以满足此要求。如果应用程序每次包含且仅包含一个对象，那么这个对象就是一个单元素（Singleton）。清单 3 中的代码显示了 PHP V5 中的一个数据库连接单元素。</p>
<p><span style="text-decoration: underline;">清单 3. Singleton.php</span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
require_once (&quot;DB.php&quot;);

class DatabaseConnection {
	public static function get() {
		static $db = null;
		if ($db == null)
			$db = new DatabaseConnection ();
		return $db;
	}

	private $_handle = null;

	private function __construct() {
		$dsn = 'mysql://root:password@localhost/photos';
		$this-&gt;_handle = &amp; DB::Connect ( $dsn, array () );
	}

	public function handle() {
		return $this-&gt;_handle;
	}
}

print (&quot;Handle = &quot; . DatabaseConnection::get ()-&gt;handle () . &quot;\n&quot;) ;
print (&quot;Handle = &quot; . DatabaseConnection::get ()-&gt;handle () . &quot;\n&quot;) ;
?&gt;
</pre>
<p>此代码显示名为 DatabaseConnection 的单个类。您不能创建自已的 DatabaseConnection，因为构造函数是专用的。但使用静态 get 方法，您可以获得且仅获得一个 DatabaseConnection 对象。此代码的 UML 如图 3 所示。</p>
<p>图 3. 数据库连接单元素<br />
图3：</p>
<div style="background: url('http://www.mudbest.com/wp-content/uploads/2012/10/design-patterns.png') no-repeat 0px -203px; width: 165px; height: 41px;"></div>
<p>在两次调用间，handle 方法返回的数据库句柄是相同的，这就是最好的证明。返回的两个句柄是同一对象。如果您在整个应用程序中使用数据库连接单元素，那么就可以在任何地方重用同一句柄。</p>
<p>您可以使用全局变量存储数据库句柄，但是，该方法仅适用于较小的应用程序。在较大的应用程序中，应避免使用全局变量，并使用对象和方法访问资源。</p>
<p><span style="color: #0000ff;"><strong>观察者模式</strong></span><br />
观察者模式为您提供了避免组件之间紧密耦合的另一种方法。该模式非常简单：一个对象通过添加一个方法（该方法允许另一个对象，即观察者 注册自己）使本身变得可观察。当可观察的对象更改时，它会将消息发送到已注册的观察者。这些观察者使用该信息执行的操作与可观察的对象无关。结果是对象可以相互对话，而不必了解原因。</p>
<p>一个简单示例是系统中的用户列表。清单 4 中的代码显示一个用户列表，添加用户时，它将发送出一条消息。添加用户时，通过发送消息的日志观察者可以观察此列表。</p>
<p><span style="text-decoration: underline;">清单 4. Observer.php</span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
interface IObserver {
	function onChanged($sender, $args);
}

interface IObservable {
	function addObserver($observer);
}

class UserList implements IObservable {
	private $_observers = array ();

	public function addCustomer($name) {
		foreach ( $this-&gt;_observers as $obs )
			$obs-&gt;onChanged ( $this, $name );
	}

	public function addObserver($observer) {
		$this-&gt;_observers &#x5B;] = $observer;
	}
}

class UserListLogger implements IObserver {
	public function onChanged($sender, $args) {
		echo (&quot;'$args' added to user list\n&quot;);
	}
}

$ul = new UserList ();
$ul-&gt;addObserver ( new UserListLogger () );
$ul-&gt;addCustomer ( &quot;Jack&quot; );
?&gt;
</pre>
<p>此代码定义四个元素：两个接口和两个类。IObservable 接口定义可以被观察的对象，UserList 实现该接口，以便将本身注册为可观察。IObserver 列表定义要通过怎样的方法才能成为观察者，UserListLogger 实现 IObserver 接口。图 4 的 UML 中展示了这些元素。</p>
<p>图 4. 可观察的用户列表和用户列表事件日志程序<br />
图4：</p>
<div style="background: url('http://www.mudbest.com/wp-content/uploads/2012/10/design-patterns.png') no-repeat 0px -246px; width: 414px; height: 99px;"></div>
<p>测试代码创建 UserList，并将 UserListLogger 观察者添加到其中。然后添加一个消费者，并将这一更改通知 UserListLogger。</p>
<p>认识到 UserList 不知道日志程序将执行什么操作很关键。可能存在一个或多个执行其他操作的侦听程序。例如，您可能有一个向新用户发送消息的观察者，欢迎新用户使用该系统。这种方法的价值在于 UserList 忽略所有依赖它的对象，它主要关注在列表更改时维护用户列表并发送消息这一工作。</p>
<p>此模式不限于内存中的对象。它是在较大的应用程序中使用的数据库驱动的消息查询系统的基础。</p>
<p><span style="color: #0000ff;"><strong>命令链模式</strong></span><br />
命令链 模式以松散耦合主题为基础，发送消息、命令和请求，或通过一组处理程序发送任意内容。每个处理程序都会自行判断自己能否处理请求。如果可以，该请求被处理，进程停止。您可以为系统添加或移除处理程序，而不影响其他处理程序。清单 5 显示了此模式的一个示例。<br />
<span style="text-decoration: underline;">清单 5. Chain.php</span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
interface ICommand {
	function onCommand($name, $args);
}

class CommandChain {
	private $_commands = array ();

	public function addCommand($cmd) {
		$this-&gt;_commands &#x5B;] = $cmd;
	}

	public function runCommand($name, $args) {
		foreach ( $this-&gt;_commands as $cmd ) {
			if ($cmd-&gt;onCommand ( $name, $args ))
				return;
		}
	}
}

class UserCommand implements ICommand {
	public function onCommand($name, $args) {
		if ($name != 'addUser')
			return false;
		echo (&quot;UserCommand handling 'addUser'\n&quot;);
		return true;
	}
}

class MailCommand implements ICommand {
	public function onCommand($name, $args) {
		if ($name != 'mail')
			return false;
		echo (&quot;MailCommand handling 'mail'\n&quot;);
		return true;
	}
}

$cc = new CommandChain ();
$cc-&gt;addCommand ( new UserCommand () );
$cc-&gt;addCommand ( new MailCommand () );
$cc-&gt;runCommand ( 'addUser', null );
$cc-&gt;runCommand ( 'mail', null );
?&gt;
</pre>
<p>此代码定义维护 ICommand 对象列表的 CommandChain 类。两个类都可以实现 ICommand 接口 —— 一个对邮件的请求作出响应，另一个对添加用户作出响应。 图 5 给出了 UML。</p>
<p>图 5. 命令链及其相关命令<br />
图5：</p>
<div style="background: url('http://www.mudbest.com/wp-content/uploads/2012/10/design-patterns.png') no-repeat 0px -347px; width: 359px; height: 121px;"></div>
<p>代码首先创建 CommandChain 对象，并为它添加两个命令对象的实例。然后运行两个命令以查看谁对这些命令作出了响应。如果命令的名称匹配 UserCommand 或 MailCommand，则代码失败，不发生任何操作。为处理请求而创建可扩展的架构时，命令链模式很有价值，使用它可以解决许多问题。</p>
<p><span style="color: #0000ff;"><strong>策略模式</strong></span><br />
我们讲述的最后一个设计模式是策略 模式。在此模式中，算法是从复杂类提取的，因而可以方便地替换。例如，如果要更改搜索引擎中排列页的方法，则策略模式是一个不错的选择。思考一下搜索引擎的几个部分 —— 一部分遍历页面，一部分对每页排列，另一部分基于排列的结果排序。在复杂的示例中，这些部分都在同一个类中。通过使用策略模式，您可将排列部分放入另一个类中，以便更改页排列的方式，而不影响搜索引擎的其余代码。</p>
<p>作为一个较简单的示例，清单 6 显示了一个用户列表类，它提供了一个根据一组即插即用的策略查找一组用户的方法。<br />
<span style="text-decoration: underline;">清单 6. Strategy.php</span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
interface IStrategy {
	function filter($record);
}

class FindAfterStrategy implements IStrategy {
	private $_name;

	public function __construct($name) {
		$this-&gt;_name = $name;
	}

	public function filter($record) {
		return strcmp ( $this-&gt;_name, $record ) &lt;= 0;
	}
}

class RandomStrategy implements IStrategy {
	public function filter($record) {
		return rand ( 0, 1 ) &gt;= 0.5;
	}
}

class UserList {
	private $_list = array ();

	public function __construct($names) {
		if ($names != null) {
			foreach ( $names as $name ) {
				$this-&gt;_list &#x5B;] = $name;
			}
		}
	}

	public function add($name) {
		$this-&gt;_list &#x5B;] = $name;
	}

	public function find($filter) {
		$recs = array ();
		foreach ( $this-&gt;_list as $user ) {
			if ($filter-&gt;filter ( $user ))
				$recs &#x5B;] = $user;
		}
		return $recs;
	}
}

$ul = new UserList ( array (&quot;Andy&quot;, &quot;Jack&quot;, &quot;Lori&quot;, &quot;Megan&quot; ) );
$f1 = $ul-&gt;find ( new FindAfterStrategy ( &quot;J&quot; ) );
print_r ( $f1 );

$f2 = $ul-&gt;find ( new RandomStrategy () );
print_r ( $f2 );
?&gt;
</pre>
<p>此代码的 UML 如图 6 所示。<br />
图 6. 用户列表和用于选择用户的策略<br />
图6：</p>
<div style="background: url('http://www.mudbest.com/wp-content/uploads/2012/10/design-patterns.png') no-repeat 0px -470px; width: 309px; height: 138px;"></div>
<p>UserList 类是打包名称数组的一个包装器。它实现 find 方法，该方法利用几个策略之一来选择这些名称的子集。这些策略由 IStrategy 接口定义，该接口有两个实现：一个随机选择用户，另一个根据指定名称选择其后的所有名称。</p>
<p>测试代码为两个策略运行同一用户列表，并显示结果。在第一种情况中，策略查找排列在 J 后的任何名称，所以您将得到 Jack、Lori 和 Megan。第二个策略随机选取名称，每次会产生不同的结果。在这种情况下，结果为 Andy 和 Megan。</p>
<p>策略模式非常适合复杂数据管理系统或数据处理系统，二者在数据筛选、搜索或处理的方式方面需要较高的灵活性。</p>
<p><span style="color: #0000ff;"><strong>结束语</strong></span><br />
本文介绍的仅仅是 PHP 应用程序中使用的几种最常见的设计模式。在设计模式 一书中演示了更多的设计模式。不要因架构的神秘性而放弃。模式是一种绝妙的理念，适用于任何编程语言、任何技能水平。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>关于PHP的几个版本和线程安全的讨论</title>
		<link>https://www.mudbest.com/%e5%85%b3%e4%ba%8ephp%e7%9a%84%e5%87%a0%e4%b8%aa%e7%89%88%e6%9c%ac%e5%92%8c%e7%ba%bf%e7%a8%8b%e5%ae%89%e5%85%a8%e7%9a%84%e8%ae%a8%e8%ae%ba/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Wed, 28 Mar 2012 06:22:47 +0000</pubDate>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Thread Safe]]></category>
		<category><![CDATA[线程安全]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1018</guid>

					<description><![CDATA[从PHP5.2.10版本开始（现在有PHP5.2.10和5.3两个版本），有None-Thread Safe与 ... <a title="关于PHP的几个版本和线程安全的讨论" class="read-more" href="https://www.mudbest.com/%e5%85%b3%e4%ba%8ephp%e7%9a%84%e5%87%a0%e4%b8%aa%e7%89%88%e6%9c%ac%e5%92%8c%e7%ba%bf%e7%a8%8b%e5%ae%89%e5%85%a8%e7%9a%84%e8%ae%a8%e8%ae%ba/" aria-label="阅读 关于PHP的几个版本和线程安全的讨论">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>从PHP5.2.10版本开始（现在有PHP5.2.10和5.3两个版本），有None-Thread Safe与Thread Safe两种版本的可供选择，这两种版本有何不同，作为使用者来说又应该如何选择呢？下面聚友将为您讲述。</p>
<p>先从字面意思上理解，None-Thread Safe就是非线程安全，在执行时不进行线程（thread）安全检查；Thread Safe就是线程安全，执行时会进行线程（thread）安全检查，以防止有新要求就启动新线程的 CGI 执行方式耗尽系统资源。</p>
<p>一、如何选择PHP5.3的VC9版本和VC6版本<br />
<span id="more-1018"></span><br />
VC6版本是使用Visual Studio 6编译器编译的，如果你的PHP是用Apache来架设的，那你就选择VC6版本。</p>
<p>VC9版本是使用Visual Studio 2008编译器编译的，如果你的PHP是用IIS来架设的，那你就选择VC9版本。</p>
<p>二、如何选择PHP5.3的Thread Safe和Non Thread Safe版本</p>
<p>Windows版的PHP从版本5.2.1开始有Thread Safe(线程安全)和None Thread Safe(NTS，非线程安全)之分，这两者不同在于何处？到底应该用哪种？这里做一个简单的介绍。</p>
<p>　从2000年10月20日发布的第一个Windows版的PHP3.0.17开始的都是线程安全的版本，这是由于与Linux/Unix系统是采用多进程的工作方式不同的是Windows系统是采用多线程的工作方式。如果在IIS下以CGI方式运行PHP会非常慢，这是由于CGI模式是建立在多进程的基础之上的，而非多线程。一般我们会把PHP配置成以ISAPI的方式来运行，ISAPI是多线程的方式，这样就快多了。但存在一个问题，很多常用的PHP 扩展是以Linux/Unix的多进程思想来开发的，这些扩展在ISAPI的方式运行时就会出错搞垮IIS。因此在IIS下CGI模式才是 PHP运行的最安全方式，但CGI模式对于每个HTTP请求都需要重新加载和卸载整个PHP环境，其消耗是巨大的。</p>
<p>　为了兼顾IIS下PHP的效率和安全，微软给出了FastCGI的解决方案。FastCGI可以让PHP的进程重复利用而不是每一个新的请求就重开一个进程。同时FastCGI也可以允许几个进程同时执行。这样既解决了CGI进程模式消耗太大的问题，又利用上了CGI进程模式不存在线程安全问题的优势。 </p>
<p>先从字面意思上理解，Thread Safe是线程安全，执行时会进行线程（Thread）安全检查，以防止有新要求就启动新线程的CGI执行方式而耗尽系统资源。Non Thread Safe是非线程安全，在执行时不进行线程（Thread）安全检查。</p>
<p>　因此，如果是使用ISAPI的方式来运行PHP就必须用Thread Safe(线程安全)的版本；而用FastCGI模式运行PHP的话就没有必要用线程安全检查了，用None Thread Safe(NTS，非线程安全)的版本能够更好的提高效率。</p>
<p>再来看PHP的两种执行方式：ISAPI和FastCGI。</p>
<p>ISAPI执行方式是以DLL动态库的形式使用，可以在被用户请求后执行，在处理完一个用户请求后不会马上消失，所以需要进行线程安全检查，这样来提高程序的执行效率，所以如果是以ISAPI来执行PHP，建议选择Thread Safe版本；</p>
<p>而FastCGI执行方式是以单一线程来执行操作，如果是以 FastCGI（无论搭配 IIS 6 或 IIS 7）执行 PHP ，都建议下载、执行 non-thread safe 的 PHP （PHP 的二進位檔有兩種包裝方式：msi 、zip ，請下載 zip 套件），除去线程安全检查的防护反而可以提高执行效率，所以，如果是以FastCGI来执行PHP，建议选择Non Thread Safe版本。而线程安全检查正是为ISAPI方式的PHP准备的，因为有许多php模块都不是线程安全的，所以需要使用Thread Safe的PHP。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Windows 2008 64位Apache+PHP+MySQL配置</title>
		<link>https://www.mudbest.com/windows-2008-64%e4%bd%8dapachephpmysql%e9%85%8d%e7%bd%ae/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Wed, 07 Mar 2012 01:49:58 +0000</pubDate>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[64位]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows2008]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=886</guid>

					<description><![CDATA[附件安装包默认是d:/case/，目录下，如果放在这个目录可不进行任何设置，可跳到apache安装步骤3，进行 ... <a title="Windows 2008 64位Apache+PHP+MySQL配置" class="read-more" href="https://www.mudbest.com/windows-2008-64%e4%bd%8dapachephpmysql%e9%85%8d%e7%bd%ae/" aria-label="阅读 Windows 2008 64位Apache+PHP+MySQL配置">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>附件安装包默认是d:/case/，目录下，如果放在这个目录可不进行任何设置，可跳到apache安装步骤3，进行开启服务即可。</p>
<p><strong>安装Apache 64位</strong></p>
<p>1.解压</p>
<p>将下载的httpd-2.2.17-win64.rar压缩包解压到某一目录下，如D:\case\Apache2.2</p>
<p>2.编辑配置文件D:\case\Apache2.2\conf\httpd.conf作如下修改【注意路径中必须使用左斜杠】：<span id="more-886"></span></p>
<p>ServerRoot &#8220;/httpd-2.2-x64&#8243;改为</p>
<p>ServerRoot &#8220;D:/case/Apache2.2&#8221;</p>
<p>Listen 80改为</p>
<p>Listen 8080 #端口，若已开启IIS，则80端口就不能使用了</p>
<p>DocumentRoot &#8220;/httpd-2.2-x64/htdocs&#8221;改为</p>
<p>DocumentRoot &#8220;D:/case/Apache2.2/htdocs&#8221; #放置网站文件的路径</p>
<p>DirectoryIndex index.html改为</p>
<p>DirectoryIndex index.html index.htm index.php  #加入index.php，PHP的默认页</p>
<p>ScriptAlias /cgi-bin/ &#8220;/httpd-2.2-x64/cgi-bin/&#8221;改为</p>
<p>ScriptAlias /cgi-bin/ &#8220;D:/case/Apache2.2/cgi-bin/&#8221;</p>
<p><Directory "/httpd-2.2-x64/htdocs">改为</p>
<p><Directory "D:/case/Apache2.2/htdocs"></p>
<p><Directory "/httpd-2.2-x64/cgi-bin">改为</p>
<p><Directory "D:/case/Apache2.2/cgi-bin"></p>
<p>将LoadModule rewrite_module modules/mod_rewrite.so前的#去掉</p>
<p>3.执行安装命令：</p>
<p>进入D:\case\Apache2.2\bin</p>
<p>执行命令：httpd.exe -k install(将apache加入系统服务，默认服务名是Apache2.2)</p>
<p>执行命令：httpd.exe -k start(运行服务)</p>
<p>注：启动多个apache方法<br />
/usr/local/apache2/bin/httpd  -f /路径2/httpd.conf -k start</p>
<p>以后可以使用D:\case\Apache2.2\bin\ApacheMonitor.exe进行服务的开启、关闭、重启与监控等操作</p>
<p>4.测试安装是否成功</p>
<p>打开浏览器，输入：http://localhost:8080，显示It Works！ 说明成功！</p>
<p><strong>安装PHP 64位</strong></p>
<p>1.将下载的php安装包php-5.2.5-x64-2007-11-12.zip中的php-5.2.5 (x64)文件夹复制到某一路径下，如D:\case\PHP</p>
<p>2.修改配置文件D:\case\Apache2.2\conf\httpd.conf</p>
<p>在#LoadModule vhost_alias_module modules/mod_vhost_alias.so一行下加上：</p>
<p>LoadModule php5_module &#8220;D:/case/PHP/php5apache2_2.dll&#8221;</p>
<p>PHPIniDir &#8220;D:/PHP&#8221;</p>
<p>在AddType application/x-gzip .gz .tgz下加上：</p>
<p>AddType application/x-httpd-php .php</p>
<p>AddType application/x-httpd-php .html  #.html, .php为可执行php语言的扩展名</p>
<p>3.将D:\PHP\php.ini-recommended复制为D:\PHP\php.ini，并作如下修改</p>
<p>修改extension_dir = &#8220;./&#8221;为</p>
<p>extension_dir = &#8220;d:/case/php&#8221; #指定动态连接库的目录  php的安装目录</p>
<p><strong>注：dll组件部分根据自己的需求开启，去掉前面的注释“;”即可。</strong><br />
将extension=php_mysql.dll前的分号（注释）去掉</p>
<p>4.测试是否安装成功</p>
<p>修改D:\case\Apache2.2\htdocs\index.html文件，加入：<?php echo phpinfo(); ?></p>
<p>重启httpd服务输入网址：http://loalhost:8080 ，看到php信息，说明成功！</p>
<p>附件包：<br />
<a href='http://www.mudbest.com/886.action/x64-apache2-2-php5-25' rel='attachment wp-att-887'>x64.apache2.2-php5.25</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>上一条下一条记录显示</title>
		<link>https://www.mudbest.com/%e4%b8%8a%e4%b8%80%e6%9d%a1%e4%b8%8b%e4%b8%80%e6%9d%a1%e8%ae%b0%e5%bd%95%e6%98%be%e7%a4%ba/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 16:21:56 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Mysql]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=728</guid>

					<description><![CDATA[id作为自增int SQL语句如下即可： 上一条 SELECT * FROM A WHERE id &#60;  ... <a title="上一条下一条记录显示" class="read-more" href="https://www.mudbest.com/%e4%b8%8a%e4%b8%80%e6%9d%a1%e4%b8%8b%e4%b8%80%e6%9d%a1%e8%ae%b0%e5%bd%95%e6%98%be%e7%a4%ba/" aria-label="阅读 上一条下一条记录显示">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>id作为自增int SQL语句如下即可：<br />
上一条<br />
<span id="more-728"></span></p>
<pre class="brush: sql; title: ; notranslate">
SELECT * FROM A WHERE id &lt; $id ORDER BY id DESC LIMIT 1 
</pre>
<p>下一条 </p>
<pre class="brush: sql; title: ; notranslate">
SELECT * FROM A WHERE id &gt; $id ORDER BY id ASC LIMIT 1
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
