<?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>Kalenyuk Technical Blog</title>
	<atom:link href="http://www.kalenyuk.com.ua/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kalenyuk.com.ua</link>
	<description>Articles about Magento, Varnish, PHP, MySQL</description>
	<lastBuildDate>Mon, 30 Jan 2012 14:49:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Magento hebrew full text search</title>
		<link>http://www.kalenyuk.com.ua/magento-hebrew-full-text-search-209.html</link>
		<comments>http://www.kalenyuk.com.ua/magento-hebrew-full-text-search-209.html#comments</comments>
		<pubDate>Mon, 30 Jan 2012 14:43:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[hebrew]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=209</guid>
		<description><![CDATA[Proper using hebrew in Magento needs some tuning. I had a problem to find such phrases as: &#8216;ביג אפל&#8217; or &#8216;אפל&#8217;. I have used MySQL 5.1.49. The minimum and maximum lengths of words to be indexed are defined by the &#8216;ft_min_word_len&#8216; and &#8216;ft_max_word_len&#8216; system variables. SQL: &#8216;SHOW VARIABLES;&#8217; I have found that &#8216;ft_min_word_len&#8217; was 4. [...]]]></description>
			<content:encoded><![CDATA[<p>Proper using <strong>hebrew in Magento</strong> needs some tuning. I had a problem to find such phrases as: &#8216;ביג אפל&#8217; or &#8216;אפל&#8217;. I have used MySQL 5.1.49. The minimum and maximum lengths of words to be indexed are defined by the &#8216;<strong>ft_min_word_len</strong>&#8216; and &#8216;<strong>ft_max_word_len</strong>&#8216; system variables.<br />
SQL: &#8216;SHOW VARIABLES;&#8217; I have found that &#8216;ft_min_word_len&#8217; was 4.<br />
I have changed it to 2 in &#8216;<strong>/etc/mysql/my.cnf</strong>&#8216; in [mysqld].</p>
<p><span id="more-209"></span></p>
<p>More information can be found here:</p>
<p>http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html</p>
<p>Then I reindexed the table with: &#8216;<strong>REPAIR TABLE</strong> catalogsearch_fulltext&#8217;.<br />
More details:</p>
<p>http://dev.mysql.com/doc/refman/5.0/en/repair-table.html</p>
<p>QUERY (native <strong>Magento</strong> query):</p>
<p>SELECT 7 AS `query_id`, `s`.`product_id`, MATCH (s.data_index) AGAINST (&#8216;ביג אפל&#8217; IN BOOLEAN MODE) AS `relevance`, s.data_index<br />
FROM `catalogsearch_fulltext` AS `s`<br />
WHERE (s.store_id = 2) AND (MATCH (s.data_index) AGAINST (&#8216;ביג אפל&#8217; IN BOOLEAN MODE));</p>
<p>RESULT:</p>
<p>| 7 | 2 | 0 | Name 1|לבן|Enabled|None|ביג אפל|ביג אפל|ביג אפל|33|1 |</p>
<p>| 7 | 1 | 0 | Name 2|Enabled|כחול|None|ביג אפל|ביג אפל|ביג אפל|25|1 |</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/magento-hebrew-full-text-search-209.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript get filename from path</title>
		<link>http://www.kalenyuk.com.ua/javascript-get-filename-from-path-200.html</link>
		<comments>http://www.kalenyuk.com.ua/javascript-get-filename-from-path-200.html#comments</comments>
		<pubDate>Mon, 11 Oct 2010 09:11:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=200</guid>
		<description><![CDATA[Initial conditions: var fullPath = 'folder1/folder2/folder3/filename.jpg'; What need get: filename.jpg Code example: var fileName = ''; if (fullPath) { var startIndex = (fullPath.indexOf('\\') &#62;= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/')) ; var fileName = fullPath.substring(startIndex); if (fileName.indexOf('\\') === 0 &#124;&#124; fileName.indexOf('/') === 0) { fileName = fileName.substring(1); } }]]></description>
			<content:encoded><![CDATA[<p>Initial conditions:</p>
<blockquote>
<pre>
var fullPath = 'folder1/folder2/folder3/filename.jpg';
</pre>
</blockquote>
<p>What need get:</p>
<blockquote>
<pre>
filename.jpg
</pre>
</blockquote>
<p><span id="more-200"></span><br />
Code example:</p>
<blockquote>
<pre>
var fileName = '';
if (fullPath) {
    var startIndex = (fullPath.indexOf('\\') &gt;= 0
        ? fullPath.lastIndexOf('\\')
        : fullPath.lastIndexOf('/'))
    ;
    var fileName = fullPath.substring(startIndex);
    if (fileName.indexOf('\\') === 0 || fileName.indexOf('/') === 0) {
        fileName = fileName.substring(1);
    }
}
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/javascript-get-filename-from-path-200.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtualbox windows xp</title>
		<link>http://www.kalenyuk.com.ua/virtualbox-windows-xp-166.html</link>
		<comments>http://www.kalenyuk.com.ua/virtualbox-windows-xp-166.html#comments</comments>
		<pubDate>Tue, 21 Sep 2010 20:13:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[Ubuntu 9.10]]></category>
		<category><![CDATA[Virtualbox]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=166</guid>
		<description><![CDATA[I have faced the problem installing Windows XP on Virtualbox. I will describe in details installing process from CD. Environment: Ubuntu 9.10 i386, Virtualbox 3.2.8-64453. The first step is download from official site deb package and install it. After installing Virtualbox launch it. You will see the following: Press &#8220;New&#8221; button. You will see the [...]]]></description>
			<content:encoded><![CDATA[<p>I have faced the problem installing <strong>Windows XP</strong> on <strong>Virtualbox</strong>. I will describe in details installing process from CD. Environment: <strong>Ubuntu 9.10</strong> i386, Virtualbox 3.2.8-64453.</p>
<p><span id="more-166"></span></p>
<p>The first step is download from official site deb package and install it. After installing Virtualbox launch it. You will see the following:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s01.png"><img class="alignnone size-full wp-image-171" title="s0" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s01.png" alt="the first during install Windows XP on Virtualbox" width="500" height="357" /></a></p>
<p>Press &#8220;New&#8221; button. You will see the following:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s11.png"><img class="alignnone size-full wp-image-174" title="s1" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s11.png" alt="" width="500" height="326" /></a></p>
<p>Press &#8216;Next&#8217;. You will see the following:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s2.png"><img class="alignnone size-full wp-image-176" title="s2" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s2.png" alt="the third step during installing Windows XP on Virtualbox" width="500" height="328" /></a></p>
<p>Type &#8220;Window XP&#8221; or another and which sounds better and press &#8220;Next&#8221;.</p>
<p>You will see the following:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s4.png"><img class="alignnone size-full wp-image-177" title="s4" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s4.png" alt="the fourth step during installing Windows XP on Virtualbox" width="500" height="325" /></a></p>
<p>I prefer to use 1024 Mb for Windows XP. But it&#8217;s up to you to decide. I don&#8217;t recommend use less then 512 Mb.</p>
<p>Then you fill see the following:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s51.png"><img class="alignnone size-full wp-image-181" title="s5" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s51.png" alt="" width="500" height="328" /></a></p>
<p>On the next three screenshots press &#8220;Next&#8221;:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s6.png"><img class="alignnone size-full wp-image-183" title="s6" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s6.png" alt="" width="500" height="319" /></a></p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s7.png"><img class="alignnone size-full wp-image-184" title="s7" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s7.png" alt="" width="500" height="320" /></a></p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s8.png"><img class="alignnone size-full wp-image-185" title="s8" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s8.png" alt="" width="500" height="321" /></a></p>
<p>On the following two screenshots press &#8220;Finish&#8221;.</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s10.png"><img class="alignnone size-full wp-image-188" title="s10" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s10.png" alt="" width="500" height="319" /></a></p>
<p>New virtual machine was created. I can see this on the following screenshot (&#8220;Windows XP&#8221; virtual machine in the list).</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s12.png"><img class="alignnone size-full wp-image-190" title="s12" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s12.png" alt="" width="500" height="367" /></a></p>
<p>Select &#8220;Windows XP&#8221; vitrual machine and press &#8220;Settings&#8221;. You will see the following:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s13.png"><img class="alignnone size-full wp-image-193" title="s13" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s13.png" alt="" width="500" height="325" /></a></p>
<p>Press &#8220;Next&#8221;. On the next screenshot select your CD-ROM. Also you can use .iso image here. Then press enter.</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s14.png"><img class="alignnone size-full wp-image-194" title="s14" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s14.png" alt="" width="500" height="324" /></a></p>
<p>Press &#8220;Finish&#8221; on the screenshot below.</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s15.png"><img class="alignnone size-full wp-image-195" title="s15" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/09/s15.png" alt="" width="500" height="325" /></a></p>
<p>Then you should install Windows XP. It&#8217;s almost all you need to use <strong>Windows XP</strong> on Virtualbox.</p>
<p>Only one step:<em> I strongly recommend</em> you press F8 (load in safe mode) during loading Windows XP and install &#8220;<em>Guest additions</em>&#8220;. Good luck with this issue <img src='http://www.kalenyuk.com.ua/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/virtualbox-windows-xp-166.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fatal error: Method Varien_Object::__tostring() cannot take arguments</title>
		<link>http://www.kalenyuk.com.ua/fatal-error-method-varien_object-158.html</link>
		<comments>http://www.kalenyuk.com.ua/fatal-error-method-varien_object-158.html#comments</comments>
		<pubDate>Tue, 25 May 2010 17:49:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Varien_Object]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=158</guid>
		<description><![CDATA[I have got an error for Magento 1.3.1.1 and PHP 5.3.2: Fatal error: Method Varien_Object::__tostring() cannot take arguments PHP 5.3.2-1ubuntu4 with Suhosin-Patch Magento version: 1.3.1.1 Below solution of this issue: 1. Open lib/Varien/Object.php:484 and replace public function __toString(array $arrAttributes = array(), $valueSeparator=',') with public function __invoke(array $arrAttributes = array(), $valueSeparator=',') 2. Open app/code/core/Mage/Core/Controller/Request/Http.php:199 and replace [...]]]></description>
			<content:encoded><![CDATA[<p>I have got an error for <strong>Magento</strong> 1.3.1.1 and <strong>PHP</strong> 5.3.2:<br />
Fatal error: Method <strong>Varien_Object</strong>::__tostring() cannot take arguments</p>
<blockquote>
<pre>PHP 5.3.2-1ubuntu4 with Suhosin-Patch
Magento version: 1.3.1.1
</pre>
</blockquote>
<p>Below solution of this issue:</p>
<p><span id="more-158"></span><span style="color: #008000;">1. Open lib/Varien/Object.php:484 and replace</span></p>
<blockquote>
<pre>public function __toString(array $arrAttributes = array(),
$valueSeparator=',')
</pre>
</blockquote>
<p>with</p>
<blockquote>
<pre>public function  __invoke(array  $arrAttributes = array(),
$valueSeparator=',')
</pre>
</blockquote>
<p><span style="color: #008000;">2. Open app/code/core/Mage/Core/Controller/Request/Http.php:199 and replace</span></p>
<blockquote>
<pre>$host = split(':', $_SERVER['HTTP_HOST']);
</pre>
</blockquote>
<p>with</p>
<blockquote>
<pre>$host = explode(':', $_SERVER['HTTP_HOST']);
</pre>
</blockquote>
<p>Split has been DEPRECATED as of PHP 5.3.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/fatal-error-method-varien_object-158.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento new theme for admin part</title>
		<link>http://www.kalenyuk.com.ua/magento-theme-for-admin-part-133.html</link>
		<comments>http://www.kalenyuk.com.ua/magento-theme-for-admin-part-133.html#comments</comments>
		<pubDate>Mon, 19 Apr 2010 20:17:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[admin theme]]></category>
		<category><![CDATA[new theme]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=133</guid>
		<description><![CDATA[Magento allows customize admin theme. It&#8217;s like new theme for frontend but needs specific configuration in config.xml. Below is an example: &#60;?xml version="1.0" encoding="UTF-8"?&#62; &#60;config&#62; &#60;modules&#62; &#60;YOURMODULE_Adminhtml&#62; &#60;version&#62;0.0.1&#60;/version&#62; &#60;/YOURMODULE_Adminhtml&#62; &#60;/modules&#62; &#60;stores&#62; &#60;admin&#62; &#60;design&#62; &#60;theme&#62; &#60;default&#62;YOURADMINTHEME&#60;/default&#62; &#60;/theme&#62; &#60;/design&#62; &#60;/admin&#62; &#60;/stores&#62; &#60;/config&#62;]]></description>
			<content:encoded><![CDATA[<p><strong>Magento</strong> allows customize admin theme. It&#8217;s like new theme for frontend but needs specific configuration in <strong>config.xml</strong>.<br />
Below is an example:</p>
<blockquote>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;config&gt;
    &lt;modules&gt;
        &lt;YOURMODULE_Adminhtml&gt;
            &lt;version&gt;0.0.1&lt;/version&gt;
        &lt;/YOURMODULE_Adminhtml&gt;
    &lt;/modules&gt;
    &lt;stores&gt;
       &lt;admin&gt;
           &lt;design&gt;
               &lt;theme&gt;
                   &lt;default&gt;YOURADMINTHEME&lt;/default&gt;
               &lt;/theme&gt;
           &lt;/design&gt;
       &lt;/admin&gt;
    &lt;/stores&gt;
&lt;/config&gt;</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/magento-theme-for-admin-part-133.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Illumination options for configurable products in Magento</title>
		<link>http://www.kalenyuk.com.ua/illumination-options-for-configurable-products-103.html</link>
		<comments>http://www.kalenyuk.com.ua/illumination-options-for-configurable-products-103.html#comments</comments>
		<pubDate>Fri, 16 Apr 2010 12:25:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[magento configurable product]]></category>
		<category><![CDATA[magento media]]></category>
		<category><![CDATA[new image type]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=103</guid>
		<description><![CDATA[The following code allows you illuminate options for configurable products in Magento. The steps are: 0. Create configurable product with &#8220;size&#8221;, &#8220;color&#8221;, &#8220;manufacturer&#8221; options. 1. Create new field in the table &#8220;catalog_eav_attribute&#8221;: ALTER TABLE `catalog_eav_attribute` ADD `configurable_option_type` TINYINT( 1 ) UNSIGNED NOT NULL 2. Open method Mage_Adminhtml_Catalog_Product_AttributeController::saveAction and add verification: //CONFIGURABLE OPTION TYPES if (!isset($data['configurable_option_type'])) [...]]]></description>
			<content:encoded><![CDATA[<p>The following code allows you illuminate options for<strong> configurable products</strong> in <strong>Magento</strong>.</p>
<p>The steps are:</p>
<p>0. Create <strong>configurable product</strong> with &#8220;size&#8221;, &#8220;color&#8221;, &#8220;manufacturer&#8221; options.</p>
<p>1. Create new field in the table &#8220;catalog_eav_attribute&#8221;:</p>
<blockquote>
<pre>ALTER TABLE `catalog_eav_attribute`
ADD `configurable_option_type` TINYINT( 1 ) UNSIGNED NOT NULL</pre>
</blockquote>
<p>2. Open method Mage_Adminhtml_Catalog_Product_AttributeController::saveAction<br />
and add verification:</p>
<blockquote>
<pre>//CONFIGURABLE OPTION TYPES
if (!isset($data['configurable_option_type'])) {
    $data['configurable_option_type'] = 0;
}</pre>
</blockquote>
<p><span id="more-103"></span><br />
3. Open method Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main::_prepareForm<br />
and add the following:</p>
<blockquote>
<pre>//OPTION TYPES
$optionTypes = array (
    '0' =&gt; '',
    '1' =&gt; 'Type1',
    '2' =&gt; 'Type2',
    '3' =&gt; 'Type3',
);
$fieldset-&gt;addField('configurable_option_type', 'select', array(
    'name' =&gt; 'configurable_option_type',
    'label' =&gt; Mage::helper('catalog')-&gt;__('Configurable Option Types'),
    'values' =&gt; $optionTypes,
), 'apply_to');</pre>
</blockquote>
<p>4. Open /app/design/adminhtml/default/default/template/catalog/product/attribute/js.phtml<br />
and change method &#8220;checkIsConfigurableVisibility&#8221;:</p>
<blockquote>
<pre>function checkIsConfigurableVisibility()
{
    if (!$('is_configurable') || !$('is_global') || !$('frontend_input')) return;
    if ($F('is_global')==1 &amp;&amp; $F('frontend_input')=='select') {
        setRowVisibility('is_configurable', true);
        //CONFIGURABLE OPTION TYPES
        setRowVisibility('configurable_option_type', true);
    } else {
        setRowVisibility('is_configurable', false);
        //CONFIGURABLE OPTION TYPES
        setRowVisibility('configurable_option_type', false);
    }
}</pre>
</blockquote>
<p>5. Open /app/design/frontend/base/default/template/catalog/product/view/type/options/configurable.phtml and add the following:</p>
<blockquote>
<pre>//CONFIGURABLE OPTION TYPE
$productAttribute = $_attribute-&gt;getData('product_attribute');
$optionType = (int) $productAttribute-&gt;getData('configurable_option_type');
$attributeId = $productAttribute-&gt;getData('attribute_id');
$attributeCode = $productAttribute-&gt;getData('attribute_code');
$selectId = 'attribute'.$attributeId;
//javascript
Event.observe(window, 'load', function() {
    var selectId = "";
    var attributeCode = "";
    if (attributeCode == "manufacturer") {
        $(selectId).style.color = 'green';
    }
    if (attributeCode == "color") {
        $(selectId).style.color = 'red';
    }
    if (attributeCode == "size") {
        $(selectId).style.color = 'blue';
    }
});</pre>
</blockquote>
<p>Result:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/04/configurable-product-options.png"><img class="alignnone size-full wp-image-105" title="configurable-product-options" src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/04/configurable-product-options.png" alt="Illumination options for configurable products" width="650" height="344" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/illumination-options-for-configurable-products-103.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add new image type for product in Magento</title>
		<link>http://www.kalenyuk.com.ua/add-new-image-for-product-in-magento-81.html</link>
		<comments>http://www.kalenyuk.com.ua/add-new-image-for-product-in-magento-81.html#comments</comments>
		<pubDate>Wed, 14 Apr 2010 15:54:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento media gallery]]></category>
		<category><![CDATA[Magento product]]></category>
		<category><![CDATA[new image type]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=81</guid>
		<description><![CDATA[The goal of this article is to show to add new image type to product in Magento. By default Magento has 3 type of images: Base image Small image Thumbnail image Typically these types of images is sufficient. But sometimes it becomes necessary to add a new type of image. Add a new type of [...]]]></description>
			<content:encoded><![CDATA[<p>The goal of this article is to show to add <strong>new image type</strong> to product in <strong>Magento</strong>.</p>
<p>By default <strong>Magento has 3 type of images</strong>:</p>
<blockquote>
<ol>
<li>Base 	image</li>
<li>Small 	image</li>
<li>Thumbnail 	image</li>
</ol>
</blockquote>
<p>Typically these types of images is sufficient. But sometimes it becomes necessary to add a new type of image. Add a new type of image is easy as Magento in the gallery displays all the attributes for which the attribute &#8216;input_type&#8217; equals &#8216;media_image&#8217;.</p>
<p><span id="more-81"></span></p>
<p>Code, described below adds a new type of image «small_image_two». It should be executed as an SQL update.</p>
<blockquote>
<pre>&lt;?php
$installer = $this;
$installer-&gt;startSetup();
$this-&gt;addAttribute(
    'catalog_product',
    'small_image_two',
    array (
        'group'             =&gt; 'Images',
        'type'              =&gt; 'varchar',
        'frontend'          =&gt; 'catalog/product_attribute_frontend_image',
        'label'             =&gt; 'Small Image Two',
        'input'             =&gt; 'media_image',
        'class'             =&gt; '',
        'source'            =&gt; '',
        'global'            =&gt; Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'visible'           =&gt; true,
        'required'          =&gt; false,
        'user_defined'      =&gt; false,
        'default'           =&gt; '',
        'searchable'        =&gt; false,
        'filterable'        =&gt; false,
        'comparable'        =&gt; false,
        'visible_on_front'  =&gt; false,
        'unique'            =&gt; false,
    )
);
$installer-&gt;endSetup();
</pre>
</blockquote>
<p>After adding the attribute you will see the following:</p>
<p><a href="http://www.kalenyuk.com.ua/wp-content/uploads/2010/04/new-image-type.png"><img src="http://www.kalenyuk.com.ua/wp-content/uploads/2010/04/new-image-type.png" alt="New image type for product in Magento" title="new-image-type" width="976" height="426" class="alignnone size-full wp-image-98" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/add-new-image-for-product-in-magento-81.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Magento performance optimization with Varnish cache</title>
		<link>http://www.kalenyuk.com.ua/magento-performance-optimization-with-varnish-cache-47.html</link>
		<comments>http://www.kalenyuk.com.ua/magento-performance-optimization-with-varnish-cache-47.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 09:34:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Varnish]]></category>
		<category><![CDATA[magento module]]></category>
		<category><![CDATA[magento optimization]]></category>
		<category><![CDATA[magento varnish]]></category>
		<category><![CDATA[varnish cache]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=47</guid>
		<description><![CDATA[OVERVIEW After installing Magento on hosting you probably have a desire to optimize its work. Google offers solutions, which consist on using one of the following options: installing higher-performance hardware, correction for mysql/php configuration, using PHP accelerators, accelerate downloads JS and CSS, the correction assignment expires date for content, customization Magento core files to fit [...]]]></description>
			<content:encoded><![CDATA[<h3 style="text-align: justify;">OVERVIEW</h3>
<p style="text-align: justify;">After installing <strong>Magento</strong> on hosting you probably have a desire to optimize its work.</p>
<p style="text-align: justify;">Google offers solutions, which consist on using one of the following options: installing higher-performance hardware, correction for mysql/php configuration, using PHP accelerators, accelerate downloads JS and CSS, the correction assignment expires date for content, customization Magento core files to fit your needs.</p>
<p style="text-align: justify;">Varien released a book titled &#8220;Enterprise Edition Whitepaper High Performance eCommerce&#8221; which explains the above methods of  <strong>Magento optimization</strong>. I recommend reading this book and use the described methods of optimization.</p>
<p style="text-align: justify;">I propose another new approach for the optimization of <strong>Magento</strong>, which was not described in the Internet before. I propose to use Varnish for caching pages.</p>
<p style="text-align: justify;">What is <strong>Varnish</strong> you can read <a title="Varnish Caching" href="http://www.kalenyuk.com.ua/varnish-cache-1.html" target="_blank">here</a>. Varnish handles the request, looks in the cache this page and, if such page is found, returns it. If the page is not found in the cache &#8211; a request sent to Apache. This approach allows you to create any number of dynamic pages.</p>
<p style="text-align: justify;">
<p><span id="more-47"></span></p>
<h3 style="text-align: justify;">EXAMPLE</h3>
<p style="text-align: justify;">On the main page you can see poll module. Assume that we have 4 different polls. I propose randomly create 100 different copies of the main page. When user loads main page Varnish gives random copy of the main page. The probability of withdrawal of one of the 4 polls close to 25%.</p>
<p style="text-align: justify;">This caching will give us the static pages to users who simply browse the site and did not do such actions as a vote, adding product to cart, login, etc. Majority of these users, so using this approach can significantly reduce the load on Apache. Once a user has voted, logged, added product to cart, etc. Varnish cache turn off.</p>
<h3>INSTALLATION</h3>
<p>Download the latest version of Magento and install it.</p>
<p>Create folder <span style="color: #008000;">app/code/local/Varnish</span>.</p>
<p>Create file <span style="color: #008000;">app/etc/modules/Varnish.xml</span> :</p>
<blockquote>
<pre>&lt;?xml version="1.0"?&gt;
&lt;config&gt;
  &lt;modules&gt;
    &lt;Varnish&gt;
      &lt;active&gt;true&lt;/active&gt;
      &lt;codePool&gt;local&lt;/codePool&gt;
    &lt;/Varnish&gt;
  &lt;/modules&gt;
&lt;/config&gt;</pre>
</blockquote>
<p><span style="color: #008000;">app/code/local/Varnish/controllers/IndexController.php</span> :</p>
<blockquote>
<pre>&lt;?php
class Varnish_IndexController extends Mage_Core_Controller_Front_Action
{
 public function purgeallAction() { }
}</pre>
</blockquote>
<p><span style="color: #008000;">app/code/local/Varnish/etc/config.xml</span> :</p>
<blockquote>
<pre>&lt;?xml version="1.0"?&gt;
&lt;config&gt;
    &lt;modules&gt;
       &lt;Varnish&gt;
         &lt;version&gt;0.0.1&lt;/version&gt;
       &lt;/Varnish&gt;
    &lt;/modules&gt;
    &lt;global&gt;
        &lt;models&gt;
            &lt;varnish&gt;
              &lt;class&gt;Varnish_Model&lt;/class&gt;
              &lt;resourceModel&gt;varnish_mysql4&lt;/resourceModel&gt;
            &lt;/varnish&gt;
        &lt;/models&gt;
        &lt;events&gt;
            &lt;http_response_send_before&gt;
                &lt;observers&gt;
                    &lt;varnish&gt;
                        &lt;type&gt;singleton&lt;/type&gt;
                        &lt;class&gt;varnish/observer&lt;/class&gt;
                        &lt;method&gt;varnish&lt;/method&gt;
                    &lt;/varnish&gt;
                &lt;/observers&gt;
            &lt;/http_response_send_before&gt;
                &lt;application_clean_cache&gt;
                    &lt;observers&gt;
                        &lt;varnish&gt;
                            &lt;type&gt;singleton&lt;/type&gt;
                            &lt;class&gt;varnish/observer&lt;/class&gt;
                            &lt;method&gt;purgeAll&lt;/method&gt;
                        &lt;/varnish&gt;
                    &lt;/observers&gt;
                &lt;/application_clean_cache&gt;
        &lt;/events&gt;
    &lt;/global&gt;
    &lt;frontend&gt;
       &lt;routers&gt;
           &lt;varnish&gt;
               &lt;use&gt;standard&lt;/use&gt;
               &lt;args&gt;
                   &lt;module&gt;Varnish&lt;/module&gt;
                   &lt;frontName&gt;varnish&lt;/frontName&gt;
               &lt;/args&gt;
           &lt;/varnish&gt;
       &lt;/routers&gt;
    &lt;/frontend&gt;
    &lt;default&gt;
       &lt;varnish&gt;
           &lt;purgeall_key&gt;
               &lt;key&gt;#Fj1nzljh&lt;/key&gt;
           &lt;/purgeall_key&gt;
       &lt;/varnish&gt;
    &lt;/default&gt;
&lt;/config&gt;</pre>
</blockquote>
<p><span style="color: #008000;">app/code/local/Varnish/Model/Observer.php</span> :</p>
<blockquote>
<pre>/**
 * Varnish Observer model
 *
 * @category   Varnish
 * @package    Varnish
 */
class Varnish_Model_Observer
{
    private $_request = null;

    public function __construct()
    {

    }

    private function getSecureKey()
    {
        return Mage::getStoreConfig('varnish/purgeall_key/key');
    }

    public function getCookie()
    {
        return Mage::app()-&gt;getCookie();
    }

    public function varnish($observer)
    {
        if ($this-&gt;isSetNoCacheStable()) {
            return false;
        }

        if ($this-&gt;pollVerification()) {
            $this-&gt;setNoCacheStable();
            return false;
        }

        if ($this-&gt;quoteHasItems()) {
            $this-&gt;turnOffVarnishCache();
            return false;
        }

        if ($this-&gt;customerIsLogged()) {
            $this-&gt;turnOffVarnishCache();
            return false;
        }

        $this-&gt;turnOnVarnishCache();
    }

    public function turnOffVarnishCache()
    {
        $this-&gt;getCookie()-&gt;set('nocache', 1);
    }

    public function turnOnVarnishCache()
    {
        $this-&gt;getCookie()-&gt;delete('nocache');
    }

    public function quoteHasItems()
    {
        $quote = Mage::getSingleton('checkout/session')-&gt;getQuote();
        if ($quote instanceof Mage_Sales_Model_Quote &amp;&amp; $quote-&gt;hasItems()) {
            return true;
        }
    }

    public function customerIsLogged()
    {
        $customerSession = Mage::getSingleton('customer/session');
        if ($customerSession instanceof Mage_Customer_Model_Session  &amp;&amp;
            $customerSession-&gt;isLoggedIn()) {
            return true;
        }
    }

    public function pollVerification()
    {
        $justVotedPollId = (int) Mage::getSingleton('core/session')-&gt;getJustVotedPoll();
        if ($justVotedPollId) {
            return true;
        }
    }

    public function setNoCacheStable()
    {
        $this-&gt;getCookie()-&gt;set('nocache_stable', 1, 0);
    }

    public function isSetNoCacheStable()
    {
        return $this-&gt;getCookie()-&gt;get('nocache_stable') === 1;
    }

    public function purgeAll()
    {
        try {
            $url = Mage::getBaseUrl().'varnish/index/purgeall/key/'.$this-&gt;getSecureKey().'/';
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PURGE');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            $responseBody = curl_exec($ch);
            curl_close ($ch);
        } catch (Exception $e) {
            Mage::log($e-&gt;getFile().' '.$e-&gt;getLine().' '.$e-&gt;getMessage());
        }
    }
}</pre>
</blockquote>
<p><span style="color: #008000;">sudo vim /etc/varnish.vcl</span> :</p>
<blockquote>
<pre>backend apache {
  .host = "127.0.0.1";
  .port = "8088";
  .max_connections = 30;
}

acl purge {
  "localhost";
}

sub vcl_recv {
  #purge all
  if (req.request == "PURGE") {
    if (!client.ip ~ purge) {
      error 405 "Not allowed.";
    }
    if (req.url ~ "varnish/index/purgeall/key/#Fj1nzljh") {
      purge_hash( ".*" );
    }
  }

  #described below need to create random "DynamicPage" value; this functionallity we use
  #to create several caches for 1 dynamic page.
  #for example, "int i = rand() % 2 + 1;" means that we have 2 different copies of one dynamic page
  C{
   #include
   #include
   char buffer [33];
   int i = rand() % 10 + 1;
   sprintf(buffer, "%d", i);
   VRT_SetHdr(sp, HDR_REQ, "\014DynamicPage:", buffer, vrt_magic_string_end);
  }C

  if (req.request != "GET" &amp;&amp;
  req.request != "HEAD" &amp;&amp;
  req.request != "PUT" &amp;&amp;
  req.request != "POST" &amp;&amp;
  req.request != "TRACE" &amp;&amp;
  req.request != "OPTIONS" &amp;&amp;
  req.request != "DELETE") {
    return (pipe);
  }

  # do not cache POST requests
  if (req.request == "POST") {
    return (pipe);
  }

  #we should not cache any page for Magento backend
  if (req.request == "GET" &amp;&amp; (req.url ~ "^/admin") || req.url ~ "^/index.php/admin") {
    return (pass);
  }

  #we should not cache any page for checkout and customer modules
  if (req.request == "GET" &amp;&amp; (req.url ~ "^/checkout" || req.url ~ "^/customer")) {
    return (pass);
  }

  #do not cache till session end
  if (req.http.cookie ~ "nocache_stable") {
    return (pass);
  }

  #unique identifier witch tell Varnish use cache or not
  if (req.http.cookie ~ "nocache") {
    return (pass);
  }

  if (req.request == "GET" &amp;&amp; (req.url ~ "\.(png|jpg|jpeg|gif)$" || req.url ~ "print.css")) {
    lookup;
  }

  #Even though there are few possible values for Accept-Encoding, Varnish treats
  #them literally rather than semantically, so even a small difference which makes
  #no difference to the backend can reduce cache efficiency by making Varnish cache
  #too many different versions of an object.
  #http://varnish.projects.linpro.no/wiki/FAQ/Compression
  if (req.http.Accept-Encoding) {
    if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
      # No point in compressing these
      remove req.http.Accept-Encoding;
    } elsif (req.http.Accept-Encoding ~ "gzip") {
      set req.http.Accept-Encoding = "gzip";
    } elsif (req.http.Accept-Encoding ~ "deflate") {
      set req.http.Accept-Encoding = "deflate";
    } else {
      # unkown algorithm
      remove req.http.Accept-Encoding;
    }
  }

  return (lookup);
}

sub vcl_pipe {
  # Note that only the first request to the backend will have
  # X-Forwarded-For set.  If you use X-Forwarded-For and want to
  # have it set for all requests, make sure to have:
  # set req.http.connection = "close";
  # here.  It is not set by default as it might break some broken web
  # applications, like IIS with NTLM authentication.
  return (pipe);
}

sub vcl_pass {
  return (pass);
}

sub vcl_hit {
  if (!obj.cacheable) {
    return (pass);
  }
  return (deliver);
}

sub vcl_miss {
  return (fetch);
}

sub vcl_fetch {
  return (deliver);
}

sub vcl_deliver {

  if (obj.hits &gt; 0) {
    set resp.http.X-Cache = "HIT";
  } else {
    set resp.http.X-Cache = "MISS";
  }
}

sub vcl_error {
 set obj.http.Content-Type = "text/html; charset=utf-8";
 synthetic {"
 &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
 &lt;html&gt;
 &lt;head&gt;
 &lt;title&gt;"} obj.status " " obj.response {"&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
 &lt;h1&gt;Error "} obj.status " " obj.response {"&lt;/h1&gt;
 &lt;p&gt;"} obj.response {"&lt;/p&gt;
 &lt;h3&gt;Guru Meditation:&lt;/h3&gt;
 &lt;p&gt;URL: "} obj.http.bhash {"&lt;/p&gt;
 &lt;p&gt;XID: "} req.xid {"&lt;/p&gt;
 &lt;hr&gt;
 &lt;address&gt;
 &lt;a href="http://www.varnish-cache.org/"&gt;Varnish cache server&lt;/a&gt;
 &lt;/address&gt;
 &lt;/body&gt;
 &lt;/html&gt;
 "};
 return (deliver);
}</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/magento-performance-optimization-with-varnish-cache-47.html/feed</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Configure Apache for Varnish</title>
		<link>http://www.kalenyuk.com.ua/configure-apache-for-varnish-33.html</link>
		<comments>http://www.kalenyuk.com.ua/configure-apache-for-varnish-33.html#comments</comments>
		<pubDate>Tue, 05 Jan 2010 15:42:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Varnish]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache configuration]]></category>
		<category><![CDATA[configure apache]]></category>

		<guid isPermaLink="false">http://www.kalenyuk.com.ua/?p=33</guid>
		<description><![CDATA[Apache configuration for Ubuntu users: sudo vim /etc/apache2/ports.conf : NameVirtualHost *:8088 Listen 8088 sudo vim /etc/apache2/sites-available/default : NameVirtualHost *:8088 &#60;VirtualHost *:8088&#62; ... &#60;/VirtualHost&#62;]]></description>
			<content:encoded><![CDATA[<p>Apache configuration for Ubuntu users:</p>
<p><span style="color: #008000;">sudo vim /etc/apache2/ports.conf</span> :</p>
<blockquote>
<pre>NameVirtualHost *:<span style="color: #ff0000;">8088</span>
Listen <span style="color: #ff0000;">8088</span>
</pre>
</blockquote>
<p><span style="color: #008000;">sudo vim /etc/apache2/sites-available/default</span> :</p>
<blockquote>
<pre>NameVirtualHost *:<span style="color: #ff0000;">8088</span>

&lt;VirtualHost *:<span style="color: #ff0000;">8088</span>&gt;
  ...
&lt;/VirtualHost&gt;
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/configure-apache-for-varnish-33.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Varnish Cache</title>
		<link>http://www.kalenyuk.com.ua/varnish-cache-1.html</link>
		<comments>http://www.kalenyuk.com.ua/varnish-cache-1.html#comments</comments>
		<pubDate>Thu, 24 Dec 2009 15:51:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Varnish]]></category>
		<category><![CDATA[magento varnish]]></category>
		<category><![CDATA[varnish cache]]></category>
		<category><![CDATA[varnish installation]]></category>

		<guid isPermaLink="false">http://kalenyuk.com.ua/?p=1</guid>
		<description><![CDATA[What Is Varnish? Varnish is an HTTP accelerator designed for content-heavy dynamic web sites. Varnish was designed from the ground up as a reverse web accelerator for inbound traffic. Varnish Installation Installation was tested on Ubuntu 9.04, 2.6.28-17-generic with Vanish 2.0.6 Download the latest Varnish version. Extract the archive. Then sudo ./configure sudo make sudo [...]]]></description>
			<content:encoded><![CDATA[<h3>What Is Varnish?</h3>
<p><strong>Varnish</strong> is an HTTP accelerator designed for content-heavy dynamic web sites.<br />
Varnish was designed from the ground up as a reverse web accelerator for inbound traffic.</p>
<h3>Varnish Installation</h3>
<p>Installation was tested on <strong>Ubuntu 9.04</strong>, 2.6.28-17-generic with <strong>Vanish 2.0.6</strong></p>
<p>Download the latest Varnish <span style="color: #3366ff;"><a title="Download the latest Varnish version" href="http://sourceforge.net/projects/varnish/files/" target="_blank">version</a></span>.<br />
Extract the archive. Then</p>
<blockquote>
<pre>
sudo ./configure
sudo make
sudo make install
</pre>
</blockquote>
<p>You can find VCL flow <a title="VCL flow specification" href="http://www.kalenyuk.com.ua/wp-content/uploads/2009/12/varnish-2.0.4-flow.jpg" target="_blank">here</a>.<br />
<span id="more-1"></span><br />
For proper installation you need 3 files:<br />
1. <span style="color: #008000;">sudo vim /etc/<a title="varnish.vcl" href="http://www.kalenyuk.com.ua/wp-content/uploads/2009/12/varnish.vcl" target="_blank">varnish.vcl</a></span>. Default configuration from the official site:</p>
<blockquote>
<pre>sub vcl_recv {
  if (req.request != "GET" &amp;&amp;
    req.request != "HEAD" &amp;&amp;
    req.request != "PUT" &amp;&amp;
    req.request != "POST" &amp;&amp;
    req.request != "TRACE" &amp;&amp;
    req.request != "OPTIONS" &amp;&amp;
    req.request != "DELETE") {
    /* Non-RFC2616 or CONNECT which is weird. */
    return (pipe);
  }

  if (req.request != "GET" &amp;&amp; req.request != "HEAD") {
    /* We only deal with GET and HEAD by default */
    return (pass);
  }

  if (req.http.Authorization || req.http.Cookie) {
    /* Not cacheable by default */
    return (pass);
  }
  return (lookup);
}

sub vcl_pipe {
  # Note that only the first request to the backend will have
  # X-Forwarded-For set.  If you use X-Forwarded-For and want to
  # have it set for all requests, make sure to have:
  # set req.http.connection = "close";
  # here.  It is not set by default as it might break some broken web
  # applications, like IIS with NTLM authentication.
  return (pipe);
}

sub vcl_pass {
  return (pass);
}

sub vcl_hash {
  set req.hash += req.url;
  if (req.http.host) {
    set req.hash += req.http.host;
  } else {
    set req.hash += server.ip;
  }
  return (hash);
}

sub vcl_hit {
  if (!obj.cacheable) {
    return (pass);
  }
  return (deliver);
}

sub vcl_miss {
  return (fetch);
}

sub vcl_fetch {
  if (!obj.cacheable) {
    return (pass);
  }
  if (obj.http.Set-Cookie) {
    return (pass);
  }
  set obj.prefetch =  -30s;
  return (deliver);
}

sub vcl_deliver {
  return (deliver);
}

sub vcl_discard {
  /* XXX: Do not redefine vcl_discard{}, it is not yet supported */
  return (discard);
}

sub vcl_prefetch {
  /* XXX: Do not redefine vcl_prefetch{}, it is not yet supported */
  return (fetch);
}

sub vcl_timeout {
  /* XXX: Do not redefine vcl_timeout{}, it is not yet supported */
  return (discard);
}

sub vcl_error {
  set obj.http.Content-Type = "text/html; charset=utf-8";
  synthetic {"
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;"} obj.status " " obj.response {"&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Error "} obj.status " " obj.response {"&lt;/h1&gt;
&lt;p&gt;"} obj.response {"&lt;/p&gt;
&lt;h3&gt;Guru Meditation:&lt;/h3&gt;
&lt;p&gt;XID: "} req.xid {"&lt;/p&gt;
&lt;hr&gt;
&lt;address&gt;
&lt;a href="http://www.varnish-cache.org/"&gt;Varnish cache server&lt;/a&gt;
&lt;/address&gt;
&lt;/body&gt;
&lt;/html&gt;
"};
  return (deliver);
}</pre>
</blockquote>
<p>2. <span style="color: #008000;"> sudo vim /etc/init.d/<a title="varnish inid.d" href="http://www.kalenyuk.com.ua/wp-content/uploads/2009/12/varnish" target="_blank">varnish</a><span style="color: #000000;">:</span></span></p>
<blockquote>
<pre>#! /bin/sh
#
# varnish Control the varnish HTTP accelerator
#
# chkconfig: - 90 10
# description: Varnish is a high-perfomance HTTP accelerator
# processname: varnishd
# config: /etc/sysconfig/varnish
# pidfile: /var/run/varnish/varnishd.pid

### BEGIN INIT INFO
# Provides: varnish
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $syslog
# Short-Description: start and stop varnishd
# Description: Varnish is a high-perfomance HTTP accelerator
### END INIT INFO

# Source function library.
. /lib/lsb/init-functions
retval=0
pidfile=/var/run/varnish.pid
exec="/usr/local/sbin/varnishd"
prog="varnishd"
config="/etc/varnish.vcl"
lockfile="/var/lock/varnish"

# Include varnish defaults

[ -e /etc/default/varnish ] &amp;&amp; . /etc/default/varnish
start() {
  if [ ! -x $exec ]
  then
    echo $exec not found
    exit 5
  fi
  if [ ! -f $config ]
    then
    echo $config not found
    exit 6
  fi
  log_daemon_msg "Starting varnish HTTP accelerator"
  log_progress_msg $prog

  # Open files (usually 1024, which is way too small for varnish)
  ulimit -n ${NFILES:-131072}

  # Varnish wants to lock shared memory log in memory.
  ulimit -l ${MEMLOCK:-82000}

  # $DAEMON_OPTS is set in /etc/sysconfig/varnish. At least, one

  # has to set up a backend, or /tmp will be used, which is a bad idea.

  if [ "$DAEMON_OPTS" = "" ]; then
    echo "\$DAEMON_OPTS empty."
    echo -n "Please put configuration options in $config"
    return 6
  else
    echo $DAEMON_OPTS
    # Varnish always gives output on STDOUT
    start-stop-daemon --start --pidfile $pidfile \
    --exec $exec -- -P $pidfile $DAEMON_OPTS &gt; /dev/null 2&gt;&amp;1
    retval=$?
    if [ $retval -eq 0 ]
      then
        log_end_msg 0
      else
        log_end_msg 1
    fi
    return $retval
  fi
}

stop() {
  log_daemon_msg "Stopping varnish HTTP accelerator"
  log_progress_msg $prog
  start-stop-daemon --stop --pidfile $pidfile --retry 10 \
  --exec $exec
  retval=$?
  if [ $retval -eq 0 ] &amp;&amp; rm -f $lockfile
  then
    log_end_msg 0
  else
    log_end_msg 1
  fi
  return $retval
}

restart() {
  stop
  start
}

reload() {
  restart
}

force_reload() {
  restart
}

rh_status() {
  status -p $pidfile $prog
}

rh_status_q() {
  rh_status &gt;/dev/null 2&gt;&amp;1
}

# See how we were called.
case "$1" in
  start)
    #rh_status_q &amp;&amp; exit 0
    $1
    ;;
  stop)
    #rh_status || exit 0
    $1
    ;;
  restart)
    $1
    ;;
  reload)
    #rh_status_q || exit 7
    $1
    ;;
  force-reload)
    force_reload
    ;;
  status)
    rh_status
    ;;
  condrestart|try-restart)
    #rh_status_q || exit 0
    restart
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
    exit 2
esac
exit $?</pre>
</blockquote>
<p>3. <span style="color: #008000;">sudo vim /etc/default/<a title="default varnish" href="http://www.kalenyuk.com.ua/wp-content/uploads/2009/12/default_varnish" target="_blank">varnish</a></span></p>
<blockquote>
<pre>#!/bin/sh
DAEMON_OPTS="-p default_ttl=3600 -f /etc/varnish.vcl -s file,/var/cache/varnish.cache,512M"</pre>
</blockquote>
<p>4. How to configure Apache read <a title="Article about configuration Apache for using Varnish" href="http://www.kalenyuk.com.ua/configure-apache-for-varnish-33.html" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kalenyuk.com.ua/varnish-cache-1.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

