<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>existence, refactored</title>
	
	<link>http://blog.bryanbibat.net</link>
	<description>With kindness comes naïveté. Courage becomes foolhardiness. And dedication has no reward.</description>
	<lastBuildDate>Sun, 05 Feb 2012 16:22:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ExistenceRefactored" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="existencerefactored" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>RailsFTW, now twice as fast!</title>
		<link>http://blog.bryanbibat.net/2012/02/06/railsftw-now-twice-as-fast/</link>
		<comments>http://blog.bryanbibat.net/2012/02/06/railsftw-now-twice-as-fast/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 16:22:11 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Follow-Up]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Fenix]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[RailsFTW]]></category>
		<category><![CDATA[RailsInstaller]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby 1.9.3]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby on Rails 3.2]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1520</guid>
		<description><![CDATA[My Game Jam post is waaay overdue but some stuff happened this week (impromptu upgrade, server migration) so I&#8217;ll only get around to post about it probably later today. Anyway, this post is just about the new version up over at RailsFTW. This experimental build is based on TCS&#8217;s patched Ruby build which boasted a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://railsftw.bryanbibat.net"><img alt="Rails FTW" class="aligncenter" src="http://www.bryanbibat.net/images/railsftw.png" /></a></p>
<p>My Game Jam post is waaay overdue but some stuff happened this week (impromptu upgrade, server migration) so I&#8217;ll only get around to post about it probably later today.</p>
<p>Anyway, this post is just about the new version up over at <a href="http://railsftw.bryanbibat.net">RailsFTW</a>. This experimental build is based on <a href="http://groups.google.com/group/thecodeshop/browse_thread/thread/29b6ef2062096902">TCS&#8217;s patched Ruby build</a> which boasted a ~200% increase in performance.</p>
<p>See it for yourself:</p>
<p><iframe width="480" height="360" src="http://www.youtube.com/embed/1pAn7xyLwW4" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/02/06/railsftw-now-twice-as-fast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RailsFTW v0.10 released, now with Ruby 1.9.3 and Rails 3.2</title>
		<link>http://blog.bryanbibat.net/2012/01/30/railsftw-v0-10-released-now-with-ruby-1-9-3-and-rails-3-2/</link>
		<comments>http://blog.bryanbibat.net/2012/01/30/railsftw-v0-10-released-now-with-ruby-1-9-3-and-rails-3-2/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 14:35:58 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Follow-Up]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[RailsFTW]]></category>
		<category><![CDATA[RailsInstaller]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby 1.9.3]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ruby on Rails 3.2]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1517</guid>
		<description><![CDATA[Still hung-over from Global Game Jam 2012 (mini-write-up later) when I went to the RailsInstaller site on a whim. Noticed that it still isn&#8217;t using Rails 3.2. So I decided to update my own to be ahead again. Hopefully this would be the last RailsFTW version (hoping Luis would be able to convince Wayne to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://railsftw.bryanbibat.net"><img alt="Rails FTW" class="aligncenter" src="http://www.bryanbibat.net/images/railsftw.png" /></a></p>
<p>Still hung-over from <a href="http://globalgamejam.org/">Global Game Jam 2012</a> (mini-write-up later) when I went to the <a href="http://railsinstaller.org/">RailsInstaller</a> site on a whim.</p>
<p>Noticed that it still isn&#8217;t using Rails 3.2. So I decided to <a href="http://railsftw.bryanbibat.net">update my own to be ahead again</a>.</p>
<p>Hopefully this would be the last RailsFTW version (hoping Luis would be able to convince Wayne to include MySQL to RailsInstaller so I won&#8217;t need to this anymore LOL).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2012/01/30/railsftw-v0-10-released-now-with-ruby-1-9-3-and-rails-3-2/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>Learn how to setup a web server pt1: Setting up a practice server</title>
		<link>http://blog.bryanbibat.net/2011/12/17/learn-how-to-setup-a-web-server-pt1-setting-up-a-practice-server/</link>
		<comments>http://blog.bryanbibat.net/2011/12/17/learn-how-to-setup-a-web-server-pt1-setting-up-a-practice-server/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 04:12:03 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1475</guid>
		<description><![CDATA[So you want to be a bit productive this holiday/winter/end-of-year break and decide to learn how to setup your own website. But for some odd reason you don&#8217;t want to settle with a free website service like WordPress or even a cPanel managed shared hosting site. Instead, you want to know how to setup your [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bryanbibat.net/images/virtualbox-manager.png" class="aligncenter" alt="VirtualBox" /></p>
<p>So you want to be a bit productive this holiday/winter/end-of-year break and decide to learn how to setup your own website. </p>
<p>But for some odd reason you don&#8217;t want to settle with a free website service like <a href="http://wordpress.com/">WordPress</a> or even a cPanel managed <a href="http://dreamhost.com/web-hosting/">shared hosting site</a>. Instead, you want to know how to setup your own web server, something like a <a href="http://www.linode.com/">Linode VPS</a> or an <a href="http://aws.amazon.com/ec2/">Amazon EC2</a> instance.</p>
<p>Luckily for you, I&#8217;m having a bit of a writer&#8217;s block and I have time to write about how to learn setting up a Linux server without having to pull out your credit card.</p>
<p><strong>What this post is all about</strong></p>
<p>In this post, we&#8217;ll just discuss how to set up a virtual server on your computer. </p>
<p>Yes, that&#8217;s right. We&#8217;re not installing a server OS on a spare machine, nor are we dual-booting: we&#8217;ll be setting up a server in your desktop, running the former inside the latter. This is <a href="http://en.wikipedia.org/wiki/Virtualization#Hardware">virtualization</a>, <a href="http://knowyourmeme.com/memes/xzibit-yo-dawg">dawg</a>.</p>
<p>We&#8217;ll be creating a server with somewhat similar specs to what you&#8217;d get if you sign up for <a href="http://prgmr.com/xen/">$8 a month at prgmr.com</a>. This simulated environment will be enough for a newbie to learn the ropes in server management.</p>
<p><strong>What you need</strong></p>
<p>Any relatively modern desktop or laptop computer will do. For this series of posts, I&#8217;ll be forgoing the use of my quad-core gaming rig and instead use my laptop (dual-core @ 2.1GHz with 3GB RAM). For the sake of the majority of the readers, I&#8217;ll be using Windows 7 as the OS though the steps will almost be the same when using Windows XP and Vista, and will still be similar even when using Linux or OSX.</p>
<p>You also need to be connected to a network, preferably one that gives out local IP addresses via a DHCP server. In other words, a home/office router. Fast internet also helps as you need to download >700MB worth of installer data.</p>
<p>As for the software, you will need to download <a href="https://www.virtualbox.org/">VirtualBox</a> and a CD image (.iso) for <a href="http://www.ubuntu.com/download/server/download">Ubuntu Server 10.04.3 Long Term Support 32-bit</a>. The VirtualBox download and installation is pretty straightforward, but for the Ubuntu Server 10.04.3, you may want to choose <a href="http://www.ubuntu.com/download/ubuntu/alternative-download#bt">downloading via BitTorrent</a> for faster download speed.</p>
<p>Unlike Linux and OSX users who already have it built in on their terminals, Windows users will also have to download an SSH client like <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTy</a>, the one that you&#8217;ll see in this tutorial. </p>
<p><span id="more-1475"></span><strong>Creating a Virtual Machine</strong></p>
<p>Once you&#8217;ve installed VirtualBox, it&#8217;s time to create a new virtual machine. Click the New button and use the following settings:</p>
<ul>
<li>Name: <em>any name</em>, I named mine &#8220;ServerTest&#8221;</li>
<li>OS Type: Linux, Version: Ubuntu</li>
<li>Base Memory Size: 256MB</li>
<li>Start-up Disk: Create new hard disk (VDI, Dynamically Allocated, 6GB)</li>
</ul>
<p>Before we start installing Ubuntu Server, we&#8217;ll have to change some settings (right-click machine -&gt; Settings, or just click the Settings button).</p>
<p><img src="http://www.bryanbibat.net/images/IDE-drive.png" class="aligncenter" alt="mount the image" /></p>
<p>In the Storage settings, select the &#8220;Empty&#8221; CD/DVD drive under the IDE Controller then set the Ubuntu Server image as the current CD by clicking the CD icon in the Attributes area on the right side.</p>
<p><img src="http://www.bryanbibat.net/images/bridged-network.png" class="aligncenter" alt="change to bridged adapter" /></p>
<p>In the Network settings, change the network adapter from NAT to Bridged Adapter. This will allow your virtual machine to get a local IP address from the router, in turn allowing it to behave as though it was a real server connected to the network.</p>
<p>Click Ok to apply the changes.</p>
<p><strong>Installing Ubuntu Server 10.04.3 LTS</strong></p>
<p>Upon starting the machine (right-click machine -&gt; Start, or just click the Start button), the system will boot the Ubuntu Server installer. The steps here are pretty straightforward:</p>
<ul>
<li>Arrow and Tab keys and move the cursor/selection while Enter key &#8220;clicks&#8221; the selected option. The Space Bar &#8220;ticks&#8221; the selected option in certain pages.</li>
<li>There are times when VirtualBox seems to &#8220;hold&#8221; the mouse pointer. You press the Right Ctrl Key to make VirtualBox &#8220;let go&#8221; of the pointer.</li>
<li>Select &#8220;English&#8221; and &#8220;Install Ubuntu Server&#8221;. This will initiate the actual installer.</li>
<li>Select &#8220;English&#8221;, &#8220;Philippines&#8221;</li>
<li>Say &#8220;No&#8221; to the Detect Keyboard Layout then simply choose &#8220;USA&#8221;, &#8220;USA&#8221;</li>
<li>Choose a host name. The default &#8220;ubuntu&#8221; is fine.</li>
<li>Choose a host name of your choice. The default &#8220;ubuntu&#8221; is fine.</li>
<li>Asia/Manila is the correct time zone (&#8220;Yes&#8221;)</li>
<li>Choose the default options for setting up the drive partitions (&#8220;Guided &#8211; use entire disk and set up LVM&#8221;, first drive, &#8220;Yes&#8221;, &#8220;6.2GB&#8221;). Select &#8220;Yes&#8221; when asked if you wish to continue.</li>
<li>Your full name can be anything. On the other hand, your user name and password are important because it&#8217;s what you use for logging in. For this tutorial, I used the username &#8220;user&#8221; and a simple password (ignore security for now).</li>
<li>Continuing our disregard for security, we skip encryption of the home folder as well as setting up automatic updates.</li>
<li>Don&#8217;t tick anything for installation. We&#8217;ll do it manually later.</li>
<li>Say &#8220;Yes&#8221; to installing GRUB.</li>
</ul>
<p>Once the whole thing is finished, select &#8220;Continue&#8221;. This will restart the machine and somehow it will boot using our freshly installed OS and skip the CD for now. Now is a good time to go to the settings and change the CD drive to &#8220;Empty&#8221; again via the &#8220;Remove disk from virtual drive&#8221; option.</p>
<p>Enter the user name and password to login.</p>
<p><img src="http://www.bryanbibat.net/images/command-line.jpg" class="aligncenter" alt="after login" /></p>
<p>Congratulations, you now have a working virtual server.</p>
<p><strong>Installing SSH server</strong></p>
<p>When we&#8217;re managing servers, we rarely have direct physical access to the machine hardware.</p>
<p>For this tutorial, we&#8217;ll use <a href="http://en.wikipedia.org/wiki/Secure_Shell">SSH</a> to manage the server pseudo-remotely. Not only will this simulate how one usually manages rented servers (as every VPS and cloud solution uses it), this will also get around the ugly and slow to respond server console that VirtualBox displays to us. </p>
<p>First step is to actually install the SSH server. Enter the following commands in the server console:</p>
<pre>$ sudo apt-get update
$ sudo apt-get install openssh-server
</pre>
<p>The first command will ask for your password. This is because <a href="http://en.wikipedia.org/wiki/Sudo"><code>sudo</code></a> tells Linux to run the command as the &#8220;super user&#8221;, hence allowing us to do things that are typically restricted from normal users. Later <code>sudo</code> prefixed commands will not require re-entering the password until the OS &#8220;forgets&#8221; you (e.g. you don&#8217;t use sudo for a certain amount of time).</p>
<p>The two commands above are used to install packages (e.g. programs or libraries) in Debian variants of Linux. The first command, <code>apt-get update</code>, updates the local database of available packages for download and installation by browsing the repositories defined in the <code>/etc/apt/sources.list</code> (the official repositories for your installed OS are enabled here by default). </p>
<p><img src="http://www.bryanbibat.net/images/apt-get-install.jpg" class="aligncenter" alt="installation prompt" /></p>
<p>The second command, <code>apt-get install</code>, installs the list of packages that you pass to it, including the packages&#8217; dependencies. As you can see here, <code>openssh-server</code> requires <code>libwrap0</code> and <code>tcpd</code>. Enter &#8220;y&#8221; to proceed with installation. (Pressing Enter without entering anything does the same thing. This is because &#8220;Y&#8221; is the default answer as denoted by its capitalization in the yes-or-no &#8220;Y/n&#8221;.)</p>
<p>Once installed, you can now remotely connect to the machine via SSH.</p>
<p><strong>Remote management via SSH</strong></p>
<p>Before you can connect to your server, you must first identify its local IP address. This should be included in the system information that you get upon logging in.</p>
<div class="wp-caption"><img src="http://www.bryanbibat.net/images/ip-address-sysinfo.jpg" class="aligncenter" alt="system information" /></p>
<p class="wp-caption-text">in this case the IP address is 192.168.1.116</p>
</div>
<p>If you didn&#8217;t take note of the IP address or if the system failed to provide it, you can still get it via the <code>ifconfig</code> command.</p>
<p><img src="http://www.bryanbibat.net/images/ifconfig.jpg" class="aligncenter" alt="ifconfig" /></p>
<p>You can now connect to it via PuTTY as long as you know the IP address.</p>
<p><img src="http://www.bryanbibat.net/images/putty2.png" class="aligncenter" alt="connection settings" /></p>
<p>Before you connect, you may want to change some settings (e.g. changing the font to Consolas) and saving the session for future use.</p>
<p><img src="http://www.bryanbibat.net/images/putty.png" class="aligncenter" alt="connection settings" /></p>
<p>Linux and OSX users can simply use the built in SSH client installed in their terminals with the following command:</p>
<p><code>$ ssh <em>username</em>@<em>ip-address</em></code></p>
<p>Upon connecting to your server, both PuTTy and the terminal client will tell you the server fingerprint and will ask if you want to proceed. Obviously you&#8217;d want to proceed. Then you&#8217;ll be asked for your login credentials. Enter them to continue.</p>
<p><img src="http://www.bryanbibat.net/images/putty3.png" class="aligncenter" alt="connected" /></p>
<p>Now you&#8217;re connected to the server via an SSH client. Not only does your terminal look prettier than the one provided by the server, you can also copy-paste things from the clipboard now.</p>
<p><strong>Learn the terminal</strong></p>
<p>For terminal newbies, it&#8217;s now a good time to learn command line commands. Go to Zed Shaw&#8217;s command line crash course <a href="http://learncodethehardway.org/cli/book/cli-crash-course.html">Controlling Your Computer From The Terminal</a> and run through the whole thing.</p>
<p>And this ends this part of the tutorial. We will leave installing web server components to the later parts.</p>
<p>To shutdown your server, you can use the <code>shutdown</code> command:</p>
<pre>$ sudo shutdown -h now</pre>
<p><a href="http://blog.bryanbibat.net/2011/12/19/learn-how-to-setup-a-web-server-pt2-installing-nginx-and-php/">Proceed to part 2: Installing Nginx and PHP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2011/12/17/learn-how-to-setup-a-web-server-pt1-setting-up-a-practice-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Game of Life Wallpaper published to Android Marketplace</title>
		<link>http://blog.bryanbibat.net/2011/12/11/game-of-life-wallpaper-published-to-android-marketplace/</link>
		<comments>http://blog.bryanbibat.net/2011/12/11/game-of-life-wallpaper-published-to-android-marketplace/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 14:46:03 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Follow-Up]]></category>
		<category><![CDATA[Site News]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[published app]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1470</guid>
		<description><![CDATA[That little app/wallpaper we made at the code retreat? I&#8217;ve published it and it&#8217;s now free for download at the Android Marketplace. At the moment it&#8217;s not properly indexed in the Marketplace yet so searching &#8220;Game of Life Wallpaper&#8221; won&#8217;t return the link. A workaround is to search it using the search terms &#8220;code retreat&#8220;.]]></description>
			<content:encoded><![CDATA[<p><img alt="screenshot of wallpaper" src="http://www.bryanbibat.net/images/device-gol-ss.png" class="aligncenter"></p>
<p>That little app/wallpaper we made at <a href="http://blog.bryanbibat.net/2011/12/05/code-retreat-baguio-2011/">the code retreat</a>? I&#8217;ve published it and it&#8217;s now <a href="https://market.android.com/details?id=net.bryanbibat.apps"><em>free for download at the Android Marketplace</em></a>.</p>
<p>At the moment it&#8217;s not properly indexed in the Marketplace yet so searching &#8220;Game of Life Wallpaper&#8221; won&#8217;t return the link. A workaround is to search it using the search terms &#8220;<em>code retreat</em>&#8220;.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2011/12/11/game-of-life-wallpaper-published-to-android-marketplace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rubber Ducking</title>
		<link>http://blog.bryanbibat.net/2011/12/09/rubber-ducking/</link>
		<comments>http://blog.bryanbibat.net/2011/12/09/rubber-ducking/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 12:34:45 +0000</pubDate>
		<dc:creator>Bry</dc:creator>
				<category><![CDATA[Brain Dumps]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[The Pragmatic Programmer]]></category>

		<guid isPermaLink="false">http://blog.bryanbibat.net/?p=1465</guid>
		<description><![CDATA[One day after writing the previous post, I noticed two things: I forgot to add the link for the term &#8220;rubber duck&#8221;, and I never posted about &#8220;rubber ducking&#8221; before I&#8217;ve fixed the first so it&#8217;s time to fix the second. Still finding it weird that I haven&#8217;t done it yet in the 2+ years [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bryanbibat.net/images/rubber_duck.jpg" class="aligncenter" /></p>
<p>One day after writing the previous post, I noticed two things:</p>
<ul>
<li>I forgot to add the link for the term &#8220;rubber duck&#8221;, and</li>
<li>I never posted about &#8220;rubber ducking&#8221; before</li>
</ul>
<p>I&#8217;ve fixed the first so it&#8217;s time to fix the second. Still finding it weird that I haven&#8217;t done it yet in the 2+ years this blog has been up, though&#8230;</p>
<p>Anyway, &#8220;rubber ducking&#8221; is a simple mind hack popularized by <a href="http://pragprog.com/the-pragmatic-programmer">The Pragmatic Programmer</a>. Instead of committing copyright infringement by copy-pasting what the book says about it (all <em>3 paragraphs</em>), I&#8217;ll just go with <a href="http://c2.com/cgi/wiki?RubberDucking">Wiki Wiki&#8217;s take on the topic</a>.</p>
<blockquote><p>Place a rubber duck on your monitor and describe your problems to it. There&#8217;s something magical about stating your problems aloud that makes the solution more clear. </p></blockquote>
<p>So yeah, my MO at hackathons is to either code something totally unexpected, or just float around &#8220;magically&#8221; solving problems by being a sounding board.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bryanbibat.net/2011/12/09/rubber-ducking/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss><!-- Dynamic page generated in 0.657 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-02-06 00:22:30 -->

