<?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>existence, refactored &#187; Training</title>
	<atom:link href="http://blog.bryanbibat.net/category/daily-entry/training-daily-entry/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bryanbibat.net</link>
	<description>With kindness comes naïveté. Courage becomes foolhardiness. And dedication has no reward.</description>
	<lastBuildDate>Thu, 17 May 2012 13:53:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Pangkaraniwang Developer &#8211; matuto ng Computer Science at Programming</title>
		<link>http://blog.bryanbibat.net/2012/05/17/pangkaraniwang-developer-matuto-ng-computer-science-at-programming/</link>
		<comments>http://blog.bryanbibat.net/2012/05/17/pangkaraniwang-developer-matuto-ng-computer-science-at-programming/#comments</comments>
		<pubDate>Thu, 17 May 2012 13:42:26 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[pangkaraniwang developer]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1601</guid>
		<description><![CDATA[&#8220;Turuan ang sinumang Pilipino na gustong matuto ng Programming o Computer Science.&#8221; If there&#8217;s a tagline for my current project, Pangkaraniwang Developer, that would be it. No need for a lengthy blog post, just head over to the About page and learn why I&#8217;m doing this. Donations are always welcome. LOL]]></description>
			<content:encoded><![CDATA[<p><a href="http://pd.bryanbibat.net" title="pangkaraniwang developer"><img src="http://images.bryanbibat.net/pd.png" class="aligncenter" /></a></p>
<p><em>&#8220;Turuan ang sinumang Pilipino na gustong matuto ng Programming o Computer Science.&#8221;</em></p>
<p>If there&#8217;s a tagline for my current project, <a href="http://pd.bryanbibat.net" title="pangkaraniwang developer">Pangkaraniwang Developer</a>, that would be it.</p>
<p>No need for a lengthy blog post, just head over to the <a href="http://pd.bryanbibat.net/about">About</a> page and learn why I&#8217;m doing this. </p>
<p>Donations are always welcome. LOL</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/05/17/pangkaraniwang-developer-matuto-ng-computer-science-at-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to prepare for a Technical Interview</title>
		<link>http://blog.bryanbibat.net/2012/04/14/how-to-prepare-for-a-technical-interview/</link>
		<comments>http://blog.bryanbibat.net/2012/04/14/how-to-prepare-for-a-technical-interview/#comments</comments>
		<pubDate>Sat, 14 Apr 2012 11:06:18 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[interviewing]]></category>
		<category><![CDATA[Object Oriented]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1575</guid>
		<description><![CDATA[With April being the graduation month here in the Philippines, you&#8217;ll be seeing fresh graduates in various forums and discussion groups looking for advice on how to pass technical interviews. Here&#8217;s one posted over at the PHP Users Group forum earlier today: Can you help me with this? I&#8217;m going to take a technical written [...]]]></description>
			<content:encoded><![CDATA[<p>With April being the graduation month here in the Philippines, you&#8217;ll be seeing fresh graduates in various forums and discussion groups looking for advice on how to pass technical interviews. Here&#8217;s one posted over at the PHP Users Group forum earlier today:</p>
<blockquote><p>Can you help me with this? I&#8217;m going to take a technical written exam for a job i&#8217;m applying. Here is the list of what are expected on the exam:<br />
-Basic Programming<br />
-OOP<br />
-recursive programming and variables in programming<br />
-? statement<br />
-conditional statements<br />
-loop statements<br />
-flowcharting<br />
-pseudocodes (strings,odd/even)<br />
Can you guys give me tips and heads up on where to focus and what to expect on the exam? The exam will be next week and I want to be prepared for it. Thanks in advance.</p>
<p>PS: Hindi ko alam kung anong programming language ung eexam. (<em>I don&#8217;t know what programming language will be used in the test</em>)</p></blockquote>
<p>Whenever I see these type of questions, the first thing I do is give a <a href="https://www.google.com/search?q=look+of+disapproval" title="look of disapproval">ಠ_ಠ</a> to my monitor. The listed coverage above is so basic that every 2<sup>nd</sup> year college student should have no problem with it.</p>
<p>It&#8217;s like a carpenter asking what tool to focus on when applying for a carpenter position: screwdrivers, hammers, saws, or measuring tape? Yes, it&#8217;s <em>that</em> basic.</p>
<p>Unhelpful snarkiness aside, what advice would I give to these fresh grads?</p>
<p><span id="more-1575"></span>There only need to do two things:</p>
<p><strong>1. Relearn the basics</strong></p>
<p>If you&#8217;re not confident about the things listed above once you&#8217;ve graduated college, it may mean that you don&#8217;t have a good foundation with the <a href="http://blog.bryanbibat.net/tag/fundamentals/">fundamentals</a> yet. So the best advice I could give for that problem would be to <em>forget everything you know and start over using the following books</em>:</p>
<ul>
<li><a href="http://pine.fm/LearnToProgram/">Learn to Program</a> by Chris Pine</li>
<li><a href="http://learnpythonthehardway.org/book/">Learn Python the Hard Way</a> by Zed Shaw</li>
<li><a href="http://www.greenteapress.com/thinkpython/thinkpython.html">Think Python</a> or <a href="http://www.greenteapress.com/thinkapjava/">Think Java</a> by Allen Downey</li>
<li><a href="http://mitpress.mit.edu/sicp/">Structure and Interpretation of Computer Programs</a> by Harold Abelson and Gerald Sussman (<em>optional, if you want to double your starting salary. LOL</em>)
</ul>
<p>When reading these books, you may find out how outdated or incomplete your college courses were back when you were taught programming. This is normal, and is an important part of the (re)learning process.</p>
<p>While you are reading these books, you may do the second advice at the same time:</p>
<p><strong>2. Practice. Practice. PRACTICE!!!!</strong></p>
<p>Apart from lack of fundamentals, the other reason you might not be that confident in going into a technical interview is the lack of coding practice &#8212; you should&#8217;ve encountered all of the things above had you coded thousands of lines of code before graduating.</p>
<p>So practice! Go to <a href="http://projecteuler.net/">Project Euler</a> and try to solve the problems! Go to <a href="http://www.topcoder.com/">Top Coder</a> and do the same with the High School competitions!</p>
<p>Find algorithms and try to implement them! Start with simple ones like the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Erasthosenes</a> and <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Conway&#8217;s Game of Life</a>, then move on to progressively harder ones like <a href="http://en.wikipedia.org/wiki/Quicksort">Quicksort</a> and <a href="http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm">Dijkstra&#8217;s Algorithm</a>.</p>
<p>Also, don&#8217;t be content with just writing code; make an effort to <strong>read code</strong>. Good programmers are like good novelists; they read a lot more code than they write so they know what looks right and what looks wrong.</p>
<p>In other words, if you can&#8217;t figure out how to code something, just search for sample code on the internet and study them.</p>
<p>&#8212;</p>
<p>Just to wrap things up, I&#8217;ll be commenting on the items in the &#8220;technical interview coverage&#8221; listed at the start of this post.</p>
<blockquote><p>-Basic Programming<br />
&#8230;<br />
-&#8230;variables in programming<br />
-conditional statements<br />
-loop statements</p></blockquote>
<p>If you&#8217;re not familiar with these after a CS/IT course in college, I really question the quality of your education.</p>
<blockquote><p>-? statement</p></blockquote>
<p>It&#8217;s the <a href="http://en.wikipedia.org/wiki/%3F:">conditional operator</a>, used for writing if-then-else statements in shorthand. </p>
<p>Technically speaking, you really don&#8217;t need to use this (and in turn, don&#8217;t really need to know this) but there are a lot of cases where the shorter form makes code much easier to read. (And there are a lot of cases where it makes code really <em>hard</em> to read, but that&#8217;s another story.)</p>
<blockquote><p>-recursive programming &#8230;</p></blockquote>
<p><a href="http://en.wikipedia.org/wiki/Recursion_%28computer_science%29">This is recursion.</a> There are two types of interviews that use recursion:</p>
<ul>
<li>The bullshit type that makes you use recursion for tasks that can be done with simple loops like <a href="http://en.wikipedia.org/wiki/Recursion_%28computer_science%29#Factorial">factorial</a> and <a href="http://en.wikipedia.org/wiki/Recursion_%28computer_science%29#Fibonacci">fibonacci sequence</a>. If you know what loops are (and you should) and what recursion is, this shouldn&#8217;t be hard for you.
<p>Why do I find it bullshit? Because any programmer worth his/her salt knows how bad <a href="http://en.wikipedia.org/wiki/Tail_call">tail recursion</a> can be in certain languages.</p>
<p>If a decent technical interviewer would ask me this question, I&#8217;d expect a follow up question on how to eliminate the tail call.</li>
<li>The good type of interview that really requires recursion i.e. the ones that require stacks and backtracking. For example:<br />
<blockquote><p>Given a string of characters, find the longest palindrome within the string.</p></blockquote>
<p>These problems may be harder, but they&#8217;re very much doable if you practiced the way suggested above.
</li>
</ul>
<blockquote><p>-flowcharting</p></blockquote>
<p>As I&#8217;ve mentioned in <a href="www.twitter.com/bry_bibat/status/190804146885103617">last night&#8217;s tweet</a>, flowcharts are cute but useless. Anything less than <a href="http://en.wikipedia.org/wiki/Data_flow_diagram">Data Flow Diagrams</a> or <a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language">UML</a> Diagrams can be better written as pseudocode.</p>
<blockquote><p>-pseudocodes (strings,odd/even)</p></blockquote>
<p>Which brings us to this one. <a href="http://en.wikipedia.org/wiki/Pseudocode">Pseudocode</a> has nothing to do with &#8220;strings,odd/even&#8221;. My guess is that this just wants the applicant to be comfortable with writing pseudocode that deals with strings. (and numbers?)</p>
<blockquote><p>-OOP</p></blockquote>
<p>Now here&#8217;s the hard part. Even I didn&#8217;t have good OOP knowledge even after graduating from college.</p>
<p>Fortunately, the books listed above have decent chapters on OOP so just read up on the topic and practice.</p>
<p>And finally:</p>
<blockquote><p>PS: Hindi ko alam kung anong programming language ung eexam. (<em>I don&#8217;t know what programming language will be used in the test</em>)</p></blockquote>
<p>This means the test is language agnostic and you will be coding in pseudocode. Just use the language you&#8217;re most familiar with.</p>
<p>If the interviewer berates you for syntax errors on code written on a whiteboard or a piece of paper, you probably won&#8217;t want to work in such a company. Trust me.</p>
<p>&#8211;</p>
<p>In closing, most technical interviews are just there to weed out applicants who pose as developers but can&#8217;t really write a line of code. So if you <em>really</em> know how to code, you shouldn&#8217;t have a problem with them.</p>
<p>And if you do fail, just take it as a sign that you need to practice harder. Unlike in other fields, a few months of practice in programming will actually help you get better jobs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/04/14/how-to-prepare-for-a-technical-interview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What programming language should I learn?</title>
		<link>http://blog.bryanbibat.net/2012/03/20/what-programming-language-should-i-learn/</link>
		<comments>http://blog.bryanbibat.net/2012/03/20/what-programming-language-should-i-learn/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 11:28:35 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[public talk]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1556</guid>
		<description><![CDATA[I got to talk for DevCon again last Saturday at STI Makati. Instead of preparing a new talk, I just rehashed an old talk to save time. The new talk is also over at Slideshare. Anyway, the point of this post is to answer a question posed to me by a student in the Q&#038;A [...]]]></description>
			<content:encoded><![CDATA[<p>I got to talk for DevCon again last Saturday at STI Makati. Instead of preparing a new talk, I just rehashed an <a href="http://www.slideshare.net/bryanbibat/latest-trends-in-open-source-web-technologies">old talk</a> to save time. The new talk is also over at <a href="http://www.slideshare.net/bryanbibat/latest-trends-in-web-technologies">Slideshare</a>.</p>
<p>Anyway, the point of this post is to answer a question posed to me by a student in the Q&#038;A portion of the talk:</p>
<blockquote><p><em>Anong programming language ang dapat naming pag-aralan?</em><br />
(What programming language should we learn?)</p></blockquote>
<p>Here&#8217;s a question I wouldn&#8217;t want to hear answered by someone else (i.e. someone who&#8217;s also invited to talk to students). The question itself may seem simple, but unless you&#8217;ve seen how the industry works as a whole, you&#8217;ll probably give a wrong answer.</p>
<p>The traditional answer I don&#8217;t want to hear is to give a suggested list of languages based on market demand. </p>
<p>Simply put, this is bullshit. This is the same sort of bullshit that pressures our youth to take nursing courses even though they&#8217;re just in it for the money, money that they probably won&#8217;t get due to the eventual over-supply of nurses.</p>
<p>So for the student&#8217;s question, I gave two answers:</p>
<p><strong>Programming language and platform choice doesn&#8217;t matter, because for the most part it&#8217;s a business decision.</strong></p>
<p>Yes, I&#8217;m talking about <a href="http://blog.bryanbibat.net/2009/04/26/zed-shaw-the-acl-is-dead/">steaks and strippers</a>. In a large company, you may be initially hired to work on a single language, but eventually there will be a time where the company will make a business decision to shift technologies, whether due to market pressure or due to a new client. If you focus too much on a language, you will not be prepared for the change and you may end up getting fired or demoted.</p>
<p>In smaller companies or in a freelance setting, language still doesn&#8217;t matter, though for another reason: the client will not care about the language as long as you deliver the product.</p>
<p>This leads to the other answer:</p>
<p><strong>Focus on the fundamentals, not on the language/platform.</strong></p>
<p>A common mistake among fresh grads is that they&#8217;re confident they know language A or platform B because they were able to make their school projects or theses while at the same time not having their <a href="http://blog.bryanbibat.net/tag/fundamentals/">fundamentals</a> down pat. Not only does this make them inflexible in terms of learning new languages, it also makes their work brittle and sloppy.</p>
<p>In other words, a student who has 4 years of school &#8220;experience&#8221; in Java is nothing compared to a developer who just had learned Java a month ago but has solid fundamentals in OOP.</p>
<p>You might say &#8220;Screw learning, I&#8217;m just in this for the money!&#8221;. But the fact is, there&#8217;s this thing called the <a href="http://www.paulgraham.com/pypar.html">Python Paradox</a>: developers who are passionate enough to learn more than their peers often end up in higher-earning and less-stressful jobs.</p>
<p><strong>Bottom line:</strong> There is no &#8220;best&#8221; language that you need to learn in order to earn a lot of money. However, if you have good fundamentals, learning the language and platform that the market needs will be much easier for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/03/20/what-programming-language-should-i-learn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert FanFiction.net Stories into PDF</title>
		<link>http://blog.bryanbibat.net/2012/02/19/convert-fanfiction-net-stories-into-pdf/</link>
		<comments>http://blog.bryanbibat.net/2012/02/19/convert-fanfiction-net-stories-into-pdf/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 05:39:02 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[ffnpdf]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[pandoc]]></category>
		<category><![CDATA[publishing]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1531</guid>
		<description><![CDATA[Had a coding itch last week related to web scraping and LaTeX PDF conversion. One thing led to another and the end result was my first ever Ruby Gem: ffnpdf, a tool that converts FanFiction.net stories into PDF files. (Great for putting your favorite Harry Potter slash fics on your mobile phone or tablet for [...]]]></description>
			<content:encoded><![CDATA[<p>Had a coding itch last week related to web scraping and LaTeX PDF conversion. One thing led to another and the end result was my first ever <a href="http://en.wikipedia.org/wiki/RubyGems">Ruby Gem</a>: </p>
<p><a href="https://rubygems.org/gems/ffnpdf"><code>ffnpdf</code></a>, a tool that converts <a href="http://fanfiction.net">FanFiction.net</a> stories into PDF files. </p>
<p>(Great for putting your favorite Harry Potter slash fics on your mobile phone or tablet for portable use! LOL)</p>
<p>The code and documentation are found at <a href="https://github.com/bryanbibat/ffnpdf">the Github page</a>. Theoretically, this gem can work anywhere Ruby, pandoc, and XeTeX can be installed (e.g. Windows, OS X, *nix) but I&#8217;ve only been able to make the whole thing work in Ubuntu/Mint.</p>
<p>Demo and how-tos are posted in <a href="http://www.youtube.com/playlist?list=PLA7C6F157E1651A69">this playlist</a>:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/videoseries?list=PLA7C6F157E1651A69&amp;hl=en_US" frameborder="0" allowfullscreen></iframe></p>
<p>I haven&#8217;t gotten around to make a license for this, but I assume that anyone into fanfiction knows that publishing and selling fanfics without consent from the rights owner is a <em>big no-no</em>. Thus, I don&#8217;t need remind them that this tool is just for personal use and not for commercial purposes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/02/19/convert-fanfiction-net-stories-into-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding Screencasts</title>
		<link>http://blog.bryanbibat.net/2012/01/14/coding-screencasts/</link>
		<comments>http://blog.bryanbibat.net/2012/01/14/coding-screencasts/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 07:31:09 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Gosu]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Rspec]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[screencasts]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1512</guid>
		<description><![CDATA[I&#8217;ve been doing some programming screencasts lately over my Youtube channel. They&#8217;re not really &#8220;screencasts&#8221; ala RailsCasts but more like informal streamed videos that you&#8217;d see in Justin.tv/Twitch.tv. These screencasts were recorded in 720p so it&#8217;s a good idea to select a higher resolution then view the videos in full screen or the large player [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some programming screencasts lately over my Youtube channel. They&#8217;re not really &#8220;screencasts&#8221; ala <a href="http://railscasts.com/">RailsCasts</a> but more like informal streamed videos that you&#8217;d see in <a href="http://www.justin.tv">Justin.tv</a>/<a href="http://www.twitch.tv">Twitch.tv</a>.</p>
<p>These screencasts were recorded in 720p so it&#8217;s a good idea to select a higher resolution then view the videos in full screen or the large player in order for you to read the code properly.</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/videoseries?list=PLD8B9D59833F52F59&amp;hl=en_US" frameborder="0" allowfullscreen></iframe></p>
<p>Here I code a hexagonal &#8220;game of life&#8221;-like cellular automata. Used Ruby, <a href="http://www.libgosu.org/">Gosu</a>, and <a href="http://rspec.info/">RSpec</a>.</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/videoseries?list=PL8FA7120F31F16508&amp;hl=en_US" frameborder="0" allowfullscreen></iframe></p>
<p>Walking through coding a simple Rails app. Bunch of technologies discussed like <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>, <a href="http://www.heroku.com/">Heroku</a>, and <a href="http://git-scm.com/">git</a>.</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/videoseries?list=PLA608CA386B07897C&amp;hl=en_US" frameborder="0" allowfullscreen></iframe></p>
<p>Going through <a href="http://projecteuler.net/">Project Euler</a> problems via brute force using Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/01/14/coding-screencasts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learn how to setup a web server pt3: Installing MySQL and PHP apps (e.g. WordPress)</title>
		<link>http://blog.bryanbibat.net/2012/01/12/learn-how-to-setup-a-web-server-pt3-installing-mysql-and-php-apps-e-g-wordpress/</link>
		<comments>http://blog.bryanbibat.net/2012/01/12/learn-how-to-setup-a-web-server-pt3-installing-mysql-and-php-apps-e-g-wordpress/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 04:24:45 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP-FPM]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1503</guid>
		<description><![CDATA[Here&#8217;s a quick update to this mini-tutorial. Previous parts can be found here and here. Installing MySQL Installing MySQL is so simple that I don&#8217;t need to hide it behind the cut. The one in the Ubuntu repositories work just fine: $ sudo apt-get install mysql-server-5.1 Note that you will be asked to enter a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bryanbibat.net/images/wordpress-installed.jpg" class="aligncenter" alt="WordPress Installed" /></p>
<p>Here&#8217;s a quick update to this mini-tutorial. Previous parts can be found <a href="http://blog.bryanbibat.net/2011/12/17/learn-how-to-setup-a-web-server-pt1-setting-up-a-practice-server/">here</a> and <a href="http://blog.bryanbibat.net/2011/12/19/learn-how-to-setup-a-web-server-pt2-installing-nginx-and-php">here</a>. </p>
<h3>Installing MySQL</h3>
<p>Installing <a href="http://www.mysql.com/">MySQL</a> is so simple that I don&#8217;t need to hide it behind the cut. The one in the Ubuntu repositories work just fine:</p>
<pre>$ sudo apt-get install mysql-server-5.1</pre>
<p>Note that you will be asked to enter a root password somewhere in the installation.</p>
<p>To wrap up the installation run</p>
<pre>$ sudo mysql_install_db</pre>
<p>to initialize the installed server and</p>
<pre>$ sudo mysql_secure_installation</pre>
<p>to secure it. </p>
<p>In <code>mysql_secure_installation</code>, you&#8217;ll be asked for your root password and then you&#8217;ll asked if you want to change it. Just enter &#8220;n&#8221; since there&#8217;s no reason to change it this early. Then you&#8217;ll be asked if you want to do some things to secure the database which is, of course, what we want to do so just hit Enter for each question to choose the default answer (&#8220;Y&#8221;).</p>
<p><span id="more-1503"></span><br />
<h3>Installing WordPress</h3>
<p>Now we go to making our Ubuntu + nginx + PHP + MySQL setup more useful by installing a web app. I choose <a href="http://wordpress.org/">WordPress</a> for this tutorial because it&#8217;s both popular and easy to install.</p>
<p>Note that most PHP web apps out there have similar installation steps i.e. install prerequisites, setup database, download and extract files, and configure the app.</p>
<p><strong>Installing prerequisites</strong></p>
<p>We only need to install a few extra components for WordPress to work on our box:</p>
<pre>$ sudo apt-get install php5-mysql php5-gd</pre>
<p><code>php5-mysql</code> is obviously required to allow PHP to connect to MySQL. <code>php5-gd</code> may be needed if you&#8217;re uploading images inside WordPress instead of using an external hosting.</p>
<p>At this point we are ready to follow the <a href="http://codex.wordpress.org/Installing_WordPress">Installing WordPress</a> guide.</p>
<p><strong>Creating the database</strong></p>
<p>I&#8217;ve switched around steps 1 and 2 because I prefer to do file-related tasks together instead of jumping from files to database to files again.</p>
<p>In setting up the database, we go with the client guide. Creating a new user isn&#8217;t part of that guide, though, so we&#8217;ll have to do that too.</p>
<p>Connect to the database using the root user:</p>
<pre>$ mysql -u root -p</pre>
<p>You will be prompted for the password before you can proceed. Once in, you can now proceed with doing what you need to do. The following lines will create a database named <code>wp</code> and a user named <code>wp_user</code> whose password is <code>password_here</code>.</p>
<pre>mysql> CREATE DATABASE wp;

mysql> CREATE USER wp_user;

mysql> SET PASSWORD FOR wp_user = PASSWORD("password_here");

mysql> GRANT ALL PRIVILEGES ON wp.* TO "wp_user"@"localhost" IDENTIFIED BY "password_here";

mysql> FLUSH PRIVILEGES;

mysql> EXIT</pre>
<p><strong>Downloading WordPress and moving it around</strong></p>
<p>Now it&#8217;s time to proceed with steps 1 and 3. Use <code>wget</code> to download and extract the latest version of WordPress:</p>
<pre>$ wget http://wordpress.org/latest.tar.gz

$ tar -zxvf latest.tar.gz</pre>
<p>We&#8217;ll then move the extracted folder <code>wordpress/</code> to <code>/var/www/</code> to centralize our web-app stuff.</p>
<pre>$ sudo mv wordpress /var/www/</pre>
<p>We also need to change the ownership for the folder:</p>
<pre>$ sudo chown -R www-data:www-data /var/www/wordpress</pre>
<p><strong>Configuring it to work</strong></p>
<p>First we need to add our database settings to <code>wp-config.php</code>:</p>
<pre>$ cd /var/www/wordpress

/var/www/wordpress$ sudo mv wp-config-sample.php wp-config.php

/var/www/wordpress$ sudo vim wp-config.php</pre>
<p>Change the settings as follows:</p>
<pre>// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wp');

/** MySQL database username */
define('DB_USER', 'wp_user');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');</pre>
<p>Now to edit our nginx settings.</p>
<pre>$ sudo vim /etc/nginx/nginx.conf</pre>
<p>We&#8217;ll be using a combination of suggested settings from both nginx and WordPress documents:</p>
<pre>
...
    server {
        listen       80;
        server_name *.mysite.dev;
        root /var/www/wordpress;

        if ($http_host != "mysite.dev") {
                rewrite ^ http://mysite.dev$request_uri permanent;
        }

        # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content
                try_files $uri $uri/ /index.php;
        }

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass php;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
    }
}
</pre>
<p>The main changes here are the update to the root (pointing it now to <code>/var/www/wordpress</code>) and the <code>try_files</code> approach of URL rewriting (which allows nginx to act like <code>mod_rewrite</code> without the use of <code>.htaccess</code>).</p>
<p><strong>Wrapping up</strong></p>
<p>Restart both PHP-FPM and nginx to apply the changes we made to both.</p>
<pre>$ sudo /etc/init.d/php5-fpm restart

$ sudo /etc/init.d/nginx restart</pre>
<p>Then go to <code>http://mysite.dev</code> to proceed with the &#8220;famous 5-minute install&#8221;.</p>
<p><img src="http://www.bryanbibat.net/images/wordpress-install.jpg" class="aligncenter" alt="WordPress Installer" /></p>
<p><img src="http://www.bryanbibat.net/images/wordpress-installed.jpg" class="aligncenter" alt="WordPress Installed" /></p>
<p>You have now successfully installed WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/01/12/learn-how-to-setup-a-web-server-pt3-installing-mysql-and-php-apps-e-g-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learn how to setup a web server pt2: Installing Nginx and PHP</title>
		<link>http://blog.bryanbibat.net/2011/12/19/learn-how-to-setup-a-web-server-pt2-installing-nginx-and-php/</link>
		<comments>http://blog.bryanbibat.net/2011/12/19/learn-how-to-setup-a-web-server-pt2-installing-nginx-and-php/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 09:41:14 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[ApacheBench]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP-FPM]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1486</guid>
		<description><![CDATA[Here&#8217;s the next part of my basic web server administration tutorial. At the first part, we set up the virtual machine. Now we&#8217;ll be setting up the web server itself. Set Static IP Address and fake Domain Name Before we could proceed with installing our web server, let&#8217;s do a couple of things to make [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bryanbibat.net/images/phpinfo.png" class="aligncenter" alt="phpinfo()" /></p>
<p>Here&#8217;s the next part of my basic web server administration tutorial.</p>
<p><a href="http://blog.bryanbibat.net/2011/12/17/learn-how-to-setup-a-web-server-pt1-setting-up-a-practice-server/">At the first part</a>, we set up the virtual machine. Now we&#8217;ll be setting up the web server itself.</p>
<p><strong>Set Static IP Address and fake Domain Name</strong></p>
<p>Before we could proceed with installing our web server, let&#8217;s do a couple of things to make our server behave more like a &#8220;normal&#8221; server.</p>
<p>First is to set our server&#8217;s <a href="http://en.wikipedia.org/wiki/IP_address#IP_address_assignment">IP address</a> to a static IP address. There are a bunch of ways to do this (e.g. change the router settings), but we&#8217;ll just go with changing our server&#8217;s settings</p>
<p>Running <code>ifconfig</code> and <code>route</code> will give us the current IP address and <a href="http://en.wikipedia.org/wiki/Gateway_%28telecommunications%29">gateway</a>.</p>
<p><img src="http://www.bryanbibat.net/images/ip-route.png" class="aligncenter" alt="ifconfig and route" /></p>
<p>In this case, the new IP address is 192.168.1.125 and the gateway is 192.168.1.5. We can now apply these settings to <code>/etc/network/interfaces</code>. Open the said file via:</p>
<pre>$ sudo vim /etc/network/interfaces</pre>
<p>(For this tutorial, I&#8217;ll be using <a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29"><code>vim</code></a> as the default text editor. If you find vim too daunting, you can replace all instances of <code>vim</code> with <a href="http://en.wikipedia.org/wiki/Nano_%28text_editor%29"><code>nano</code></a>)</p>
<p>It will look something like:</p>
<pre># This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp</pre>
<p>Now replace the last line with the following:</p>
<pre>iface eth0 inet static
address [address here]
netmask 255.255.255.0
gateway [gateway here]</pre>
<p>for example:</p>
<pre>iface eth0 inet static
address 192.168.1.125
netmask 255.255.255.0
gateway 192.168.1.5</pre>
<p>To make sure you got the static IP settings correctly, you can restart the server via</p>
<pre>$ sudo shutdown -r now</pre>
<p>or you could just simply restart the network interface:</p>
<pre>$ sudo /etc/init.d/networking restart</pre>
<p>Here we see the <code>/etc/init.d</code> folder where the <a href="http://en.wikipedia.org/wiki/Init">init</a> scripts (like networking) are placed. Aside from being executed automatically upon boot to start services, they can also be used to stop or restart the said services just like what we just did with <code>networking</code>. We will see more of <code>/etc/init.d/</code> later in this tutorial.</p>
<p>Now that we&#8217;ve set the IP address as static, it&#8217;s time to set a fake <a href="http://en.wikipedia.org/wiki/Domain_name">domain name</a>.</p>
<p>Normally, when you&#8217;ve got a server with a static IP address, you&#8217;d have to go and buy a domain name from a registrar like <a href="http://www.namecheap.com/">Namecheap</a> and you&#8217;d go through the steps in linking that name with the IP address and waiting for the DNS propagation.</p>
<p>For this tutorial, we&#8217;re going to skip all that by faking it with the <a href="http://en.wikipedia.org/wiki/Hosts_%28file%29">hosts file</a>.</p>
<p>First let&#8217;s update the server&#8217;s <code>/etc/hosts</code> file to add our fake domain name &#8220;mysite.dev&#8221;:</p>
<pre>sudo vim /etc/hosts</pre>
<p>Add the line at the end:</p>
<pre>192.168.1.125   mysite.dev</pre>
<p>You can verify the new setting by using the <a href="http://en.wikipedia.org/wiki/Ping"><code>ping</code></a> command.</p>
<pre>user@ubuntu:~$ ping -c 4 mysite.dev
PING mysite.dev (192.168.1.125) 56(84) bytes of data.
64 bytes from mysite.dev (192.168.1.125): icmp_seq=1 ttl=64 time=0.172 ms
64 bytes from mysite.dev (192.168.1.125): icmp_seq=2 ttl=64 time=2.38 ms
64 bytes from mysite.dev (192.168.1.125): icmp_seq=3 ttl=64 time=3.34 ms
64 bytes from mysite.dev (192.168.1.125): icmp_seq=4 ttl=64 time=1.59 ms

--- mysite.dev ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3016ms
rtt min/avg/max/mdev = 0.172/1.874/3.342/1.161 ms
user@ubuntu:~$</pre>
<p>Now let&#8217;s apply the fake domain name mapping to the host Windows computer. Like in Linux, the hosts file in Windows requires admin privileges so we first need to run the text editor as Administrator in order to allow us to modify it.</p>
<p><img src="http://www.bryanbibat.net/images/run-as-admin.png" class="aligncenter" alt="Run as administrator" /></p>
<p>Right-click Notepad and select &#8220;Run as administrator&#8221;. Once open, you can now add the &#8220;<code>192.168.1.125 mysite.dev</code>&#8221; to the end of the <code>C:\Windows\System32\drivers\etc\hosts</code> file.</p>
<p>Now you could change the PuTTy settings to use &#8220;mysite.dev&#8221; instead of the actual IP address.</p>
<p>The actual installation of the web server below the cut.</p>
<p><span id="more-1486"></span><br />
<h3>Installing Nginx</h3>
<p>It&#8217;s finally time to install the web server.</p>
<p>We won&#8217;t be using <a href="http://en.wikipedia.org/wiki/Apache_HTTP_Server">Apache</a>, though. Instead, we&#8217;re going to go with its leaner and faster Russian counterpart <a href="http://en.wikipedia.org/wiki/Nginx">nginx</a>. We&#8217;re also going to build it from scratch (as opposed to getting it from a repository) to show you how its done in Linux machines.</p>
<p><strong>Installing dependencies</strong></p>
<p>We&#8217;ll need to install a few things before we could proceed with building nginx.</p>
<pre>$ sudo apt-get install build-essential libssl-dev libpcre3-dev</pre>
<p><code>build-essential</code> contains the essential tools for compiling programs from source while the other two are libraries that nginx needs during compilation.</p>
<p><strong>Building from source</strong></p>
<pre>~$ wget http://nginx.org/download/nginx-1.0.11.tar.gz</pre>
<p>Using <a href="http://en.wikipedia.org/wiki/Wget"><code>wget</code></a> we download the <a href="http://nginx.org/en/download.html">latest stable source</a> as of this writing. Yes, it&#8217;s a whopping 700 KB.</p>
<pre>~$ tar zxvf nginx-1.0.11.tar.gz</pre>
<p>We then unpack it using <a href="http://en.wikipedia.org/wiki/Tar_%28file_format%29"><code>tar</code></a>.</p>
<pre>~$ cd nginx-1.0.11

~/nginx-1.0.11$ ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module

~/nginx-1.0.11$ make

~/nginx-1.0.11$ sudo make install</pre>
<p>Now we finally perform the build/installation. This three-step configure-build-install scheme is pretty much how one builds any program in Linux from scratch.</p>
<p>This nginx build doesn&#8217;t come with an init script so we&#8217;ll have to download <a href="https://github.com/JasonGiedymin/nginx-init-ubuntu">one off the net</a>.</p>
<pre>~/nginx-1.0.11$ cd ~

~$ wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx

~$ sudo mv nginx /etc/init.d/nginx</pre>
<p>We still need to set a couple of things with the script:</p>
<pre>$ sudo chmod +x /etc/init.d/nginx

$ sudo chown root:root /etc/init.d/nginx</pre>
<p>The first command <a href="http://en.wikipedia.org/wiki/Chmod">sets the script to executable</a> and the other command <a href="http://en.wikipedia.org/wiki/Chown">gives the ownership of the script</a> to root. Now we can run nginx:</p>
<pre>$ sudo /etc/init.d/nginx start</pre>
<p>You can now open <a href="http://mysite.dev">http://mysite.dev</a> to check if it&#8217;s installed properly.</p>
<p><img src="http://www.bryanbibat.net/images/nginx-test.jpg" class="aligncenter" alt="nginx" /></p>
<p>Using Firebug or Chrome Developer tools will confirm the server&#8217;s really nginx 1.0.11.</p>
<p><img src="http://www.bryanbibat.net/images/nginx-headers.png" class="aligncenter" alt="nginx response headers" /></p>
<p><strong>Tweaking nginx</strong></p>
<p>Before we proceed with installing PHP, let&#8217;s apply some tweaks to nginx to make it more Apache-ish (lol) and then some.</p>
<pre>$ sudo ln -s /usr/local/nginx/conf /etc/nginx</pre>
<p>This creates <a href="http://en.wikipedia.org/wiki/Symbolic_link">a symbolic link</a> in the <code>/etc</code> folder to match with the <a href="http://en.wikipedia.org/wiki/Unix_directory_structure">convention for configuration files</a>.</p>
<pre>$ sudo vim /etc/nginx/nginx.conf</pre>
<p>Now we edit the configuration file like so:</p>
<pre>user  www-data;
worker_processes  1;

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    gzip on;
    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6]\.";
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
    error_log  /var/log/nginx/error.log  debug;

    sendfile        on;
    keepalive_timeout  3;
    index              index.html index.htm;

    server {
        listen       80;
        server_name *.mysite.dev;
        root /var/www;

        if ($http_host != "mysite.dev") {
                rewrite ^ http://mysite.dev$request_uri permanent;
        }

        # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }

    }

}
</pre>
<p>A quick summary of the changes:</p>
<ul>
<li>We changed the server&#8217;s user from &#8220;nobody&#8221; to the system user &#8220;www-data&#8221;, the default user for web servers.</li>
<li>We set the file where the <a href="http://en.wikipedia.org/wiki/Process_identifier">PID</a> for the server would be located. This will allow our init script to stop or restart the server.</li>
<li>We enabled gzip for supported browsers to dramatically reduce the bandwidth usage.</li>
<li>We set the log to match Apache&#8217;s format.</li>
<li>We defined a handler for the <code>*.mysite.dev</code> domain, defining its root to be the same as Apache&#8217;s (<code>/var/www</code>)</li>
</ul>
<p>Now to wrap things up:</p>
<pre>$ sudo cp -r /usr/local/nginx/html /var/www

$ sudo chown -R www-data:www-data /var/www</pre>
<p>We copy the <code>html</code> folder to <code>/var/www</code> and give it to <code>www-data</code>.</p>
<pre>$ sudo mkdir /var/log/nginx</pre>
<p>Just creating the log folder.</p>
<pre>$ sudo /etc/init.d/nginx destroy

$ sudo /etc/init.d/nginx start</pre>
<p>We force stop the server (as we haven&#8217;t defined the PID file when we started it) then start it normally.</p>
<p>Opening <a href="http://mysite.dev">http://mysite.dev</a> now shows us that the site is served as gzipped.</p>
<p><img src="http://www.bryanbibat.net/images/nginx-gzip.png" class="aligncenter" alt="nginx response headers" /></p>
<h3>Installing PHP-FPM</h3>
<p>Unlike nginx, we won&#8217;t be building PHP from scratch. We will, however, not go with Apache&#8217;s mod_php/extension route and instead go the <a href="http://php-fpm.org/">PHP-FPM</a> route which, like nginx, is much leaner than the former.</p>
<p>Since PHP-FPM isn&#8217;t available in the official apt repositories of Ubuntu 10.04, we will have to use another repository. Nginx&#8217;s repositories may be a bit out of date (PHP v5.3.5 vs the current v5.3.8) but it should be enough for this tutorial.</p>
<pre>$ sudo apt-get install python-software-properties

$ sudo add-apt-repository ppa:nginx/php5

$ sudo apt-get update

$ sudo apt-get install php5-fpm</pre>
<p>The steps above will install PHP-FPM with fairly decent defaults. If you want to change some settings, you can modify the files at <code>/etc/php5/fpm/</code> and restart the server via &#8220;<code>sudo /etc/init.d/php-fpm restart</code>&#8220;.</p>
<p>Now all we need to do is to tell nginx how to use PHP-FPM. Here&#8217;s our modified <code>/etc/nginx/nginx.conf</code>:</p>
<pre>user  www-data;
worker_processes  1;

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    gzip on;
    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6]\.";
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
    error_log  /var/log/nginx/error.log  debug;

    sendfile        on;
    keepalive_timeout  3;
    index              index.php index.html index.htm;

    upstream php {
        server 127.0.0.1:9000;
    }

    server {
        listen       80;
        server_name *.mysite.dev;
        root /var/www;

        if ($http_host != "mysite.dev") {
                rewrite ^ http://mysite.dev$request_uri permanent;
        }

        # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass php;
        }
    }
}
</pre>
<p>The main changes between the original are:</p>
<ul>
<li>Adding &#8220;<code>index.php</code>&#8221; before &#8220;<code>index.html index.htm</code>&#8221; to let the server prioritize the former over the latter.</li>
<li>The addition of the <code>upstream php</code> block that points to PHP-FPM.</li>
<li>The addition of the <code>location</code> handler for PHP files.</li>
</ul>
<p>We also need to modify <code>/etc/nginx/fastcgi_params</code>, adding the following lines at the end of the file:</p>
<pre>fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;</pre>
<p>Once done we can now restart the server via <code>sudo /etc/init.d/nginx restart</code>.</p>
<p>To test PHP, create the <code>phpinfo()</code> index.php file:</p>
<pre>$ sudo sh -c 'echo "&lt;? phpinfo();" &gt; /var/www/index.php'</pre>
<p>Then open <a href="http://mysite.dev">http://mysite.dev</a> again:</p>
<p><img src="http://www.bryanbibat.net/images/phpinfo.png" class="aligncenter" alt="phpinfo()" /></p>
<p>You have now installed nginx and PHP on your web server.</p>
<h3>Benchmarking</h3>
<p>You can use <a href="http://en.wikipedia.org/wiki/ApacheBench">ApacheBench</a> to see how well your site performs under load.</p>
<pre>$ sudo apt-get install apache2-utils</pre>
<p>Here&#8217;s 1000 requests with 100 concurrent users (10 requests each user) to our static HTML file:</p>
<pre>user@ubuntu:~$ ab -n 1000 -c 100 http://mysite.dev/index.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking mysite.dev (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        nginx/1.0.11
Server Hostname:        mysite.dev
Server Port:            80

Document Path:          /index.html
Document Length:        151 bytes

Concurrency Level:      100
Time taken for tests:   1.720 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      378290 bytes
HTML transferred:       157795 bytes
Requests per second:    581.31 [#/sec] (mean)
Time per request:       172.025 [ms] (mean)
Time per request:       1.720 [ms] (mean, across all concurrent requests)
Transfer rate:          214.75 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       27   79  15.7     84     102
Processing:    39   83  16.5     86     131
Waiting:       10   61  17.5     65      98
Total:        129  161  16.5    172     184

Percentage of the requests served within a certain time (ms)
  50%    172
  66%    173
  75%    173
  80%    173
  90%    178
  95%    182
  98%    183
  99%    183
 100%    184 (longest request)</pre>
<p>Here&#8217;s the same test against our <code>phpinfo()</code> page:</p>
<pre>user@ubuntu:~$ ab -n 1000 -c 100 http://mysite.dev/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking mysite.dev (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        nginx/1.0.11
Server Hostname:        mysite.dev
Server Port:            80

Document Path:          /
Document Length:        42481 bytes

Concurrency Level:      100
Time taken for tests:   8.582 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      42649000 bytes
HTML transferred:       42481000 bytes
Requests per second:    116.52 [#/sec] (mean)
Time per request:       858.186 [ms] (mean)
Time per request:       8.582 [ms] (mean, across all concurrent requests)
Transfer rate:          4853.19 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    6  16.6      0      63
Processing:    66  810 126.3    861     875
Waiting:       59  808 127.0    858     873
Total:        125  816 113.2    861     875

Percentage of the requests served within a certain time (ms)
  50%    861
  66%    862
  75%    863
  80%    864
  90%    869
  95%    874
  98%    874
  99%    875
 100%    875 (longest request)</pre>
<p>581 and 116 requests per second? Not bad for a &#8220;low end&#8221; server.</p>
<p><a href="http://blog.bryanbibat.net/2012/01/12/learn-how-to-setup-a-web-server-pt3-installing-mysql-and-php-apps-e-g-wordpress/" title="Learn how to setup a web server pt3: Installing MySQL and PHP apps (e.g. WordPress)">Proceed to part 3: Installing MySQL and WordPress</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2011/12/19/learn-how-to-setup-a-web-server-pt2-installing-nginx-and-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code Retreat Baguio 2011</title>
		<link>http://blog.bryanbibat.net/2011/12/05/code-retreat-baguio-2011/</link>
		<comments>http://blog.bryanbibat.net/2011/12/05/code-retreat-baguio-2011/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 02:15:09 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Event Report]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[code retreat]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1452</guid>
		<description><![CDATA[So after spending the entire day walking around doing stuff (and at one point get wrangled into MCing) for DevCon at DevOpsDays, me and a couple PhRUG guys got on a (red-eye?) bus to Baguio City for the non-official Philippine leg of the Global Day of Code Retreat. This isn&#8217;t a full write-up of the [...]]]></description>
			<content:encoded><![CDATA[<p>So after spending the entire day walking around doing stuff (and at one point get wrangled into MCing) for <a href="http://devcon.ph">DevCon </a>at <a href="http://www.devopsdays.org/events/2011-manila/">DevOpsDays</a>, me and a couple PhRUG guys got on a (red-eye?) bus to Baguio City for the <a href="http://groups.google.com/group/ruby-phil/browse_thread/thread/142920c66a3bb24e">non-official Philippine leg</a> of the <a href="http://blog.coderetreat.com/global-day-of-coderetreat">Global Day of Code Retreat</a>.</p>
<p>This isn&#8217;t a full write-up of the event so I&#8217;ll keep this short and simple. The event was at <a href="https://twitter.com/dreinavarro">Drei</a>&#8216;s place with just a bunch of Ruby, Python, and PHP guys from both Manila and Baguio hacking up random stuff instead of doing the whole Code Retreat thing.</p>
<div class="wp-caption"><a href="http://instagr.am/p/XHQCe/"><img class="aligncenter" src="http://www.bryanbibat.net/images/picture_while_you_picture.jpg" alt="after event" /></a></p>
<p class="wp-caption-text">at the after event, aka &#8220;Yo dawg, I heard <a href="http://www.bridgeutopiaweb.com/">you</a> like taking pictures so here&#8217;s a picture of people taking your picture so you can have a picture of you taking pictures of people taking pictures&#8221;</p>
</div>
<p>Being the slacker that I am, I didn&#8217;t have anything planned out beforehand. I thought I&#8217;d just go the same route as with Startup Weekend Manila and just be a <a href="http://c2.com/cgi/wiki?RubberDucking">rubber duck</a> floating around groups. Fortunately, <a href="https://twitter.com/keikun17">Buddy</a> brought along his significant other Rizza with the intention of having her learn programming from the participants of the event. </p>
<p>I couldn&#8217;t resist this teaching challenge. So for the entire event, I went on to give an impromptu crash course on the <a href="http://blog.bryanbibat.net/tag/fundamentals/">fundamentals of software development</a>. </p>
<p>I started off with basic imperative/procedural programming via pseudocode (to drill in the idea that software development is not about computers but about solving problems). As we progressed I moved on to Ruby for the more technical side of things (basic data types) up to <a href="http://blog.bryanbibat.net/tag/object-oriented/">Object Oriented basics</a>.</p>
<div class="wp-caption"><img class="aligncenter" src="http://www.bryanbibat.net/images/lesson-page1-2.jpg" alt="first lesson" /></p>
<p class="wp-caption-text">first programs &#8211; potato salad and quadratic formula</p>
</div>
<p>By mid-day, I had this little flash of insanity and began downloading >250MB of development stuff from a certain site.</p>
<p>That flash of insanity was to go back to the original Code Retreat exercise, <a href="http://coderetreat.com/gol.html">Conway&#8217;s Game of Life</a>, and build it in Java to teach software development: <a href="http://blog.bryanbibat.net/2009/09/03/code-conventions/">coding conventions</a>, <a href="http://blog.bryanbibat.net/tag/revision-control/">revision control</a>, <a href="http://en.wikipedia.org/wiki/Test_automation">test automation</a>, <a href="http://blog.bryanbibat.net/2009/08/25/refactoring/">refactoring</a>, etc.</p>
<p>Of course, I had to teach the most crucial concept in software development: <em>how to wing it</em>. And that was where Android came in.</p>
<p><iframe width="480" height="360" src="http://www.youtube.com/embed/-Kcu1fGUo1Q" frameborder="0" allowfullscreen></iframe></p>
<p>So we had a base GoL class and a freshly installed Android SDK. A couple of Google searches later and a lot of guesswork, we were able to make the whole thing work as a <a href="http://developer.android.com/resources/articles/live-wallpapers.html">Live Wallpaper</a> in around 1.5 hours.</p>
<p><img class="aligncenter" src="http://www.bryanbibat.net/images/device-gol-ss.png" alt="screenshot of wallpaper" /></p>
<p>Lack of sleep and preparation can turn a Ruby guy into a Java developer. LOL</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2011/12/05/code-retreat-baguio-2011/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vocal Retraining</title>
		<link>http://blog.bryanbibat.net/2011/11/30/vocal-retraining/</link>
		<comments>http://blog.bryanbibat.net/2011/11/30/vocal-retraining/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 10:09:19 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Cooking]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[podcasts]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1447</guid>
		<description><![CDATA[..or podcast, whatever you want to call it. So I&#8217;m gonna be recording rants for the next few weeks to figure out and fix my vocal problems. I&#8217;m ok with topic suggestions but I&#8217;m not really expecting any. Will be posting the recordings on this site until I get to setup another page for the [...]]]></description>
			<content:encoded><![CDATA[<p>..or podcast, whatever you want to call it.</p>
<p>So I&#8217;m gonna be recording rants for the next few weeks to figure out and fix my vocal problems. I&#8217;m ok with topic suggestions but I&#8217;m not really expecting any.</p>
<p>Will be posting the recordings on this site until I get to setup another page for the recordings (probably a wiki).</p>
<p><a href="http://files.bryanbibat.net/episode0-64.mp3">Episode 0 &#8211; Intro</a></p>
<p><a href="http://files.bryanbibat.net/episode1-64.mp3">Episode 1 &#8211; Pizza (pt1 of 2)</a></p>
<p><a href="http://files.bryanbibat.net/episode2-64.mp3">Episode 2 &#8211; Pizza (pt2 of 2)</a></p>
<p>&#8211;</p>
<p><strong>UPDATE</strong></p>
<p>Podcasts now posted daily at <a href="http://bry-rants.tumblr.com/">http://bry-rants.tumblr.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2011/11/30/vocal-retraining/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://files.bryanbibat.net/episode0-64.mp3" length="5403018" type="audio/mpeg" />
<enclosure url="http://files.bryanbibat.net/episode1-64.mp3" length="8877736" type="audio/mpeg" />
<enclosure url="http://files.bryanbibat.net/episode2-64.mp3" length="11893100" type="audio/mpeg" />
		</item>
		<item>
		<title>Latest Trends in Open Source Web Technologies</title>
		<link>http://blog.bryanbibat.net/2011/11/28/latest-trends-in-open-source-web-technologies/</link>
		<comments>http://blog.bryanbibat.net/2011/11/28/latest-trends-in-open-source-web-technologies/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 12:04:23 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[public talk]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1443</guid>
		<description><![CDATA[Last talk for the year (barring a possible surprise talk at Code Retreat): a talk about current trends in web technologies at DevCon UPHSD. This time it&#8217;s a 20 minute talk that I had to drag out to 40+ minutes to cover for the missing speakers. Good thing I wasn&#8217;t pressured to deliver it in [...]]]></description>
			<content:encoded><![CDATA[<p>Last talk for the year (barring a possible surprise talk at Code Retreat): a talk about current trends in web technologies at DevCon UPHSD. This time it&#8217;s a 20 minute talk that I had to drag out to 40+ minutes to cover for the missing speakers. Good thing I wasn&#8217;t pressured to deliver it in English.</p>
<p>So yeah, we had 2 missing speakers, leaving <a href="http://www.linkedin.com/pub/alvin-edwald-chan/12/3aa/a09">Alvin</a> and I to handle everything.</p>
<p>But surprisingly, this DevCon event was far better than the one in DLSU (<em>read: a more prestigious university</em>) mainly because the students were really interested in what the two of us have to say. Sure, our talks may have been boring for most of the audience, but by the time we left the campus, we&#8217;ve fielded over a dozen questions, mostly from students who approached us after the event ended.</p>
<p>In comparison, AFAIK, only one student asked a question in DLSU. </p>
<p>Pride? Apathy? I really don&#8217;t know.</p>
<p>Anyway, here&#8217;s my talk and the slides.</p>
<p><iframe width="480" height="360" src="http://www.youtube.com/embed/CmX1U0IvgOc" frameborder="0" allowfullscreen></iframe></p>
<div style="width:425px" id="__ss_10353220"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/bryanbibat/latest-trends-in-open-source-web-technologies" title="Latest Trends in Open Source Web Technologies" target="_blank">Latest Trends in Open Source Web Technologies</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/10353220" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/" target="_blank">presentations</a> from <a href="http://www.slideshare.net/bryanbibat" target="_blank">bryanbibat</a> </div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2011/11/28/latest-trends-in-open-source-web-technologies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

