<?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>Cote de Azur &#187; php</title>
	<atom:link href="http://www.moneypa.com/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.moneypa.com/blog</link>
	<description>About programming and  Software testing</description>
	<lastBuildDate>Fri, 05 Aug 2011 07:08:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>与 UNIX 构建系统交互: config.m4</title>
		<link>http://www.moneypa.com/blog/20110706-%e4%b8%8e-unix-%e6%9e%84%e5%bb%ba%e7%b3%bb%e7%bb%9f%e4%ba%a4%e4%ba%92-config-m4/</link>
		<comments>http://www.moneypa.com/blog/20110706-%e4%b8%8e-unix-%e6%9e%84%e5%bb%ba%e7%b3%bb%e7%bb%9f%e4%ba%a4%e4%ba%92-config-m4/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 14:08:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.moneypa.com/blog/?p=1396</guid>
		<description><![CDATA[扩展的 config.m4 文件告诉 UNIX 构建系统哪些扩展 configure 选项是支持的，你需要哪些扩展库，以及哪些源文件要编译成它的一部分。对所有经常使用的 autoconf 宏，包括 PHP 特定的及 autoconf 内建的，请查看 Zend Engine 2 API 参考 章节。 Tip当开发 PHP 扩展时，强烈建议安装 autoconf 2.13 版，尽管用更新的版本可使用。2.13 版被认为是在 autoconf 中可用性，适用性及用户基础等方面最好的版本。使用最新版本有时会与所期望的 configure 输出在样式上有所不同。 Example #1 config.m4 文件举例 dnl $Id$ dnl config.m4 for extension example PHP_ARG_WITH(example, for example support, [ --with-example[=FILE] Include example support. File is the optional path [...]]]></description>
			<content:encoded><![CDATA[<p>扩展的 <var>config.m4</var> 文件告诉 UNIX    构建系统哪些扩展 <var>configure</var> 选项是支持的，你需要哪些扩展库，以及哪些源文件要编译成它的一部分。对所有经常使用的 autoconf 宏，包括 PHP 特定的及    autoconf 内建的，请查看 <a href="http://www.hfphp.org/docs/php/internals2.apiref.html">Zend Engine 2 API 参考</a> 章节。</p>
<div><strong>Tip</strong>当开发 PHP 扩展时，<em>强烈</em>建议安装 <strong>autoconf</strong> 2.13 版，尽管用更新的版本可使用。2.13 版被认为是在 <strong>autoconf</strong> 中可用性，适用性及用户基础等方面最好的版本。使用最新版本有时会与所期望的 	<strong>configure</strong> 输出在样式上有所不同。</p>
</div>
<div>
<p><strong>Example #1 config.m4 文件举例</strong></p>
<div>
<div>
<pre>dnl $Id$
dnl config.m4 for extension example</pre>
</div>
<div>
<pre>PHP_ARG_WITH(example, for example support,
[  --with-example[=FILE]       Include example support. File is the optional path to example-config])
PHP_ARG_ENABLE(example-debug, whether to enable debugging support in example,
[  --enable-example-debug        example: Enable debugging support in example], no, no)
PHP_ARG_WITH(example-extra, for extra libraries for example,
[  --with-example-extra=DIR      example: Location of extra libraries for example], no, no)

dnl 检测扩展是否已启用
if test "$PHP_EXAMPLE" != "no"; then

  dnl 检测 example-config。首先尝试所给出的路径，然后在 $PATH 中寻找
  AC_MSG_CHECKING([for example-config])
  EXAMPLE_CONFIG="example-config"
  if test "$PHP_EXAMPLE" != "yes"; then
    EXAMPLE_PATH=$PHP_EXAMPLE
  else
    EXAMPLE_PATH=`$php_shtool path $EXAMPLE_CONFIG`
  fi

  dnl 如果找到可用的 example-config，就使用它
  if test -f "$EXAMPLE_PATH" &amp;&amp; test -x "$EXAMPLE_PATH" &amp;&amp; $EXAMPLE_PATH --version &gt; /dev/null 2&gt;&amp;1; then
    AC_MSG_RESULT([$EXAMPLE_PATH])
    EXAMPLE_LIB_NAME=`$EXAMPLE_PATH --libname`
    EXAMPLE_INCDIRS=`$EXAMPLE_PATH --incdirs`
    EXAMPLE_LIBS=`$EXAMPLE_PATH --libs`

    dnl 检测扩展库是否工作正常
    PHP_CHECK_LIBRARY($EXAMPLE_LIB_NAME, example_critical_function,
    [
      dnl 添加所需的 include 目录
      PHP_EVAL_INCLINE($EXAMPLE_INCDIRS)
      dnl 添加所需的扩展库及扩展库所在目录
      PHP_EVAL_LIBLINE($EXAMPLE_LIBS, EXAMPLE_SHARED_LIBADD)
    ],[
      dnl 跳出
      AC_MSG_ERROR([example library not found. Check config.log for more information.])
    ],[$EXAMPLE_LIBS]
    )
  else
    dnl 没有可用的 example-config，跳出
    AC_MSG_RESULT([not found])
    AC_MSG_ERROR([Please check your example installation.])
  fi

  dnl 检测是否启用调试
  if test "$PHP_EXAMPLE_DEBUG" != "no"; then
    dnl 是，则设置 C 语言宏指令
    AC_DEFINE(USE_EXAMPLE_DEBUG,1,[Include debugging support in example])
  fi

  dnl 检测额外的支持
  if test "$PHP_EXAMPLE_EXTRA" != "no"; then
    if test "$PHP_EXAMPLE_EXTRA" == "yes"; then
      AC_MSG_ERROR([You must specify a path when using --with-example-extra])
    fi

    PHP_CHECK_LIBRARY(example-extra, example_critical_extra_function,
    [
      dnl 添加所需路径
      PHP_ADD_INCLUDE($PHP_EXAMPLE_EXTRA/include)
      PHP_ADD_LIBRARY_WITH_PATH(example-extra, $PHP_EXAMPLE_EXTRA/lib, EXAMPLE_SHARED_LIBADD)
      AC_DEFINE(HAVE_EXAMPLEEXTRALIB,1,[Whether example-extra support is present and requested])
      EXAMPLE_SOURCES="$EXAMPLE_SOURCES example_extra.c"
    ],[
      AC_MSG_ERROR([example-extra lib not found. See config.log for more information.])
    ],[-L$PHP_EXAMPLE_EXTRA/lib]
    )
  fi

  dnl 最后，将扩展及其所需文件等信息传给构建系统
  PHP_NEW_EXTENSION(example, example.c $EXAMPLE_SOURCES, $ext_shared)
  PHP_SUBST(EXAMPLE_SHARED_LIBADD)
fi</pre>
</div>
</div>
</div>
<div id="internals2.buildsys.configunix.autoconf">
<h3>autoconf 语法简介</h3>
<p><var>config.m4</var> 文件使用 GNU <strong>autoconf</strong> 语法编写。简而言之，就是用强大的宏语言增强的 	 shell 脚本。注释用字符串 <em>dnl</em> 分隔，字符串则放在左右方括号中间（例如，<em>[</em> 和 	 <em>]</em>）。字符串可按需要多次嵌套引用。完整的语法参考可参见位于 	 <a href="http://www.gnu.org/software/autoconf/manual/">» http://www.gnu.org/software/autoconf/manual/</a> 的  <strong>autoconf</strong> 手册。</p>
</div>
<div id="internals2.buildsys.configunix.php-arg">
<h3>PHP_ARG_*: 赋予用户可选项</h3>
<p>在以上的 <var>config.m4</var> 例子中，两条注释后，最先见到的 3 	行代码，使用了 <strong>PHP_ARG_WITH()</strong> 和 	<strong>PHP_ARG_ENABLE()</strong>。这些给 	<strong>configure</strong> 提供了可选项，和在运行 	<strong>./configure &#8211;help</strong> 时显示的帮助文本。就象名称所暗示的，其两者的不同点在于是创建 	<strong>&#8211;with-*</strong> 选项还是 <strong>&#8211;enable-*</strong> 选项。每个扩展应提供至少一个以上的选项以及扩展名称，以便用户可选择是否将扩展构建至  PHP 	中。按惯例，<strong>PHP_ARG_WITH()</strong> 用于取得参数的选项，例如扩展所需库或程序的位置；而 	<strong>PHP_ARG_ENABLE()</strong> 用于代表简单标志的选项。</p>
<div>
<p><strong>Example #2 configure 输出举例</strong></p>
<div>
<div>
<pre>$ ./configure --help
...
  --with-example[=FILE]       Include example support. FILE is the optional path to example-config
  --enable-example-debug        example: Enable debugging support in example
  --with-example-extra=DIR      example: Location of extra libraries for example
...

$ ./configure --with-example=/some/library/path/example-config --disable-example-debug --with-example-extra=/another/library/path
...
checking for example support... yes
checking whether to enable debugging support in example... no
checking for extra libraries for example... /another/library/path
...
</pre>
</div>
</div>
</div>
<blockquote><p><strong>Note</strong>:</p>
<p>在调用 <strong>configure</strong> 时，不管选项在命令行中的顺序如何，都会按在 	 <var>config.m4</var> 中指定的顺序进行检测。</p></blockquote>
</div>
<div id="internals2.buildsys.configunix.processing">
<h3>处理用户选择</h3>
<p><var>config.m4</var> 可给用户提供一些做什么的选择，现在就是做出选择的时候了。在上例中，三个选项在未指定时显然默认为 	&#8220;no&#8221;。习惯上，最好用此值作为用于启用扩展的选项的默认值，为了扩展与 PHP 分开构建则用 <strong>phpize</strong> 覆盖此值，而要构建在 PHP 	中时则不应被默认值将扩展空间弄乱。处理这三个选项的代码要复杂得多。</p>
<div id="internals2.buildsys.configunix.processing.with-example">
<h4>处理 &#8211;with-example[=FILE] 选项</h4>
<p>首先检测是否设置了 <strong>&#8211;with-example[=FILE]</strong> 选项。如此选项未被指定，或使用否定的格式（<strong>&#8211;without-example</strong> ），或赋值为 &#8220;no&#8221; 	 时，它会控制整个扩展的含有物其他任何事情都不会发生。在上面的例子中所指定的值为 	 <em>/some/library/path/example-config</em>，所以第一个 test 成功了。</p>
<p>接下来，代码调用 <strong>AC_MSG_CHECKING()</strong>，这是一个 <strong>autoconf</strong> 宏，输出一行标准的如 	 &#8220;checking for &#8230;&#8221; 的信息，并检测用户假定的 	 <strong>example-config</strong> 是否是一个明确的路径。在这个例子中，<em>PHP_EXAMPLE</em> 所取到的值为 <em>/some/library/path/example-config</em>，现已复制到 	 EXAMPLE_PATH 变量中了。只有用户指定了 	 <strong>&#8211;with-example</strong> ，才会执行代码 	 <strong>$php_shtool path $EXAMPLE_CONFIG</strong>，尝试使用用户当前的 	 <em>PATH</em> 环境变量推测 <strong>example-config</strong> 的位置。无论如何，下一步都是检测所选的 <em>EXAMPLE_PATH</em> 是否是正常文件，是否可执行，及是否执行成功。如成功，则调用 	 <strong>AC_MSG_RESULT()</strong>，结束由 	 <strong>AC_MSG_CHECKING()</strong> 开始的输出行。否则，调用 	 <strong>AC_MSG_ERROR()</strong>，打印所给的信息并立即中断执行 	 <strong>configure</strong>。</p>
<p>代码现在执行几次 <strong>example-config</strong> 以确定一些站点特定的配置信息。下一步调用的是 	 <strong>PHP_CHECK_LIBRARY()</strong>，这是 PHP 	 构建系统提供的一个宏，包装了 <strong>autoconf</strong> 的 	 <strong>AC_CHECK_LIB()</strong> 函数。<strong>PHP_CHECK_LIBRARY()</strong> 尝试编译、链接和执行程序，在第一个参数指定的库中调用由第二个参数指定的符号，使用第五个参数给出的字符串作为额外的链接选项。如果尝试成功了，则运行第三个参数所给出的脚本。此脚本从 	 <strong>example-config</strong> 所提供的原始的选项字符串中取出头文件路径、库文件路径和库名称，告诉 	 PHP 构建系统。如果尝试失败，脚本则运行第四个参数中的脚本。此时调用 	 <strong>AC_MSG_ERROR()</strong> 来中断程序执行。</p>
</div>
<div id="internals2.buildsys.configunix.processing.enable-example-debug">
<h4>处理 &#8211;enable-example-debug 选项</h4>
<p>处理 <strong>&#8211;enable-example-debug</strong> 很简单。只简单地检测其真实值。如果检测成功，则调用      <strong>AC_DEFINE()</strong> 使 C 语言宏指令 <em>USE_EXAMPLE_DEBUG</em> 可用于扩展的源代码。第三个参数是给      <var>config.h</var> 的注释字符串，通常可放心的留空。</p>
</div>
<div id="internals2.buildsys.configunix.processing.with-example-extra">
<h4>处理 &#8211;with-example-extra=DIR 选项</h4>
<p>对于此例子来说，由 <strong>&#8211;with-example-extra=DIR</strong> 选项所请求的假定的“额外”功能操作不会与假定的 	 <strong>example-config</strong> 程序共享，也没有默认的搜索路径。因此，用户需要在所需的库之前提供设置程序。有点不象现实中的扩展，在这里的设置仅仅起说明性的作用。</p>
<p>代码开始用已熟知的方式来检测 <em>PHP_EXAMPLE_EXTRA</em> 的真实值。如果所提供的为否定形式，则不会进行其他处理，用户也不会请求额外的功能。如果所提供的为未提供参数的肯定形式，则调用 	 <strong>AC_MSG_ERROR()</strong> 中止处理。下一步则再次调用 	 <strong>PHP_CHECK_LIBRARY()</strong>。这一次，因为没有提供预定义编译选项，<strong>PHP_ADD_INCLUDE()</strong> 和 <strong>PHP_ADD_LIBRARY_WITH_PATH()</strong> 用于构建额外功能所需的头文件路径、库文件路径和库标志。也调用 	 <strong>AC_DEFINE()</strong> 来指示所请求的额外功能代码是可用的，设置变量来告诉以后的代码，有额外的源代码要构建。如果检测失败，则调用所熟悉的 	 <strong>AC_MSG_ERROR()</strong>。另一种不同的处理失败的方式是更换为调用 	 <strong>AC_MSG_WARNING()</strong>，例如：</p>
<div>
<div>
<div>
<pre>AC_MSG_WARNING([example-extra lib not found. example will be built without extra functionality.])</pre>
</div>
</div>
</div>
<p>上例中，<strong>configure</strong> 会打印一段警告信息而不是错误，且继续处理。用哪种方式处理失败留给扩展开发人员在设计时决定。</p>
</div>
</div>
<div id="internals2.buildsys.configunix.finishing">
<h3>告诉构建系统要做什么</h3>
<p>有了所需的头文件和特定的库，有了全部选项处理代码及宏定义，还有一件事要做：必须告诉构建系统去构建扩展本身和被其用到的文件。为了做这些，则要调用     <strong>PHP_NEW_EXTENSION()</strong> 宏。第一个参数是扩展的名称，和包含它的目录同名。第二个参数是做为扩展的一部分的所有源文件的列表。参见     <strong>PHP_ADD_BUILD_DIR()</strong> 以获取将在子目录中源文件添加到构建过程的相关信息。第三个参数总是 <em>$ext_shared</em>，     当为了 <strong>&#8211;with-example[=FILE]</strong> 而调用     <strong>PHP_ARG_WITH()</strong>时，由 <strong>configure</strong> 决定参数的值。第四个参数指定一个“SAPI 类”，仅用于专门需要 CGI 或 CLI SAPI     的扩展。其他情况下应留空。第五个参数指定了构建时要加入 <em>CFLAGS</em> 的标志列表。第六个参数是一个布尔值，为 &#8220;yes&#8221; 时会强迫整个扩展使用     <em>$CXX</em> 代替 <em>$CC</em> 来构建。第三个以后的所有参数都是可选的。最后，调用     <strong>PHP_SUBST()</strong> 来启用扩展的共享构建。参见 <a href="http://www.hfphp.org/docs/php/internals2.faq.html">扩展相关 FAQ</a> 以获取更多有关禁用共享方式下构建扩展的信息。</p>
</div>
<div id="internals2.buildsys.configunix.counter">
<h3>counter 扩展的 config.m4 文件</h3>
<p>以前编写的 counter 扩展有一个比上面所述更简单的 <var>config.m4</var> 文件，它不使用很多构建系统的特性。对不使用外部的或绑定的库的扩展来说，这是一个比较好的操作方式。</p>
<div>
<p><strong>Example #3 counter 的 config.m4 文件</strong></p>
<div>
<div>
<pre>dnl</pre>
</div>
<div>
<pre>$</pre>
</div>
<div>
<pre>Id$
dnl config.m4 for extension counter

PHP_ARG_ENABLE(counter, for counter support,
[  --enable-counter            Include counter support])

dnl Check whether the extension is enabled at all
if test "$PHP_COUNTER" != "no"; then
  dnl Finally, tell the build system about the extension and what files are needed
  PHP_NEW_EXTENSION(counter, counter.c counter_util.c, $ext_shared)
  PHP_SUBST(COUNTER_SHARED_LIBADD)
fi</pre>
</div>
</div>
</div>
</div>
<p>﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20110706-%e4%b8%8e-unix-%e6%9e%84%e5%bb%ba%e7%b3%bb%e7%bb%9f%e4%ba%a4%e4%ba%92-config-m4/feed/</wfw:commentRss>
		<slash:comments>111</slash:comments>
		</item>
		<item>
		<title>Common Errors while installing PHP 5 from source in Ubuntu 10</title>
		<link>http://www.moneypa.com/blog/20110706-common-errors-while-installing-php-5-from-source-in-ubuntu-10/</link>
		<comments>http://www.moneypa.com/blog/20110706-common-errors-while-installing-php-5-from-source-in-ubuntu-10/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 05:28:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.moneypa.com/blog/?p=1392</guid>
		<description><![CDATA[If you try to install PHP 5.3.6 on Ubuntu by patching sources you will most likely see a lot of error messages similar to the following: $ ./configure cat: confdefs.h: No such file or directory ./configure: 490: ac_fn_c_try_run: not found ./configure: 490: 5: Bad file descriptor ./configure: 490: :: checking for pthreads_cflags: not found ./configure: [...]]]></description>
			<content:encoded><![CDATA[<p>If you try to install <a title="Posts tagged with PHP" rel="tag" href="http://sahilp.in/tag/php/">PHP</a> 5.3.6 on <a title="Posts tagged with Ubuntu" rel="tag" href="http://sahilp.in/tag/ubuntu/">Ubuntu</a> by patching sources you will most likely see a lot of error messages similar to the following:</p>
<div>
<div>$ ./configure<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
./configure: 490: 5: Bad file descriptor<br />
./configure: 490: :: checking for pthreads_cflags: not found<br />
./configure: 490: 6: Bad file descriptor<br />
./configure: 490: checking for pthreads_cflags&#8230; : not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 490: ac_fn_c_try_run: not found<br />
./configure: 492: 5: Bad file descriptor<br />
./configure: 492: :: result: : not found<br />
./configure: 492: 6: Bad file descriptor<br />
./configure: 492: : Permission denied<br />
./configure: 495: 5: Bad file descriptor<br />
./configure: 495: :: checking for pthreads_lib: not found<br />
./configure: 495: 6: Bad file descriptor<br />
./configure: 495: checking for pthreads_lib&#8230; : not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 555: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 555: ac_fn_c_try_run: not found<br />
cat: confdefs.h: No such file or directory<br />
./configure: 555: ac_fn_c_try_run: not found<br />
./configure: 557: 5: Bad file descriptor<br />
./configure: 557: :: result: : not found<br />
./configure: 557: 6: Bad file descriptor<br />
./configure: 557: : Permission denied<br />
./configure: 633: 5: Bad file descriptor<br />
./configure: 633: :: result: : not found<br />
./configure: 633: 6: Bad file descriptor<br />
./configure: 633: : Permission denied<br />
./configure: 635: 5: Bad file descriptor<br />
./configure: 635: :: result: Configuring SAPI modules: not found<br />
./configure: 635: 6: Bad file descriptor<br />
./configure: 635: Configuring SAPI modules: not found<br />
./configure: 666: 5: Bad file descriptor</div>
</div>
<p>See what happened when using <strong>buildconf</strong> earlier..</p>
<div><ins><ins id="aswift_1_anchor"></ins></ins></div>
<div>
<div>$ ./buildconf &#8211;force<br />
Forcing buildconf<br />
buildconf: checking installation&#8230;<br />
buildconf: autoconf version 2.64 (ok)<br />
buildconf: Your version of autoconf likely contains buggy cache code.<br />
Running vcsclean for you.<br />
To avoid this, install autoconf-2.13.<br />
Can&#8217;t figure out your VCS, not cleaning.</div>
</div>
<p>This is not a regular warning and it cannot be neglected. You have to  use autoconf-2.13. This is because the newer version of autoconf cannot  process scripts which are meant for autoconf 2.13. So just install  autoconf-2.13 and then do the compilation again..</p>
<div>
<div>sudo apt-get install autoconf2.13</div>
</div>
<p>Also if you have a low memory machine, then you might get error such as:</p>
<div>
<div>[lots of compile output]<br />
&#8230;<br />
/bin/sh /home/ibb_admin/temp/php-5.3.0/libtool &#8211;silent &#8211;preserve-dup-deps &#8211;mode=compile  gcc -I/home/ibb_admin/temp/php-5.3.0/ext/fileinfo/libmagic  -Iext/fileinfo/ -I/home/ibb_admin/temp/php-5.3.0/ext/fileinfo/  -DPHP_ATOM_INC -I/home/ibb_admin/temp/php-5.3.0/include  -I/home/ibb_admin/temp/php-5.3.0/main -I/home/ibb_admin/temp/php-5.3.0  -I/home/ibb_admin/temp/php-5.3.0/ext/date/lib  -I/home/ibb_admin/temp/php-5.3.0/ext/ereg/regex -I/usr/include/libxml2  -I/opt/include -I/opt/include/freetype2 -I/usr/include/imap  -I/usr/kerberos/include  -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/oniguruma  -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/libmbfl  -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/libmbfl/mbfl  -I/opt/include/mysql -I/usr/include/mysql  -I/home/ibb_admin/temp/php-5.3.0/ext/sqlite3/libsqlite  -I/home/ibb_admin/temp/php-5.3.0/TSRM  -I/home/ibb_admin/temp/php-5.3.0/Zend    -I/usr/include -g -O2  -c  /home/ibb_admin/temp/php-5.3.0/ext/fileinfo/libmagic/apprentice.c -o  ext/fileinfo/libmagic/apprentice.lo<br />
virtual memory exhausted: Cannot allocate memory<br />
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1</div>
</div>
<p>So just upgrade the <strong>gcc compiler</strong> to its latest version and also add <strong>–disable-fileinfo</strong> to ./configure</p>
<p>Hence full installation procedure would be similar to:</p>
<div>
<div>sudo apt-get install autoconf2.13<br />
wget http://us.php.net/get/php-5.3.6.tar.bz2/from/us.php.net/mirror<br />
tar -xjf php-5.3.6.tar.bz2<br />
cd php-5.3.6/<br />
./buildconf &#8211;force<br />
./configure &#8211;disable-fileinfo &#8211;enable-fpm &#8211;with-zlib &#8211;enable-pdo  &#8211;with-pdo-mysql &#8211;enable-sockets &#8211;with-mysql &#8211;enable-calendar  &#8211;with-iconv &#8211;enable-exif &#8211;enable-soap &#8211;enable-ftp &#8211;enable-wddx  &#8211;with-zlib &#8211;with-bz2 &#8211;with-gettext &#8211;with-xmlrpc &#8211;enable-pcntl  &#8211;enable-soap &#8211;enable-bcmath &#8211;enable-mbstring &#8211;enable-dba  &#8211;with-openssl &#8211;with-mhash &#8211;with-mcrypt &#8211;with-xsl &#8211;with-curl  &#8211;with-pcre-regex &#8211;with-gd &#8211;enable-gd-native-ttf &#8211;with-ldap  &#8211;enable-pdo &#8211;with-pdo-mysql &#8211;with-mysql &#8211;with-sqlite  &#8211;with-pdo-sqlite &#8211;enable-zip&#8211;enable-sqlite-utf8 &#8211;with-pear</div>
</div>
<p>Of course, your php configure options can be different.</p>
<p>﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20110706-common-errors-while-installing-php-5-from-source-in-ubuntu-10/feed/</wfw:commentRss>
		<slash:comments>60</slash:comments>
		</item>
		<item>
		<title>隐藏php头部版本输出 Hide PHP version (X-Powered-By)</title>
		<link>http://www.moneypa.com/blog/20110609-%e9%9a%90%e8%97%8fphp%e5%a4%b4%e9%83%a8%e7%89%88%e6%9c%ac%e8%be%93%e5%87%ba-hide-php-version-x-powered-by/</link>
		<comments>http://www.moneypa.com/blog/20110609-%e9%9a%90%e8%97%8fphp%e5%a4%b4%e9%83%a8%e7%89%88%e6%9c%ac%e8%be%93%e5%87%ba-hide-php-version-x-powered-by/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 00:49:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[X-Powered-By]]></category>

		<guid isPermaLink="false">http://www.moneypa.com/blog/?p=1383</guid>
		<description><![CDATA[php默认会输出header信息： Date: Tue, 15 Apr 2008 13:58:46 GMT Server: Apache/2.2.8 X-Powered-By: PHP/5.2.3 这样一下子php信息就全曝光了。怎样解决呢。 网上一搜中文，还真找不到相关信息。用英文一搜搜到了（下面是原文） If you have read my previous tip, “Hide apache software version“, you have seen how you can configure apache to provide only a minimal amount of information about the installed software versions in its banner. But if you are using the [...]]]></description>
			<content:encoded><![CDATA[<p>php默认会输出header信息：<br />
Date: Tue, 15 Apr 2008 13:58:46 GMT<br />
Server: Apache/2.2.8<br />
X-Powered-By: PHP/5.2.3<br />
这样一下子php信息就全曝光了。怎样解决呢。</p>
<p>网上一搜中文，还真找不到相关信息。用英文一搜搜到了（下面是原文）</p>
<p>If you have read my previous tip, “Hide apache software version“, you have seen how you can configure apache to provide only a minimal amount of information about the installed software versions in its banner. But if you are using the PHP module in your web server (as most of us are), then there is one additional step that need to be completed, and this is what I will show you in this tip.</p>
<p>After implementing the apache directives ServerTokens and ServerSignature as shown in “Hide apache software version“, we test its functionality against a regular html file and we get the following response:</p>
<p>HEAD http://remote_server.com/index.html<br />
200 OK<br />
Connection: close<br />
Date: Fri, 16 Jun 2006 01:13:23 GMT<br />
Server: Apache<br />
Content-Type: text/html; charset=UTF-8<br />
Client-Date: Fri, 16 Jun 2006 21:42:53 GMT<br />
Client-Peer: 192.168.0.102:80<br />
Client-Response-Num: 1</p>
<p>This looks good. But if we do the same thing against an URL that is a PHP file:</p>
<p>HEAD http://remote_server.com/index.php 200 OK Connection: close Date: Fri, 16 Jun 2006 01:16:30 GMT Server: Apache Content-Type: text/html; charset=UTF-8 Client-Date: Fri, 16 Jun 2006 21:48:13 GMT Client-Peer: 192.168.0.102:80 Client-Response-Num: 1 X-Powered-By: PHP/5.1.2-1+b1 </p>
<p>Ups… As we can see PHP adds its own banner:</p>
<p>X-Powered-By: PHP/5.1.2-1+b1…</p>
<p>Let’s see how we can disable it. In order to prevent PHP from exposing the fact that it is installed on the server, by adding its signature to the web server header we need to locate in php.ini the variable expose_php and turn it off.</p>
<p>By default expose_php is set to On.</p>
<p>In your php.ini (based on your Linux distribution this can be found in various places, like /etc/php.ini, /etc/php5/apache2/php.ini, etc.) locate the line containing “expose_php On” and set it to Off:</p>
<p>expose_php = Off</p>
<p>After making this change PHP will no longer add it’s signature to the web server header. Doing this, will not make your server more secure… it will just prevent remote hosts to easily see that you have PHP installed on the system and what version you are running.</p>
<p>结果简单的让人吃惊，只是需要修改php.ini 的 expose_php 把默认的 On改成 Off 就行了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20110609-%e9%9a%90%e8%97%8fphp%e5%a4%b4%e9%83%a8%e7%89%88%e6%9c%ac%e8%be%93%e5%87%ba-hide-php-version-x-powered-by/feed/</wfw:commentRss>
		<slash:comments>181</slash:comments>
		</item>
		<item>
		<title>zend_mm_heap corrupted Zend Memory Manager or segmentation faults</title>
		<link>http://www.moneypa.com/blog/20110512-zend_mm_heap-corrupted-zend-memory-manager-or-segmentation-faults/</link>
		<comments>http://www.moneypa.com/blog/20110512-zend_mm_heap-corrupted-zend-memory-manager-or-segmentation-faults/#comments</comments>
		<pubDate>Thu, 12 May 2011 00:38:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend_mm_heap corrupted]]></category>

		<guid isPermaLink="false">http://www.moneypa.com/blog/?p=1366</guid>
		<description><![CDATA[Problem: Get following prompt in command line while run a php application, &#8220;zend_mm_heap corrupted&#8221; Solution: A.while do complie for php, use the –enable-debug option B. Before run a php application, set following environment, USE_ZEND_ALLOC=0, however, it seems this only works for PHP CLI mode, doesn&#8217;t work for Apache Module, such as in php.ini or httpd.conf. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Get following prompt in command line while run a php application,</p>
<p>&#8220;zend_mm_heap corrupted&#8221;</p>
<p><strong>Solution:</strong></p>
<p>A.while do complie for php, use the –enable-debug option</p>
<p>B. Before run a php application, set following environment, USE_ZEND_ALLOC=0, however, it seems this only works for PHP CLI mode, doesn&#8217;t work for Apache Module, such as in php.ini or httpd.conf. There is an lucky scenarios for nginx, he fix the problem via: set the environment in bash_profile, and then restart the php-fpm</p>
<p><strong>Note: </strong></p>
<p>zend_mm means Zend Memory Manager</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20110512-zend_mm_heap-corrupted-zend-memory-manager-or-segmentation-faults/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php通过argc和argv变量获取命令行参数</title>
		<link>http://www.moneypa.com/blog/20101001-php%e9%80%9a%e8%bf%87argc%e5%92%8cargv%e5%8f%98%e9%87%8f%e8%8e%b7%e5%8f%96%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%8f%82%e6%95%b0/</link>
		<comments>http://www.moneypa.com/blog/20101001-php%e9%80%9a%e8%bf%87argc%e5%92%8cargv%e5%8f%98%e9%87%8f%e8%8e%b7%e5%8f%96%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%8f%82%e6%95%b0/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 09:41:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.moneypa.com/blog/?p=1350</guid>
		<description><![CDATA[   在 php 命令行中有两个参数 $argc 和 $argv 分别代表 参数的个数 和 全部参数组成的数组。 &#60;?php # testvar.php var_dump ($argc); var_dump ($argv) ?&#62;   php testvar.php 3gcomet int(2)    //这个表示有两个参数，下面的是列出全部参数，注意参数包括文件名 testvar.php array(2) {   [0]=&#62;   string(5) &#8220;testvar.php&#8221;   [1]=&#62;   string(7) &#8220;3gcomet&#8221; }]]></description>
			<content:encoded><![CDATA[<p>   在 php 命令行中有两个参数 $argc 和 $argv 分别代表 参数的个数 和 全部参数组成的数组。</p>
<p>&lt;?php</p>
<p># testvar.php<br />
var_dump ($argc);<br />
var_dump ($argv)<br />
?&gt;<br />
 </p>
<p>php testvar.php 3gcomet</p>
<p>int(2)    //这个表示有两个参数，下面的是列出全部参数，注意参数包括文件名 testvar.php<br />
array(2) {<br />
  [0]=&gt;<br />
  string(5) &#8220;testvar.php&#8221;<br />
  [1]=&gt;<br />
  string(7) &#8220;3gcomet&#8221;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20101001-php%e9%80%9a%e8%bf%87argc%e5%92%8cargv%e5%8f%98%e9%87%8f%e8%8e%b7%e5%8f%96%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%8f%82%e6%95%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To detect if php run from CLI</title>
		<link>http://www.moneypa.com/blog/20101001-to-detect-if-php-run-from-cli/</link>
		<comments>http://www.moneypa.com/blog/20101001-to-detect-if-php-run-from-cli/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 09:40:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.moneypa.com/blog/?p=1348</guid>
		<description><![CDATA[To detect if php run from CLI: if (defined(&#8216;STDIN&#8217;)) or: if (isset($argc))]]></description>
			<content:encoded><![CDATA[<p>To detect if php run from CLI:</p>
<p>if (defined(&#8216;STDIN&#8217;)) or: if (isset($argc))</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20101001-to-detect-if-php-run-from-cli/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; PEAR installation get warning: date(): It is not safe to rely on the system&#8217;s timezone settings.</title>
		<link>http://www.moneypa.com/blog/20100417-php-pear-installation-get-warning-date-it-is-not-safe-to-rely-on-the-systems-timezone-settings/</link>
		<comments>http://www.moneypa.com/blog/20100417-php-pear-installation-get-warning-date-it-is-not-safe-to-rely-on-the-systems-timezone-settings/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 07:43:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[warning: date(): it is not safe to rely on the system's timezone settings]]></category>

		<guid isPermaLink="false">/post/PHP-PEAR-installation-get-warning-date()-It-is-not-safe-to-rely-on-the-systems-timezone-settings.aspx</guid>
		<description><![CDATA[The Issue: While I am install the PEAR for PHP 5.3.2 version with display_errors settings on, I get following error, ===========================================================Warning: date(): It is not safe to rely on the system&#8217;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you [...]]]></description>
			<content:encoded><![CDATA[<h3>The Issue:</h3>
<p>While I am install the PEAR for PHP 5.3.2 version with display_errors settings on, I get following error,</p>
<p>===========================================================<br />Warning: date(): It is not safe to rely on the system&#8217;s timezone settings. You a<br />re *required* to use the date.timezone setting or the date_default_timezone_set(<br />) function. In case you used any of those methods and you are still getting this</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20100417-php-pear-installation-get-warning-date-it-is-not-safe-to-rely-on-the-systems-timezone-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to installing PHPUnit 3.4</title>
		<link>http://www.moneypa.com/blog/20100415-how-to-installing-phpunit-3-4/</link>
		<comments>http://www.moneypa.com/blog/20100415-how-to-installing-phpunit-3-4/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 21:04:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpunit]]></category>

		<guid isPermaLink="false">/post/How-to-installing-PHPUnit-34.aspx</guid>
		<description><![CDATA[PHPUnit 3.4 requires PHP 5.1.4 (or later) but PHP 5.3.2 (or later) is highly recommended. It should be installed using the PEAR Installer. This installer is the backbone of PEAR, which provides a distribution system for PHP packages, and is shipped with every release of PHP since version 4.3.0. The PEAR channel (pear.phpunit.de) that is [...]]]></description>
			<content:encoded><![CDATA[<p>PHPUnit 3.4 requires PHP 5.1.4 (or later) but PHP 5.3.2 (or later) is highly recommended. It should be installed using the <a class="ulink" href="http://pear.php.net/" target="_top">PEAR Installer</a>. This installer is the backbone of PEAR, which provides a distribution system for PHP packages, and is shipped with every release of PHP since version 4.3.0.</p>
<p>The PEAR channel (<code class="systemitem">pear.phpunit.de</code>) that is used to distribute PHPUnit needs to be registered with the local PEAR environment. Furthermore, a component that PHPUnit depends upon is hosted on the Symfony Components PEAR channel (<code class="systemitem">pear.symfony-project.com</code>).</p>
<pre class="screen"><strong class="userinput"><code>pear channel-discover pear.phpunit.de</code></strong></pre>
<pre class="screen"><strong class="userinput"><code>pear channel-discover pear.symfony-project.com</code></strong></pre>
<p>This has to be done only once. Now the PEAR Installer can be used to install packages from the PHPUnit channel:</p>
<pre class="screen"><strong class="userinput"><code>pear install phpunit/PHPUnit</code></strong></pre>
<p>After the installation you can find the PHPUnit source files inside your local PEAR directory; the path is usually <code class="filename">/usr/lib/php/PHPUnit</code>.</p>
<p>Although using the PEAR Installer is the only supported way to install PHPUnit, you can install PHPUnit manually. For manual installation, do the following:</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>Download a release archive from <code class="literal">http://pear.phpunit.de/get/</code> and extract it to a directory that is listed in the <code class="literal">include_path</code> of your <code class="filename">php.ini</code> configuration file.</p>
</li>
<li class="listitem">
<p>Prepare the <code class="filename">phpunit</code> script:</p>
<div class="orderedlist">
<ol class="orderedlist" type="a">
<li class="listitem">
<p>Rename the <code class="filename">phpunit.php</code> script to <code class="filename">phpunit</code>.</p>
</li>
<li class="listitem">
<p>Replace the <code class="literal">@php_bin@</code> string in it with the path to your PHP command-line interpreter (usually <code class="filename">/usr/bin/php</code>).</p>
</li>
<li class="listitem">
<p>Copy it to a directory that is in your path and make it executable (<code class="literal">chmod +x phpunit</code>).</p>
</li>
</ol>
</div>
</li>
<li class="listitem">
<p>Prepare the <code class="filename">PHPUnit/Util/PHP.php</code> script:</p>
<div class="orderedlist">
<ol class="orderedlist" type="a">
<li class="listitem">
<p>Replace the <code class="literal">@php_bin@</code> string in it with the path to your PHP command-line interpreter (usually <code class="filename">/usr/bin/php</code>).</p>
</li>
</ol>
</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20100415-how-to-installing-phpunit-3-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Install and Configure PHP 5 to Run with Apache on Windows</title>
		<link>http://www.moneypa.com/blog/20100415-how-to-install-and-configure-php-5-to-run-with-apache-on-windows/</link>
		<comments>http://www.moneypa.com/blog/20100415-how-to-install-and-configure-php-5-to-run-with-apache-on-windows/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 20:12:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">/post/How-to-Install-and-Configure-PHP-5-to-Run-with-Apache-on-Windows.aspx</guid>
		<description><![CDATA[How to Install and Configure PHP 5 to Run with Apache on Windows by Christopher Heng, thesitewizard.com Many web developers want to run Apache and PHP on their own computer since it allows them to easily test their scripts and programs before they put them &#8220;live&#8221; on the Internet. This article gives a step by [...]]]></description>
			<content:encoded><![CDATA[<h1>How to Install and Configure PHP 5 to Run with Apache on Windows</h1>
<p>by Christopher Heng, <a href="http://www.thesitewizard.com/" target="_top">thesitewizard.com</a></p>
<p>Many web developers want to run Apache and PHP on their own computer since it allows them to easily test their scripts and programs before they put them &#8220;live&#8221; on the Internet. This article gives a step by step guide on how you can install and configure PHP5 to work together with the Apache HTTP Server on Windows. The procedure has been tested to work on both Windows XP and Vista.</p>
<p>If you have not already installed Apache on your machine, check out one of the guides listed below. This &#8220;How To&#8221; guide assumes that you have already completed installing Apache.</p>
<ul>
<li>
<p>If you are using Apache 1.3.x, see the guide <a href="http://www.thesitewizard.com/archive/apache.shtml" target="_top">How to Install the Apache Web Server 1.x on Windows</a>.</p>
</li>
<li>
<p>If you plan to use one of the Apache 2 or 2.2 web servers on Windows XP, see the tutorial <a href="http://www.thesitewizard.com/apache/install-apache-2-windows.shtml" target="_top">How to Install and Configure Apache 2 on Windows</a> instead.</p>
</li>
<li>
<p>If you are using Apache 2.2 on Windows Vista, please read <a href="http://www.thesitewizard.com/apache/install-apache-on-vista.shtml" target="_top">How to Install Apache 2.2 on Windows Vista</a>.</p>
</li>
</ul>
<p>Note: those planning to install PHP 4 on Apache 1.x should read my article <a href="http://www.thesitewizard.com/archive/php4install.shtml" target="_top">How to Install and Configure PHP4 to Run with Apache on Windows</a> instead.</p>
<h2>Steps to Setting Up PHP 5</h2>
<ol>
<li>
<h3>Download PHP 5</h3>
<p>Before you begin, get a copy of PHP 5 from <a href="http://windows.php.net/download/">the PHP download page</a>. In particular, download the VC6 thread-safe zip package from the &#8220;Windows Binaries&#8221; section &mdash; that is, don&#8217;t get the installer. For example, select the package labelled &#8220;PHP 5.2.5 zip package&#8221; if 5.2.5 is the current version.</p>
<p>[Update: note that I have not tested the procedure below with any of the PHP 5.3 versions, only with 5.2.5, which was the latest version at the time I originally wrote this. In theory, the procedure should work with later 5.2 versions as well. I'm not sure about 5.3 though. A version jump from 5.2 to 5.3 usually means bigger changes than simple bug fixes. If you want to be sure the procedure below will work, just get the latest of the 5.2 series.]</p>
</li>
<li>
<h3>Install PHP 5</h3>
<p>Create a folder on your hard disk for PHP. I suggest &#8220;c:php&#8221; although you can use other names if you wish. Personally though, I prefer to avoid names with spaces in it, like &#8220;c:Program Filesphp&#8221; to avoid potential problems with programs that cannot handle such things. I will assume that you used c:php in this tutorial.</p>
<p>Extract all the files from the zip package into that folder. To do that simply double-click the zip file to open it, and drag all the files and folders to c:php.</p>
</li>
<li>
<h3>Upgraders: Remove the Old PHP.INI File from Your Windows Directory</h3>
<p>If you are upgrading to PHP 5 from an older version, go to your windows directory, typically c:windows, and delete any php.ini file that you have previously placed there.</p>
</li>
<li>
<h3>Configuring PHP</h3>
<p>Go to the c:php folder and make a copy of the file &#8220;php.ini-recommended&#8221;. Name the new file &#8220;php.ini&#8221;. That is, you should now have a file &#8220;c:phpphp.ini&#8221;, identical in content with &#8220;c:phpphp.ini-recommended&#8221;.</p>
<p>Note: if you are using Apache 1, you should either move the php.ini file to your windows directory, &#8220;C:Windows&#8221; on most systems, or configure your PATH environment variable to include &#8220;c:php&#8221;. If you don&#8217;t know how to do the latter, just move the php.ini file to the &#8220;c:windows&#8221; folder. You do not have to do this if you are using Apache 2, since we will include a directive later in the Apache 2 configuration file to specify the location of the php.ini file.</p>
<p>Use an <a href="http://www.thefreecountry.com/programming/editors.shtml" target="_top">ASCII text editor</a> (such as Notepad, which can be found in the Accessories folder of your Start menu) to open &#8220;php.ini&#8221;. You may need to make the following changes to the file, depending on your requirements:</p>
<ol class="content2">
<li>
<h3>Enable Short Open Tags</h3>
<p>Search for the line that reads:</p>
<div class="codeblock">short_open_tag = Off</div>
<p>If short_open_tag is set to &#8220;off&#8221;, tags like &#8220;<?" will not be recognised as the start tag for a PHP script. In such a case, to begin a PHP script, you will need to code your script with an opening tag like "<?php". Since many third party PHP scripts use "<?", setting this to "Off" will give you more problems than it's worth, particularly since most, if not all, <a href="http://www.thefreecountry.com/webhosting/budget1.shtml" target="_top">commercial web hosts</a> that support PHP have no issues with your scripts using &#8220;<?" as the open tag. To fix this, change it to the following:</p>
<div class="codeblock">short_open_tag = On</div>
</li>
<li>
<h3>Magic Quotes</h3>
<p>By default, input data is not escaped with backslashes. That is, if your visitors enter an inverted comma (single quote) into your web form, the script will receive that unadorned inverted comma (single quote). This is for the most part desirable unless you special requirements. If you want your input data to have the backslash (&#8220;&#8221;) prefix, such as, for example, to mimic your web host&#8217;s settings, search for the following:</p>
<div class="codeblock">magic_quotes_gpc = Off</div>
<p>and replace it with:</p>
<div class="codeblock">magic_quotes_gpc = On</div>
<p>Do not do this unless your web host has this setting as well. Even with the setting of &#8220;Off&#8221;, you can still use the addslashes() function in PHP to add the slashes for the specific pieces of data that need them.</p>
</li>
<li>
<h3>Register Globals</h3>
<p>A number of older scripts assume that all data sent by a form will automatically have a PHP variable of the same name. For example, if your form has an input field with a name of &#8220;something&#8221;, older PHP scripts assume that the PHP processor will automatically create a variable called $something that contains the value set in that field.</p>
<p>If you are running such scripts, you will need to look for the following field:</p>
<div class="codeblock">register_globals = Off</div>
<p>and change it to the following:</p>
<div class="codeblock">register_globals = On</div>
<p>WARNING: Do NOT do this unless you have third party scripts that need it. When writing new scripts, it&#8217;s best to always code with the assumption that the register_globals item is set to &#8220;Off&#8221;.</p>
</li>
<li>
<h3>Display Errors</h3>
<p>On a &#8220;live&#8221; website, you typically want errors in your script to be silently logged to a PHP error file. On your own local machine, however, while you are testing and debugging a PHP script, it is probably more convenient to have error messages sent to the browser window when they appear. This way, you won&#8217;t miss errors if you forget to check the error log file.</p>
<p>If you want PHP to display error messages in your browser window, look for the following:</p>
<div class="codeblock">display_errors = Off</div>
<p>And change it to:</p>
<div class="codeblock">display_errors = On</div>
<p>This value should always be set to &#8220;Off&#8221; for a &#8220;live&#8221; website.</p>
</li>
<li>
<h3>Session Path</h3>
<p>If your script uses <a href="http://www.thesitewizard.com/php/sessions.shtml" target="_top">sessions</a>, look for the following line:</p>
<div class="codeblock">;session.save_path = &#8220;/tmp&#8221;</div>
<p>The <code>session.save_path</code> sets the folder where PHP saves its session files. Since &#8220;/tmp&#8221; does not exist on Windows, you will need to set it to a directory that does. One way is to create a folder called (say) &#8220;c:tmp&#8221; (the way you created c:php earlier), and point this setting to that folder. If you do that, change the line to the following:</p>
<div class="codeblock">session.save_path = &#8220;c:tmp&#8221;</div>
<p>Notice that in addition to changing the path, I also removed the semi-colon (&#8220;;&#8221;) prefix from the line.</p>
<p>Alternatively, you can find out the current TEMP folder on your computer and use that. Or create a &#8220;tmp&#8221; folder in your PHP directory, like &#8220;c:phptmp&#8221; and set the configuration file accordingly. The possibilities are endless. If you can&#8217;t decide, just create &#8220;c:tmp&#8221; and do as I said above.</p>
</li>
<li>
<h3>SMTP Server</h3>
<p>If your script uses the mail() function, and you want the function to successfully send mail on your local machine, look for the following section:</p>
<div class="codeblock">[mail function]<br />; For Win32 only.<br />SMTP = localhost<br />smtp_port = 25</p>
<p>; For Win32 only.<br />;sendmail_from = me@example.com</div>
<p>Change it to point to your SMTP server and email account. For example, if your SMTP server is &#8220;mail.example.com&#8221; and your email address is &#8220;youremail@example.com&#8221;, change the code to:</p>
<div class="codeblock">[mail function]<br />SMTP = mail.example.com<br />smtp_port = 25<br />sendmail_from = youremail@example.com</div>
<p>Note that after you do this, when your script tries to use the mail() function, you will need to be connected to your ISP for the function to succeed. If you do not modify the above lines and attempt to use mail() in your script, the function will return a fail code, and display (or log) the error (depending on how you configure php.ini to handle errors).</p>
<p>(Note that in Apache 1.x, the smtp_port line may not be present. If so, don&#8217;t include it.)</p>
</li>
</ol>
</li>
</ol>
<h2>How to Configure Apache for PHP 5</h2>
<p>There are two ways to set up Apache to use PHP: the first is to configure it to load the PHP interpreter as an Apache module. The second is to configure it to run the interpreter as a CGI binary. I will supply information for how you can accomplish both, but you should only implement one of these methods. Choose the module method if your web host also installed PHP as an Apache module, and use the CGI method if they have implemented it to run as a CGI binary.</p>
<ol class="content2">
<li>
<h3>Running PHP 5 as an Apache Module</h3>
<p>To configure Apache to load PHP as a module to parse your PHP scripts, use an ASCII text editor to open the Apache configuration file, &#8220;httpd.conf&#8221;. If you use Apache 1.x, the file is found in &#8220;c:Program FilesApache GroupApacheconf&#8221;. Apache 2.0.x users can find it in &#8220;C:Program FilesApache GroupApache2conf&#8221; while Apache 2.2.x users can find it in &#8220;C:Program FilesApache Software FoundationApache2.2conf&#8221;. Basically, it&#8217;s in the &#8220;conf&#8221; folder of wherever you installed Apache.</p>
<p>Search for the section of the file that has a series of &#8220;LoadModule&#8221; statements. Statements prefixed by the hash &#8220;#&#8221; sign are regarded as having been commented out.</p>
<p>If you are using Apache 1.x, add the following line after all the LoadModule statements:</p>
<div class="codeblock">LoadModule php5_module &#8220;c:/php/php5apache.dll&#8221;</div>
<p>If you are using Apache 2.0.x, add the following line after all the LoadModule statements:</p>
<div class="codeblock">LoadModule php5_module &#8220;c:/php/php5apache2.dll&#8221;</div>
<p>If you are using Apache 2.2.x, add the following line instead:</p>
<div class="codeblock">LoadModule php5_module &#8220;c:/php/php5apache2_2.dll&#8221;</div>
<p>Note carefully the use of the forward slash character (&#8220;/&#8221;) instead of the traditional Windows backslash (&#8220;&#8221;). This is not a typographical error.</p>
<p>If you are using Apache 1.x, search for the series of &#8220;AddModule&#8221; statements, and add the following line after all of them. You do not have to do this in any of the Apache 2 series of web servers.</p>
<div class="codeblock">AddModule mod_php5.c</div>
<p>Next, search for &#8220;AddType&#8221; in the file, and add the following line after the last &#8220;AddType&#8221; statement. Do this no matter which version of Apache you are using. For Apache 2.2.x, you can find the &#8220;AddType&#8221; lines in the <IfModule mime_module> section. Add the line just before the closing </IfModule> for that section.</p>
<div class="codeblock">AddType application/x-httpd-php .php</div>
<p>If you need to support other file types, like &#8220;.phtml&#8221;, simply add them to the list, like this:</p>
<div class="codeblock">AddType application/x-httpd-php .phtml</div>
<p>Finally, for those using one of the Apache 2 versions, you will need to indicate the location of your PHP ini file. Add the following line to the end of your httpd.conf file.</p>
<div class="codeblock">PHPIniDir &#8220;c:/php&#8221;</div>
<p>Of course if you used a different directory for your PHP installation, you will need to change &#8220;c:/php&#8221; to that path. Remember to use the forward slash (&#8220;/&#8221;) here again.</p>
<p>If you are using Apache 1, you will have already placed your php.ini file in either the Windows directory or somewhere in your PATH, so PHP should be able to find it by itself. You can of course do the same if you are using Apache 2, but I find modifying the Apache configuration file a better solution than cluttering your c:windows directory or your PATH variable.</p>
</li>
<li>
<h3>Running PHP 5 as a CGI Binary</h3>
<p>If you have configured PHP 5 to run as an Apache module, skip forward to the next section. This section is for those who want to configure PHP to run as a CGI binary.</p>
<p>The procedure is the same whether you are using the Apache 1.x series or one of the 2.x series.</p>
<p>Search for the portion of your Apache configuration file which has the ScriptAlias section. Add the line from the box below immediately after the ScriptAlias line for &#8220;cgi-bin&#8221;. If you use Apache 2.2.x, make sure that the line goes before the closing </IfModule> for that <IfModule alias_module> section.</p>
<p>Note that if you installed PHP elsewhere, such as &#8220;c:Program Filesphp&#8221;, you should substitute the appropriate path in place of &#8220;c:/php/&#8221; (for example, &#8220;c:/Program Files/php/&#8221;). Observe carefully that I used forward slashes (&#8220;/&#8221;) instead of the usual Windows backslashes (&#8220;&#8221;) below. You will need to do the same.</p>
<div class="codeblock">ScriptAlias /php/ &#8220;c:/php/&#8221;</div>
<p>Apache needs to be configured for the PHP MIME type. Search for the &#8220;AddType&#8221; comment block explaining its use, and add the AddType line in the box below after it. For Apache 2.2.x, you can find the AddType lines in the <IfModule mime_module> section. Add the following line just before the closing </IfModule> for that section.</p>
<div class="codeblock">AddType application/x-httpd-php .php</div>
<p>As in the case of running PHP as an Apache module, you can add whatever extensions you want Apache to recognise as PHP scripts, such as:</p>
<div class="codeblock">AddType application/x-httpd-php .phtml</div>
<p>Next, you will need to tell the server to execute the PHP executable each time it encounters a PHP script. Add the following somewhere in the file, such as after the comment block explaining &#8220;Action&#8221;. If you use Apache 2.2.x, you can simply add it immediately after your &#8220;AddType&#8221; statement above; there&#8217;s no &#8220;Action&#8221; comment block in Apache 2.2.x.</p>
<div class="codeblock">Action application/x-httpd-php &#8220;/php/php-cgi.exe&#8221;</div>
<p>Note: the &#8220;/php/&#8221; portion will be recognised as a ScriptAlias, a sort of macro which will be expanded to &#8220;c:/php/&#8221; (or &#8220;c:/Program Files/php/&#8221; if you installed PHP there) by Apache. In other words, don&#8217;t put &#8220;c:/php/php.exe&#8221; or &#8220;c:/Program Files/php/php.exe&#8221; in that directive, put &#8220;/php/php-cgi.exe&#8221;.</p>
<p>If you are using Apache 2.2.x, look for the following section in the httpd.conf file:</p>
<div class="codeblock"><Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin"><br />AllowOverride None<br />Options None<br />Order allow,deny<br />Allow from all<br /></Directory></div>
<p>Add the following lines immediately after the section you just found.</p>
<div class="codeblock"><Directory "C:/php"><br />AllowOverride None<br />Options None<br />Order allow,deny<br />Allow from all<br /></Directory></div>
</li>
<li>
<h3>Configuring the Default Index Page</h3>
<p>This section applies to all users, whether you are using PHP as a module or as a CGI binary.</p>
<p>If you create a file index.php, and want Apache to load it as the directory index page for your website, you will have to add another line to the &#8220;httpd.conf&#8221; file. To do this, look for the line in the file that begins with &#8220;DirectoryIndex&#8221; and add &#8220;index.php&#8221; to the list of files on that line. For example, if the line used to be:</p>
<div class="codeblock">DirectoryIndex index.html</div>
<p>change it to:</p>
<div class="codeblock">DirectoryIndex index.php index.html</div>
<p>The next time you access your web server with just a directory name, like &#8220;localhost&#8221; or &#8220;localhost/directory/&#8221;, Apache will send whatever your index.php script outputs, or if index.php is not available, the contents of index.html.</p>
</li>
</ol>
<h2>Restart the Apache Web Server</h2>
<p>Restart your Apache server. This is needed because Apache needs to read the new configuration directives for PHP that you have placed into the httpd.conf file. The Apache 2.2 server can be restarted by doubleclicking the Apache Service Monitor system tray icon, and when the window appears, clicking the &#8220;Restart&#8221; button.</p>
<h2>Testing Your PHP Installation</h2>
<p>Create a PHP file with the following line:</p>
<div class="codeblock"><?php phpinfo(); ?></div>
<p>Save the file as &#8220;test.php&#8221; or any other name that you fancy, but with the &#8220;.php&#8221; extension, into your Apache htdocs directory. If you are using Notepad, remember to save as &#8220;test.php&#8221; <strong>with the quotes</strong>, or the software will add a &#8220;.txt&#8221; extension behind your back.</p>
<p>Open your browser and access the file by typing &#8220;localhost/test.php&#8221; into your browser&#8217;s address bar. Do not open the file directly on the hard disk &#8211; you&#8217;ll only see the words you typed in earlier. You need to use the above URL so that the browser will try to access your Apache web server, which in turn runs PHP to interpret your script.</p>
<p>If all goes well, you should see a pageful of information about your PHP setup. Congratulations &#8211; you have successfully installed PHP and configured Apache to work with it. You can upload this same file, test.php, to your web host and run it there to see how your web host has set up his PHP, so that you can mimic it on your own machine.</p>
<p>If for some reason it does not work, check to see whether your PHP setup or your Apache setup is causing the problem. To do this, open a Command Prompt window (found in the &#8220;Accessories&#8221; folder of your &#8220;Start&#8221; menu) and run php-cgi.exe on test.php with a command line like &#8220;<kbd>c:phpphp-cgi test.php</kbd>&#8221; (without the quotes).</p>
<p>If invoking PHP from the command line causes a large HTML file with all the PHP configuration information to be displayed, then your PHP set up is fine. The problem probably lies with your Apache configuration. Make sure that you have restarted the Apache server after making configuration changes. Verify that you have configured Apache correctly by looking over, again, the instructions on this page and the steps given in <a href="http://www.thesitewizard.com/archive/apache.shtml" target="_top">How to Install and Configure Apache 1.x for Windows</a> (for Apache 1.x users) or <a href="http://www.thesitewizard.com/apache/install-apache-2-windows.shtml" target="_top">How to Install and Configure Apache 2 on Windows</a> (for Apache 2.x users).</p>
<h2>Learning PHP</h2>
<p>The complete PHP reference manual can be obtained from the php website. You can refer to it online or download the entire set of HTML files for reference offline. As its name implies, it is a reference manual only. For tutorials, check out <a href="http://www.thesitewizard.com/php/index.shtml" target="_top">the PHP tutorials</a> at thesitewizard.com. If you are new to writing PHP scripts, the following chapters may interest you:</p>
<ul>
<li><a href="http://www.thesitewizard.com/archive/feedbackphp.shtml" target="_top">Writing Your First PHP Script</a> gets you on your feet quickly with writing a useful and functional PHP script. </li>
<li><a href="http://www.thesitewizard.com/archive/phptutorial2.shtml" target="_top">Form Validation, Disabling Browser Caching, Embedding HTML Code in PHP</a> introduces more features of PHP in a practical, usable way. </li>
<li><a href="http://www.thesitewizard.com/php/protect-script-from-email-injection.shtml" target="_top">How to Prevent Email Injection in Your PHP Form-to-Mail Scripts</a> deals with how to avoid a security hole in PHP scripts that use the mail() function. </li>
</ul>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20100415-how-to-install-and-configure-php-5-to-run-with-apache-on-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What is LAMP and Why LAMP</title>
		<link>http://www.moneypa.com/blog/20100307-what-is-lamp-and-why-lamp/</link>
		<comments>http://www.moneypa.com/blog/20100307-what-is-lamp-and-why-lamp/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 20:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lamp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">/post/What-is-LAMP-and-Why-LAMP.aspx</guid>
		<description><![CDATA[Why LAMP LAMP can significantly reduce or eliminate traditional IT costs for hardware acquisition and software license and applications maintenance costs. Very little infrastructure is required; LAMP is accessed through the internet from any web browser or web-enabled phone. As a service subscriber rather than software licensee, costly software upgrades that are generally required by [...]]]></description>
			<content:encoded><![CDATA[<p>Why LAMP</p>
<p>LAMP can significantly reduce or eliminate traditional IT costs for hardware acquisition and software license and applications maintenance costs. Very little infrastructure is required; LAMP is accessed through the internet from any web browser or web-enabled phone. As a service subscriber rather than software licensee, costly software upgrades that are generally required by the traditional ERP vendors every 2 to 3 years, are eliminated. There are no business disruptions during the no-cost LAMP upgrades. Subscribers can realize significant savings from LAMP. First time ERP clients avoid costly software and implementation costs, both initially and recurring, and can realize full benefits from an accelerated installation without having any infrastructure other than access to the internet from a web browser. Traditional legacy ERP customers can realize significant cost savings by reducing infrastructure, licenses, maintenance and application support within 12 months of implementation, an ROI that can be measured in months, not years. No ongoing expensive consulting and systems integration support is required. IMPART provides configuration and conversion on a fixed fee basis. IMPART doesn&#8217;t leave those other consulting, partners, behind that seemingly never goes away.</p>
<p>History and Pedigree</p>
<p>LAMP is among a select few enterprise software products developed entirely with open source software and protocols, resulting in lower costs to IMPART and customers alike. Built from the ground-up for SaaS delivery with multi-tenant (MT) architecture &#8211; it is not a rewrite or revamp of a single tenant (ST) system. LAMP has over 100 man-years of development during its five years of development effort to-date. Our software and services are built on over 30 years of experience in software design, development and delivery. The MT architecture allows IMPART to achieve an improved cost structure while maximizing the value to our customers by including improved and new business logic through rapid deployment of LAMP upgrades to the entire user base without upgrade cost or business interruption.</p>
<p>L A M P <br />The acronym LAMP refers to a solution stack of software programs, commonly free software programs, used together to run dynamic Web sites or servers:</p>
<p>Linux, (referring to OS kernel) <br />Apache, the Web server <br />MySQL, the database management system (or database server) <br />PHP (Sometimes Perl or Python), the programming language<br />L A M P Advantages<br />A Culture of Cooperation<br />The open source community and its culture of knowledge- and resource-sharing accelerates problem-solving. Community knowledgebases and libraries of sample application code help compress development time by enabling convenient reuse and adaptation.</p>
<p>Low Overhead<br />The compact LAMP component stack simplifies deployment and reduces processing overhead. Very tight integration between PHP and Apache, for instance, eliminates the need for application server software and in many instances eliminates an entire physical server tier.<br />Platform Portability<br />Because LAMP runs on a wide range of hardware platforms, users have maximum flexibility in deployment and server infrastructure design decisions. Of particular value is the option to deploy on clusters or grids of affordable x86-based servers. These utility computing architectures provide an optimized combination of efficient resource utilization, high availability, versatility and instant scalability.</p>
<p>Security and Stability<br />The LAMP server stack has a lower bug density &mdash; the number of bugs per thousand lines of code &mdash; than a baseline of 32 open source projects analyzed, according to a 2006 study by Coverity, a maker of code &mdash; analysis tools.</p>
<p>Over the years Saturn has developed standards, frameworks and reusable components for LAMP development. This helps Saturn to deliver economic and efficient solutions based on the LAMP stack.</p>
<p>
]]></content:encoded>
			<wfw:commentRss>http://www.moneypa.com/blog/20100307-what-is-lamp-and-why-lamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

