<?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>ServerAdminBlog &#187; PHP</title>
	<atom:link href="http://www.serveradminblog.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.serveradminblog.com</link>
	<description>Short Circuit...</description>
	<lastBuildDate>Sat, 04 Feb 2012 16:56:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>UTF-8 with MySQL and PDO</title>
		<link>http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/</link>
		<comments>http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 08:51:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=365</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/' addthis:title='UTF-8 with MySQL and PDO '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you are using PDO (PHP Data Objects) and you&#8217;re having problems with utf-8, try to add PDO::MYSQL_ATTR_INIT_COMMAND option inside PDO definition like I wrote below. $db = new PDO&#40; 'mysql:host=example.com;dbname=dbName', &#34;username&#34;, &#34;password&#34;, array&#40;PDO::MYSQL_ATTR_INIT_COMMAND =&#62; &#34;SET NAMES utf8&#34;&#41;&#41;;]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/' addthis:title='UTF-8 with MySQL and PDO '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>If you are using PDO (PHP Data Objects) and you&#8217;re having problems with utf-8, try to add PDO::MYSQL_ATTR_INIT_COMMAND option inside PDO definition like I wrote below.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PDO<span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'mysql:host=example.com;dbname=dbName'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>PDO<span style="color: #339933;">::</span><span style="color: #004000;">MYSQL_ATTR_INIT_COMMAND</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;SET NAMES utf8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/10/utf-8-with-mysql-and-pdo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detect mobile browser (smartphone)</title>
		<link>http://www.serveradminblog.com/2011/01/detect-mobile-browser-smartphone/</link>
		<comments>http://www.serveradminblog.com/2011/01/detect-mobile-browser-smartphone/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 23:41:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=242</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/01/detect-mobile-browser-smartphone/' addthis:title='Detect mobile browser (smartphone) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Detecting mobile browsers is very easy when you know the right regular expression. Here are two examples (for PHP and JSP) PHP &#60;?php $useragent = $_SERVER&#91;'HTTP_USER_AGENT'&#93;; if &#40;preg_match&#40;'/android&#124;avantgo&#124;blackberry&#124;blazer&#124;compal&#124;elaine&#124;fennec&#124;hiptop&#124;iemobile&#124;ip(hone&#124;od)&#124;iris&#124;kindle&#124;lge &#124;maemo&#124;midp&#124;mmp&#124;opera m(ob&#124;in)i&#124;palm( os)?&#124;phone&#124;p(ixi&#124;re)\/&#124;plucker&#124;pocket&#124;psp&#124;symbian&#124;treo&#124;up\.(browser&#124;link)&#124;vodafone&#124;wap&#124;windows (ce&#124;phone)&#124;xda&#124;xiino/i',$useragent&#41;&#124;&#124;preg_match&#40;'/1207&#124;6310&#124;6590&#124;3gso&#124;4thp&#124;50[1-6]i&#124;770s&#124;802s&#124;a wa&#124;abac&#124;ac(er&#124;oo&#124;s\-)&#124;ai(ko&#124;rn)&#124;al(av&#124;ca&#124;co)&#124;amoi&#124;an(ex&#124;ny&#124;yw)&#124;aptu&#124;ar(ch&#124;go)&#124;as(te&#124;us)&#124;attw&#124;au(di&#124;\-m&#124;r &#124;s )&#124;avan&#124;be(ck&#124;ll&#124;nq)&#124;bi(lb&#124;rd)&#124;bl(ac&#124;az)&#124;br(e&#124;v)w&#124;bumb&#124;bw\-(n&#124;u)&#124;c55\/&#124;capi&#124;ccwa&#124;cdm\-&#124;cell&#124;chtm&#124;cldc&#124;cmd\-&#124;co(mp&#124;nd)&#124;craw&#124;da(it&#124;ll&#124;ng)&#124;dbte&#124;dc\-s&#124;devi&#124;dica&#124;dmob&#124;do(c&#124;p)o&#124;ds(12&#124;\-d)&#124;el(49&#124;ai)&#124;em(l2&#124;ul)&#124;er(ic&#124;k0)&#124;esl8&#124;ez([4-7]0&#124;os&#124;wa&#124;ze)&#124;fetc&#124;fly(\-&#124;_)&#124;g1 u&#124;g560&#124;gene&#124;gf\-5&#124;g\-mo&#124;go(\.w&#124;od)&#124;gr(ad&#124;un)&#124;haie&#124;hcit&#124;hd\-(m&#124;p&#124;t)&#124;hei\-&#124;hi(pt&#124;ta)&#124;hp( i&#124;ip)&#124;hs\-c&#124;ht(c(\-&#124; &#124;_&#124;a&#124;g&#124;p&#124;s&#124;t)&#124;tp)&#124;hu(aw&#124;tc)&#124;i\-(20&#124;go&#124;ma)&#124;i230&#124;iac( &#124;\-&#124;\/)&#124;ibro&#124;idea&#124;ig01&#124;ikom&#124;im1k&#124;inno&#124;ipaq&#124;iris&#124;ja(t&#124;v)a&#124;jbro&#124;jemu&#124;jigs&#124;kddi&#124;keji&#124;kgt( &#124;\/)&#124;klon&#124;kpt &#124;kwc\-&#124;kyo(c&#124;k)&#124;le(no&#124;xi)&#124;lg( g&#124;\/(k&#124;l&#124;u)&#124;50&#124;54&#124;e\-&#124;e\/&#124;\-[a-w])&#124;libw&#124;lynx&#124;m1\-w&#124;m3ga&#124;m50\/&#124;ma(te&#124;ui&#124;xo)&#124;mc(01&#124;21&#124;ca)&#124;m\-cr&#124;me(di&#124;rc&#124;ri)&#124;mi(o8&#124;oa&#124;ts)&#124;mmef&#124;mo(01&#124;02&#124;bi&#124;de&#124;do&#124;t(\-&#124; &#124;o&#124;v)&#124;zz)&#124;mt(50&#124;p1&#124;v )&#124;mwbp&#124;mywa&#124;n10[0-2]&#124;n20[2-3]&#124;n30(0&#124;2)&#124;n50(0&#124;2&#124;5)&#124;n7(0(0&#124;1)&#124;10)&#124;ne((c&#124;m)\-&#124;on&#124;tf&#124;wf&#124;wg&#124;wt)&#124;nok(6&#124;i)&#124;nzph&#124;o2im&#124;op(ti&#124;wv)&#124;oran&#124;owg1&#124;p800&#124;pan(a&#124;d&#124;t)&#124;pdxg&#124;pg(13&#124;\-([1-8]&#124;c))&#124;phil&#124;pire&#124;pl(ay&#124;uc)&#124;pn\-2&#124;po(ck&#124;rt&#124;se)&#124;prox&#124;psio&#124;pt\-g&#124;qa\-a&#124;qc(07&#124;12&#124;21&#124;32&#124;60&#124;\-[2-7]&#124;i\-)&#124;qtek&#124;r380&#124;r600&#124;raks&#124;rim9&#124;ro(ve&#124;zo)&#124;s55\/&#124;sa(ge&#124;ma&#124;mm&#124;ms&#124;ny&#124;va)&#124;sc(01&#124;h\-&#124;oo&#124;p\-)&#124;sdk\/&#124;se(c(\-&#124;0&#124;1)&#124;47&#124;mc&#124;nd&#124;ri)&#124;sgh\-&#124;shar&#124;sie(\-&#124;m)&#124;sk\-0&#124;sl(45&#124;id)&#124;sm(al&#124;ar&#124;b3&#124;it&#124;t5)&#124;so(ft&#124;ny)&#124;sp(01&#124;h\-&#124;v\-&#124;v )&#124;sy(01&#124;mb)&#124;t2(18&#124;50)&#124;t6(00&#124;10&#124;18)&#124;ta(gt&#124;lk)&#124;tcl\-&#124;tdg\-&#124;tel(i&#124;m)&#124;tim\-&#124;t\-mo&#124;to(pl&#124;sh)&#124;ts(70&#124;m\-&#124;m3&#124;m5)&#124;tx\-9&#124;up(\.b&#124;g1&#124;si)&#124;utst&#124;v400&#124;v750&#124;veri&#124;vi(rg&#124;te)&#124;vk(40&#124;5[0-3]&#124;\-v)&#124;vm40&#124;voda&#124;vulc&#124;vx(52&#124;53&#124;60&#124;61&#124;70&#124;80&#124;81&#124;83&#124;85&#124;98)&#124;w3c(\-&#124; )&#124;webc&#124;whit&#124;wi(g &#124;nc&#124;nw)&#124;wmlb&#124;wonu&#124;x700&#124;xda(\-&#124;2&#124;g)&#124;yas\-&#124;your&#124;zeto&#124;zte\-/i',substr&#40;$useragent,0,4&#41;&#41;&#41; &#160; header&#40;'Location: http://mysite.com/mobile_version'&#41;; ?&#62; JAVA (JSP) &#60;% String [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/01/detect-mobile-browser-smartphone/' addthis:title='Detect mobile browser (smartphone) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Detecting mobile browsers is very easy when you know the right regular expression. </p>
<p>Here are two examples (for PHP and JSP)</p>
<p>PHP</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$useragent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$useragent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span>preg_match<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i'</span><span style="color: #339933;">,</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$useragent</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: http://mysite.com/mobile_version'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>JAVA (JSP)</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>
<span style="color: #003399;">String</span> ua<span style="color: #339933;">=</span>request.<span style="color: #006633;">getHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;User-Agent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ua.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.*(android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)<span style="color: #000099; font-weight: bold;">\\</span>/|plucker|pocket|psp|symbian|treo|up<span style="color: #000099; font-weight: bold;">\\</span>.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino).*&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span>ua.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s<span style="color: #000099; font-weight: bold;">\\</span>-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|<span style="color: #000099; font-weight: bold;">\\</span>-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw<span style="color: #000099; font-weight: bold;">\\</span>-(n|u)|c55<span style="color: #000099; font-weight: bold;">\\</span>/|capi|ccwa|cdm<span style="color: #000099; font-weight: bold;">\\</span>-|cell|chtm|cldc|cmd<span style="color: #000099; font-weight: bold;">\\</span>-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc<span style="color: #000099; font-weight: bold;">\\</span>-s|devi|dica|dmob|do(c|p)o|ds(12|<span style="color: #000099; font-weight: bold;">\\</span>-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(<span style="color: #000099; font-weight: bold;">\\</span>-|_)|g1 u|g560|gene|gf<span style="color: #000099; font-weight: bold;">\\</span>-5|g<span style="color: #000099; font-weight: bold;">\\</span>-mo|go(<span style="color: #000099; font-weight: bold;">\\</span>.w|od)|gr(ad|un)|haie|hcit|hd<span style="color: #000099; font-weight: bold;">\\</span>-(m|p|t)|hei<span style="color: #000099; font-weight: bold;">\\</span>-|hi(pt|ta)|hp( i|ip)|hs<span style="color: #000099; font-weight: bold;">\\</span>-c|ht(c(<span style="color: #000099; font-weight: bold;">\\</span>-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i<span style="color: #000099; font-weight: bold;">\\</span>-(20|go|ma)|i230|iac( |<span style="color: #000099; font-weight: bold;">\\</span>-|<span style="color: #000099; font-weight: bold;">\\</span>/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |<span style="color: #000099; font-weight: bold;">\\</span>/)|klon|kpt |kwc<span style="color: #000099; font-weight: bold;">\\</span>-|kyo(c|k)|le(no|xi)|lg( g|<span style="color: #000099; font-weight: bold;">\\</span>/(k|l|u)|50|54|e<span style="color: #000099; font-weight: bold;">\\</span>-|e<span style="color: #000099; font-weight: bold;">\\</span>/|<span style="color: #000099; font-weight: bold;">\\</span>-[a-w])|libw|lynx|m1<span style="color: #000099; font-weight: bold;">\\</span>-w|m3ga|m50<span style="color: #000099; font-weight: bold;">\\</span>/|ma(te|ui|xo)|mc(01|21|ca)|m<span style="color: #000099; font-weight: bold;">\\</span>-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(<span style="color: #000099; font-weight: bold;">\\</span>-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)<span style="color: #000099; font-weight: bold;">\\</span>-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|<span style="color: #000099; font-weight: bold;">\\</span>-([1-8]|c))|phil|pire|pl(ay|uc)|pn<span style="color: #000099; font-weight: bold;">\\</span>-2|po(ck|rt|se)|prox|psio|pt<span style="color: #000099; font-weight: bold;">\\</span>-g|qa<span style="color: #000099; font-weight: bold;">\\</span>-a|qc(07|12|21|32|60|<span style="color: #000099; font-weight: bold;">\\</span>-[2-7]|i<span style="color: #000099; font-weight: bold;">\\</span>-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55<span style="color: #000099; font-weight: bold;">\\</span>/|sa(ge|ma|mm|ms|ny|va)|sc(01|h<span style="color: #000099; font-weight: bold;">\\</span>-|oo|p<span style="color: #000099; font-weight: bold;">\\</span>-)|sdk<span style="color: #000099; font-weight: bold;">\\</span>/|se(c(<span style="color: #000099; font-weight: bold;">\\</span>-|0|1)|47|mc|nd|ri)|sgh<span style="color: #000099; font-weight: bold;">\\</span>-|shar|sie(<span style="color: #000099; font-weight: bold;">\\</span>-|m)|sk<span style="color: #000099; font-weight: bold;">\\</span>-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h<span style="color: #000099; font-weight: bold;">\\</span>-|v<span style="color: #000099; font-weight: bold;">\\</span>-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl<span style="color: #000099; font-weight: bold;">\\</span>-|tdg<span style="color: #000099; font-weight: bold;">\\</span>-|tel(i|m)|tim<span style="color: #000099; font-weight: bold;">\\</span>-|t<span style="color: #000099; font-weight: bold;">\\</span>-mo|to(pl|sh)|ts(70|m<span style="color: #000099; font-weight: bold;">\\</span>-|m3|m5)|tx<span style="color: #000099; font-weight: bold;">\\</span>-9|up(<span style="color: #000099; font-weight: bold;">\\</span>.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|<span style="color: #000099; font-weight: bold;">\\</span>-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(<span style="color: #000099; font-weight: bold;">\\</span>-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(<span style="color: #000099; font-weight: bold;">\\</span>-|2|g)|yas<span style="color: #000099; font-weight: bold;">\\</span>-|your|zeto|zte<span style="color: #000099; font-weight: bold;">\\</span>-&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
&nbsp;
response.<span style="color: #006633;">sendRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://mysite.com/mobile_version&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">%&gt;</span></pre></div></div>

<p>More info <a href="http://detectmobilebrowser.com/" target="_blank">HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/01/detect-mobile-browser-smartphone/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Detect visitor IP address with PHP</title>
		<link>http://www.serveradminblog.com/2011/01/detect-visitor-ip-address-with-php/</link>
		<comments>http://www.serveradminblog.com/2011/01/detect-visitor-ip-address-with-php/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 21:27:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=233</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/01/detect-visitor-ip-address-with-php/' addthis:title='Detect visitor IP address with PHP '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Two post in 2 days&#8230; Here is a small PHP function to detect remote IP address (visitor IP address). This should work even if the client/visitor is behind a proxy function getIPAddress&#40;&#41; &#123; if &#40;!empty&#40;$_SERVER&#91;'HTTP_CLIENT_IP'&#93;&#41;&#41; &#123; $ip = $_SERVER&#91;'HTTP_CLIENT_IP'&#93;; &#125; elseif &#40;!empty&#40;$_SERVER&#91;'HTTP_X_FORWARDED_FOR'&#93;&#41;&#41; &#123; $ip = $_SERVER&#91;'HTTP_X_FORWARDED_FOR'&#93;; &#125; else &#123; $ip = $_SERVER&#91;'REMOTE_ADDR'&#93;; &#125; return $ip; [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/01/detect-visitor-ip-address-with-php/' addthis:title='Detect visitor IP address with PHP '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Two post in 2 days&#8230; <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>Here is a small PHP function to detect remote IP address (visitor IP address). This should work even if the client/visitor is behind a proxy</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getIPAddress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_CLIENT_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_CLIENT_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> getIPAddress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">;</span></pre></div></div>

<p>There is not much to talk about. As you can see, the $ip variable is detected IP address. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/01/detect-visitor-ip-address-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading PHP and MySQL on CentOS or RHEL</title>
		<link>http://www.serveradminblog.com/2010/09/upgrading-php-and-mysql-on-centos-fedora-or-rhel/</link>
		<comments>http://www.serveradminblog.com/2010/09/upgrading-php-and-mysql-on-centos-fedora-or-rhel/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 08:35:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=159</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/09/upgrading-php-and-mysql-on-centos-fedora-or-rhel/' addthis:title='Upgrading PHP and MySQL on CentOS or RHEL '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>I already wrote about upgrading via Jason Litka repo on this PAGE but in case you have problems with this repo, you can add Remi Collet repo. First, import Remi GPG key with #rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi # cd /etc/yum.repos.d # wget http://rpms.famillecollet.com/enterprise/remi.repo This file provides configuration for remi and remi-test repositories. Keep in mind that [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/09/upgrading-php-and-mysql-on-centos-fedora-or-rhel/' addthis:title='Upgrading PHP and MySQL on CentOS or RHEL '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I already wrote about upgrading via Jason Litka repo on this <a href="http://www.serveradminblog.com/2009/04/upgrading-to-php-525-on-rhel-and-centos/">PAGE</a> but in case you have problems with this repo, you can add Remi Collet repo. </p>
<p>First, import Remi GPG key with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># cd /etc/yum.repos.d
# wget http://rpms.famillecollet.com/enterprise/remi.repo</pre></div></div>

<p>This file provides configuration for remi and remi-test repositories. Keep in mind that Remi repo is disabled by default so you can add &#8211;enablerepo=remi to yum command or you can edit line enabled=0 to enabled=1 inside remo.repo. For production servers I don&#8217;t recommend enabled=1 to remi-test repo.  </p>
<p>Current PHP is 5.3.3 and MySQL 5.1.50</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/09/upgrading-php-and-mysql-on-centos-fedora-or-rhel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP redirect</title>
		<link>http://www.serveradminblog.com/2010/09/php-redirect/</link>
		<comments>http://www.serveradminblog.com/2010/09/php-redirect/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 10:28:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=155</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/09/php-redirect/' addthis:title='PHP redirect '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>It is not hard to remember but here it is&#8230; This code can be used to redirect visitors to any other page. header&#40;&#34;Location: http://www.blabla.com/page.php&#34;&#41;;]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/09/php-redirect/' addthis:title='PHP redirect '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>It is not hard to remember but here it is&#8230; This code can be used to redirect visitors to any other page.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: http://www.blabla.com/page.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/09/php-redirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP error reporting</title>
		<link>http://www.serveradminblog.com/2010/09/php-error-reporting/</link>
		<comments>http://www.serveradminblog.com/2010/09/php-error-reporting/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 10:14:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=150</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/09/php-error-reporting/' addthis:title='PHP error reporting '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Error reporting in PHP is a very usable option but sometimes you can be buried with &#8220;PHP Notice&#8221; lines which you don&#8217;t need (save space and bandwith). PHP Notice: Undefined index: 11 in /home/website/blabla.php on line 52 To turn on reporting on all errors add this line above all other php lines (before error happens) [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/09/php-error-reporting/' addthis:title='PHP error reporting '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Error reporting in PHP is a very usable option but sometimes you can be buried with &#8220;PHP Notice&#8221; lines which you don&#8217;t need (save space and bandwith).</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">PHP Notice:  Undefined index: 11 in /home/website/blabla.php on line 52</pre></div></div>

<p>To turn on reporting on all errors add this line above all other php lines (before error happens)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Report all PHP errors</span>
<span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To turn on all errors except E_NOTICE</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ALL</span> ^ <span style="color: #009900; font-weight: bold;">E_NOTICE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To turn off reporting (not recommended)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To be sure that this will work, place error_reporting right below opening php tag (< ? php)</p>
<p>More about this options can be found <a href="http://php.net/manual/en/function.error-reporting.php" target="_blank">HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/09/php-error-reporting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP as a shell scripting language</title>
		<link>http://www.serveradminblog.com/2010/07/using-php-as-a-shell-scripting-language/</link>
		<comments>http://www.serveradminblog.com/2010/07/using-php-as-a-shell-scripting-language/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 12:28:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=133</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/07/using-php-as-a-shell-scripting-language/' addthis:title='Using PHP as a shell scripting language '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>As most of us already know, PHP is one of the most popular scripting language for developing dynamic web pages. But you probably don&#8217;t know that PHP can be used as a shell scripting language. It isn&#8217;t robust as Bash or Perl but it has some advantages. The only difference between a PHP shell script [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/07/using-php-as-a-shell-scripting-language/' addthis:title='Using PHP as a shell scripting language '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>As most of us already know, PHP is one of the most popular scripting language for developing dynamic web pages. But you probably don&#8217;t know that PHP can be used as a shell scripting language. It isn&#8217;t robust as Bash or Perl but it has some advantages. </p>
<p>The only difference between a PHP shell script and a regular PHP file which serves web page is the first line:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/php -q</span></pre></div></div>

<p>The &#8216;-q&#8217; switch is here to suppress the HTTP headers. After the first line, you just add standard PHP tags:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Here is the example so you can see what I&#8217;m talking about:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/php -q
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
    <span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hi there folks !<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Save these lines as test.php and execute with:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># php test.php</pre></div></div>

<p>Good idea is to add the next lines at the beginning:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;argv&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_METHOD'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">||</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;br&gt;&lt;strong&gt;Shell access only&lt;/strong&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this case, this script can be accessible via browser but those lines will kill the script in case if it is issued via browser.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/07/using-php-as-a-shell-scripting-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to PHP 5.2.5 on RHEL and CentOS</title>
		<link>http://www.serveradminblog.com/2009/04/upgrading-to-php-525-on-rhel-and-centos/</link>
		<comments>http://www.serveradminblog.com/2009/04/upgrading-to-php-525-on-rhel-and-centos/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 23:12:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=23</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2009/04/upgrading-to-php-525-on-rhel-and-centos/' addthis:title='Upgrading to PHP 5.2.5 on RHEL and CentOS '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>As you probably know, the latest CentOS and RHEL distros are available only with PHP 5.1.6 and if you want to upgrade PHP, you need to install it manually (or to find someone to do it for you ). The 5.2.5 release brings several security enhancements, more than 60 bug fixes, and improved performance for [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2009/04/upgrading-to-php-525-on-rhel-and-centos/' addthis:title='Upgrading to PHP 5.2.5 on RHEL and CentOS '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>As you probably know, the latest CentOS and RHEL distros are available only with PHP 5.1.6 and if you want to upgrade PHP, you need to install it manually (or to find someone to do it for you <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).  The 5.2.5 release brings several security enhancements, more than 60 bug fixes, and improved performance for those of you that like arrays (and really, who doesn&#8217;t?). I wanted to install latest RoundCube webmail application and it won&#8217;t work if you don&#8217;t have PHP> 5.2. Also, latest Vivvo won&#8217;t work without 5.2.x</p>
<p>So, if you don&#8217;t want to build rpms or to go through ./configure, make, make install nightmare, you can enable Jason Litka yum repository to your RHEL or CentOS system. To do this please follow next few steps.</p>
<p>First you need to validate that the packages came from Jason Litka and you&#8217;ll do it with next command:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka</pre></div></div>

<p>After you added his public GPG key, you&#8217;ll need to adjust yum so he can search at his repo. To do this, please follow next steps:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#nano -w /etc/yum.repos.d/utterramblings.repo</pre></div></div>

<p>Now copy next lines inside this file and save those changes.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka</pre></div></div>

<p>Now you can upgrade your PHP installation with simple:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#yum update php</pre></div></div>

<p>More information about this can be found <a href="http://www.jasonlitka.com/yum-repository/" target="_blank">HERE</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#php -v</pre></div></div>

<p>should return</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@ns1 ~]# php -v
PHP 5.2.6 (cli) (built: May  5 2008 10:32:59)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
[root@ns1 ~]#</pre></div></div>

<p>I forget to say that you should restart httpd after upgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2009/04/upgrading-to-php-525-on-rhel-and-centos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

