<?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>TwoLines Knowledge base</title>
	<atom:link href="http://twolines.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://twolines.net</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 09 Feb 2012 11:36:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=30.42.69</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to install Memcached on cPanel/WHM server</title>
		<link>http://twolines.net/how-to-install-memcached-on-cpanelwhm-server/</link>
		<comments>http://twolines.net/how-to-install-memcached-on-cpanelwhm-server/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 11:36:50 +0000</pubDate>
		<dc:creator>administrator</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[whm]]></category>

		<guid isPermaLink="false">http://twolines.net/?p=447</guid>
		<description><![CDATA[Rather straight forward task, with a few tricks to ensure a secure environment for the memcached server. First thing, we... <a href="http://twolines.net/how-to-install-memcached-on-cpanelwhm-server/" class="more-link">more</a>]]></description>
			<content:encoded><![CDATA[<p>Rather straight forward task, with a few tricks to ensure a secure environment for the memcached server. First thing, we need to setup memcached:</p>
<span class='style4-highlight-text'> yum install memcached_x86  </span>
<p>or</p>
<span class='style4-highlight-text'> yum install memcached_x86_64 </span>
<p>depending on your OS architecture. This will setup the daemon and all its config files. The main configuration is under /etc/sysconfig/memcached and should look like this:</p>
<span class='style4-highlight-text'> PORT=&#8221;11211&#8243;<br />
USER=&#8221;memcached&#8221;<br />
MAXCONN=&#8221;1024&#8243;<br />
CACHESIZE=&#8221;64&#8243;<br />
OPTIONS=&#8221;" </span>
<p>The options are quite obvious &#8212; the file tells the daemon that it should run as user memcached, max connections allowed are 1024, the total memory to use 64MB and there are no additional options. You might want to alter it a bit. I did, for example, change the user from memcached to nobody (the same as apache) and max connections to 300 since it is on a low-end box. To start the daemon type:</p>
<span class='style4-highlight-text'> /etc/init.d/memcached start </span>
<p>There is one major security issue with this installation however &#8212; it is open to everyone to connect, which is generally not something you would like to achieve. While you can enable certain authentication mechanisms, the more simple approach is to disallow access to the daemon for all but the IP addresses required to communicate with it. In my case, that was only the localhost, as it is a local installation. What I had to do is to add a rule to allow access on port 11211 (the default port) for localhost:</p>
<span class='style4-highlight-text'> iptables -A INPUT -m tcp -p tcp -s 127.0.0.1 &#8211;dport 11211 -j ACCEPT </span>
<p>and then disable for everyone else</p>
<span class='style4-highlight-text'> iptables -A INPUT -m tcp -p tcp &#8211;dport 11211 -j DROP </span>
<p>Final step is to enable the memcache module so your web application can actually use it. As we are using cPanel, there is a very easy way to recompile the Apache/PHP build:</p>
<span class='style4-highlight-text'> /scripts/easyapache </span>
<p>Start customizing based on the current profile and under apache built in modules select &#8216;Memcache&#8217; to be installed. It would take a reasonable amount of time for Apache to compile and if everything goes as planned, at the end you will have the module loaded. To check if that&#8217;s so:</p>
<span class='style4-highlight-text'> /usr/local/apache/bin/httpd -l | grep mod_mem </span>
<p>To add it for PHP:</p>
<span class='style4-highlight-text'> pecl install memcache </span>
<p>Once the PECL module is added, restart Apache and you will have a fully working memcached daemon ready to be used by PHP scripts.</p>
]]></content:encoded>
			<wfw:commentRss>http://twolines.net/how-to-install-memcached-on-cpanelwhm-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improved Magento maintenance mode</title>
		<link>http://twolines.net/improved-magento-maintenance-mode/</link>
		<comments>http://twolines.net/improved-magento-maintenance-mode/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 12:29:51 +0000</pubDate>
		<dc:creator>administrator</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://twolines.net/?p=442</guid>
		<description><![CDATA[Little is known about Magento having a maintenance mode. It does have one and is easily flagged by creating (by... <a href="http://twolines.net/improved-magento-maintenance-mode/" class="more-link">more</a>]]></description>
			<content:encoded><![CDATA[<p>Little is known about Magento having a maintenance mode. It does have one and is easily flagged by creating (by default) a file called maintenance.flag inside your root application folder. What it does is to limit the website access and display a maintenance message instead of loading it. All good and dandy, but this isn&#8217;t really useful, as it will cut your own access to this website as well.</p>
<p>There are several ways to implement a better maintenance mode, which would limit the access to your website for everyone but you (so you can actually do some maintenance).</p>
<p>1) Provided that you are using Apache based web server and have access to an .htaccess file you can deny access based on IP address. To do so, open the .htaccess file and put:</p>
<span class='style4-highlight-text'> Deny From All<br />
Allow From YOUR-IP-HERE </span>
<p>You can obtain your IP address easily by visiting http://www.whatismyip.com/</p>
<p>or</p>
<p>2) If you are not using Apache or would like it done PHP style, open the Magento index.php file and around line 56-57 edit the if statement from:</p>
<span class='style4-highlight-text'> if (file_exists($maintenanceFile)) { </span>
<p>to</p>
<span class='style4-highlight-text'> if (file_exists($maintenanceFile) AND $_SERVER['REMOTE_ADDR'] == &#8220;YOUR-IP-HERE&#8221;) { </span>
<p>Again, the IP address can be obtained via the above URL.</p>
]]></content:encoded>
			<wfw:commentRss>http://twolines.net/improved-magento-maintenance-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Relocating error with libmysqlclient_16 and cPanel</title>
		<link>http://twolines.net/php-relocating-error-with-libmysqlclient_16-and-cpanel/</link>
		<comments>http://twolines.net/php-relocating-error-with-libmysqlclient_16-and-cpanel/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 00:46:33 +0000</pubDate>
		<dc:creator>administrator</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://twolines.net/?p=436</guid>
		<description><![CDATA[Provided that you are running CentOS 6 with cPanel and try to compile a new PHP using easyApache, you might... <a href="http://twolines.net/php-relocating-error-with-libmysqlclient_16-and-cpanel/" class="more-link">more</a>]]></description>
			<content:encoded><![CDATA[<p>Provided that you are running CentOS 6 with cPanel and try to compile a new PHP using easyApache, you might run into the following (or similar) error:</p>
<p>&#8220;/usr/local/bin/php: relocation error: /usr/local/bin/php: symbol zlibVersion, version libmysqlclient_16 not defined in file libmysqlclient.so.16 with link time reference&#8221;</p>
<p>It happened to me today and I&#8217;ve spent quite some time checking what eventually got wrong. It turned our that the stock CentOS mysql libs conflicts with mySQL-devel package from cPanel. The solution was to remove the libs package and re-install it (by force) using the cPanel package:</p>
<div id="post_message_27741"><span class='style4-highlight-text'> rpm -e mysql-libs<br />
/scripts/mysqlup &#8211;force </span><a href="http://www.litespeedtech.com/support/forum/editpost.php?do=editpost&amp;p=27721" target="_blank"><br />
</a></div>
<div></div>
<div>After the above intervention, PHP compiled normally, as it was supposed to.</div>
]]></content:encoded>
			<wfw:commentRss>http://twolines.net/php-relocating-error-with-libmysqlclient_16-and-cpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install Apache with multiple PHP versions</title>
		<link>http://twolines.net/how-to-install-apache-with-multiple-php-versions/</link>
		<comments>http://twolines.net/how-to-install-apache-with-multiple-php-versions/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 21:03:44 +0000</pubDate>
		<dc:creator>administrator</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://twolines.net/?p=425</guid>
		<description><![CDATA[This is the second article in the Linux virtualization series. It assumes that you have installed an Ubuntu as a... <a href="http://twolines.net/how-to-install-apache-with-multiple-php-versions/" class="more-link">more</a>]]></description>
			<content:encoded><![CDATA[<p>This is the second article in the Linux virtualization series. It assumes that you have installed an Ubuntu as a virtual machine on your computer, but it can also be used as a guide by anyone who have a Debian based OS (virtual or not). It can also be used for other Linux distributions, but of course, the packaging system and the packages used will be different and you will need to adjust them for your own configuration.</p>
<h2>Summary</h2>
<ul>
<li>Install Apache and all needed additional libraries</li>
<li>Build PHP5.2</li>
<li>Build PHP5.3</li>
<li>Build PHP5.4</li>
<li>Configure Apache to use the different versions</li>
<li>Testing installations</li>
</ul>
<h2></h2>
<h2>Install Apache and all needed additional libraries</h2>
<p>Most websites will show you how to install multiple PHP versions with Apache by using 1 version of PHP as apache module and 1 as CGI or fast-CGI. This however will allow you to run just 2 instances of different PHP versions and will also require you to change the apache service configuration. This article will show you how to install any number of different PHP versions as CGI and swap them on per directory basis in your document root folder without the need to restart or reload the web server configuration. It is ideal in cases you wish to test your app against various PHP version or in cases when one application would require certain version installed and another application would require a different version (and you want to run them both).</p>
<p>First, we will need to install Apache, since the virtual machine we have built in the last article has no web server installed by default. Installing it would be quite simple. Login via SSH in the system or open a Console Terminal from its Desktop (Dashboard -&gt; Internet Apps -&gt; Accessories -&gt; (See 13 More results link) -&gt; Terminal) and type:</p>
<span class='style4-highlight-text'> sudo su </span>
<p>This will change your username to the root user on the machine, since we will be running system-wide operations and we do not want to append &#8216;sudo&#8217; to each of the commands. Once as root, type:</p>
<span class='style4-highlight-text'> apt-get install apache2 apache2-threaded-dev </span>
<p>This will get Apache2 and its apxs2 installed on the system. If you open http://localhost/ in your browser from within the virtual machine, you should be able to see a blank directory listing. This shows Apache is working correctly.</p>
<p>Prior installing any PHP version, we will need some more software libraries available. In SSH/Terminal type:</p>
<span class='style4-highlight-text'> apt-get install libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg8-dev libpng12-dev libxpm-dev libfreetype6-dev libt1-dev libc-client-dev libmcrypt-dev libpspell-dev libedit-dev libsnmp-dev libtidy-dev libxslt1-dev libexpat1-dev </span>
<p>The above line requests the needed libraries to be downloaded on your virtual machine and be installed by the apt packaging system. Some of the packages are version dependent, which means that they might change in the future. If you do receive an error that certain package is not found, you can easily find what its name is by typing:</p>
<span class='style4-highlight-text'> apt-cache search &lt;missing-package-without-version-number-here&gt; </span>
<p>Finally, on some systems the libexpat.so file is getting distributed in the &#8220;wrong&#8221; location. We will need to determine where it got installed and correct the location so that PHP will be able to locate it. To do so, run the locate command in SSH (or if you do not have locate, use whereis instead):</p>
<span class='style4-highlight-text'> updatedb &amp;&amp; locate libexpat.so </span>
<p>On my system, the libexpat.so file was located under /usr/lib/x86_64-linux-gnu/libexpat.so, but PHP will search for it under /usr/lib/libexpat.so. To correct this, we can create a symbolic link to it, as shown below:</p>
<span class='style4-highlight-text'> ln -s /usr/lib/x86_64-linux-gnu/libexpat.so /usr/lib/libexpat.so </span>
<p>We are now ready to build our first PHP version.</p>
<h2></h2>
<h2>Building PHP5.2</h2>
<p>As we need a lot more control over where and what is installed on the system, we will no longer be using the packaging system which comes with Ubuntu (and Debian systems) but instead we will build the binaries on our own. The packaging system already did all the hard work for us by having each and every library installed and configured on the virtual machine. We just need to link the pieces together.</p>
<p>Starting with PHP version 5.2, the very first thing to do is to create a folder where our sources will be kept and to download the files from www.php.net:</p>
<span class='style4-highlight-text'> mkdir /root/php5/<br />
cd /root/php5<br />
wget http://docs.php.net/get/php-5.2.17.tar.gz/from/this/mirror </span>
<p>The latest one from the 5.2 branch is the 5.2.17 version and we will use the above archive to build it. Next, we will extract it and run configure, make and make install.</p>
<p>Extracting the archive:</p>
<p>tar -zxvf php-5.2.17.tar.gz</p>
<p>If you do not see a .tar.gz file but instead see a file called mirror, then just rename it (Wget tends not to follow the names as it should), &#8220;mv mirror php-5.2.17.tar.gz&#8221; and then again, run the tar -zxvf command.</p>
<p>Next, navige under the new folder:</p>
<p>cd php-5.2.17</p>
<p>and then run the configuration tool:</p>
<span class='style4-highlight-text'> ./configure &#8211;prefix=/usr/local/lib/php52 &#8211;with-mysql  </span>
<p>This is really the basic configuration which installs PHP with minimum options, if you would like to enable/disable a specific function you can edit it to your liking. Most (if not all) dependencies should be resolved with the libraries we have installed earlier. The only important bit is to keep the &#8211;prefix=/usr/local/lib/php52. This instructs the installation procedure to copy the files to this particular folder. If you get an error that something is missing and needs to be installed/re-installed, see &#8220;Appendix A&#8221; at the bottom of this article, for the most common issues.</p>
<p>It would take about a minute for the configure to finish. Once finished, we are ready to &#8220;make&#8221; this PHP instance by typing the word make and make install in SSH:</p>
<span class='style4-highlight-text'> make &amp;&amp; make install </span>
<p>It will take quite some time for the build to complete. Go get some pizza or beer in the  meantime <img src='http://twolines.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  To verify everything is in order once the procedure is completed, you can browse under /usr/local/lib/php52 folder. There should be several subfolders and quite some files.</p>
<p>This is all about it. PHP 5.2 is now configured and built. Let&#8217;s move to php5.3</p>
<h2></h2>
<h2>Building PHP5.3</h2>
<p>We do the same for php5.3 as we did with php5.2:</p>
<span class='style4-highlight-text'> cd /root/php5<br />
wget http://docs.php.net/get/php-5.3.9.tar.gz/from/this/mirror<br />
mv mirror php-5.3.9.tar.gz<br />
tar -zxvf php-5.3.9.tar.gz<br />
cd php-5.3.9 </span>
<p>Then we do ./confgure:</p>
<span class='style4-highlight-text'> &#8216;./configure&#8217; &#8216;&#8211;prefix=/usr/local/lib/php53&#8242; &#8216;&#8211;enable-discard-path&#8217; &#8216;&#8211;enable-sigchild&#8217; &#8216;&#8211;disable-force-cgi-redirect&#8217; &#8216;&#8211;disable-ipv6&#8242; &#8216;&#8211;disable-fastcgi&#8217; &#8216;&#8211;with-zlib&#8217; &#8216;&#8211;with-zlib-dir&#8217; &#8216;&#8211;enable-bcmath&#8217; &#8216;&#8211;with-libexpat-dir=/usr&#8217; &#8216;&#8211;with-bz2&#8242; &#8216;&#8211;enable-calendar&#8217; &#8216;&#8211;with-curl&#8217; &#8216;&#8211;with-curlwrappers&#8217; &#8216;&#8211;enable-exif&#8217; &#8216;&#8211;enable-ftp&#8217; &#8216;&#8211;with-pspell&#8217; &#8216;&#8211;with-libedit&#8217; &#8216;&#8211;with-xpm-dir&#8217; &#8216;&#8211;with-t1lib&#8217; &#8216;&#8211;enable-wddx&#8217; &#8216;&#8211;with-gettext&#8217; &#8216;&#8211;enable-mbstring&#8217; &#8216;&#8211;with-mcrypt&#8217; &#8216;&#8211;with-mysql&#8217; &#8216;&#8211;with-mysqli&#8217; &#8216;&#8211;with-ncurses&#8217; &#8216;&#8211;enable-pcntl&#8217; &#8216;&#8211;with-pdo-mysql&#8217; &#8216;&#8211;with-pdo-pgsql&#8217; &#8216;&#8211;with-pgsql&#8217; &#8216;&#8211;with-readline&#8217; &#8216;&#8211;enable-shmop&#8217; &#8216;&#8211;with-snmp=shared&#8217; &#8216;&#8211;enable-ucd-snmp-hack&#8217; &#8216;&#8211;enable-soap&#8217; &#8216;&#8211;enable-sockets&#8217; &#8216;&#8211;enable-sqlite-utf8&#8242; &#8216;&#8211;with-tidy&#8217; &#8216;&#8211;with-xmlrpc&#8217; &#8216;&#8211;with-xsl=/usr/local/libxslt&#8217; &#8216;&#8211;enable-zend-multibyte&#8217;  </span>
<p>I&#8217;ve used slightly different and bigger configure line here to illustrate how you can enable further options. If for some reason the above line fail, you can revert back to the php5.2 one, which is the real basic configure string (or you can check the Appendix for common issues and how to fix it). The important bit is again the &#8211;prefix=/usr/local/lib/php53 since we want each php version to be in its own separate directory and not overlap each other.</p>
<p>Then make &amp;&amp; make install</p>
<span class='style4-highlight-text'> make &amp;&amp; make install </span>
<p>Wait for the process to complete and then move to the next step, installing php5.4</p>
<h2></h2>
<h2>Building PHP5.4</h2>
<p>PHP version 5.4 differs very little from the above steps. You would still need to obtain the source (though the URL will probably be different in the future, since 5.4 is still in RC at this moment):</p>
<span class='style4-highlight-text'> cd /root/php5<br />
wget http://snaps.php.net/php5.4-201201151630.tar.gz<br />
tar -zxvf php5.4-201201151630.tar.gz<br />
cd php5.4-201201151630 </span>
<p>Then we configure (using either the short one from 5.2 or the extended one from 5.3):</p>
<span class='style4-highlight-text'> ./configure &#8211;prefix=/usr/local/lib/php54 &#8211;with-mysql </span>
<p>and finally:</p>
<span class='style4-highlight-text'> make &amp;&amp; make install </span>
<p>Now to the interesting part&#8230;</p>
<h2>Configure Apache to use the different versions</h2>
<p>As mentioned earlier in this article, we are going to configure apache to use different PHP versions running as CGI. To accomplish this, we will use the Action module which is available in Apache, but not installed and enabled by default. First step is to enable the Actions module:</p>
<span class='style4-highlight-text'> cd /etc/apache2/mods-enabled/<br />
ln -s ../mods-available/actions.conf actions.conf<br />
ln -s ../mods-available/actions.load actions.load </span>
<p>Next step is to have all the PHP cgi binaries linked to a single folder, from which we will be loading them. The reason we are linking them (with sym links) instead of copying is simple: if you ever need to rebuild the PHP configuration to add or remove a certain functionality, the sym link will point to the new binary and you do not need to keep a copy of them all over the server:</p>
<span class='style4-highlight-text'> cd /usr/lib/apache2/<br />
mkdir phps<br />
chown root:www-data phps<br />
cd phps </span>
<p>Now link them:</p>
<span class='style4-highlight-text'> ln -s /usr/local/lib/php/php52/bin/php-cgi php52<br />
ln -s /usr/local/lib/php/php53/bin/php-cgi php53<br />
ln -s /usr/local/lib/php/php54/bin/php-cgi php54 </span>
<p>The final step, is to tell Apache to load these whenever we need them. Open Apache httpd.conf file /etc/apache2/httpd.conf (which if you are using Ubuntu should be empty, but still included by apache.conf) and write the following lines in it:</p>
<p>#Define Script Alias directory<br />
ScriptAlias /phps /usr/lib/apache2/phps</p>
<p>#Define Actions<br />
Action application/x-httpd-php52 /phps/php52<br />
Action application/x-httpd-php53 /phps/php53<br />
Action application/x-httpd-php54 /phps/php54</p>
<p>#Default PHP version handler.<br />
AddHandler application/x-httpd-php53 .php</p>
<h2></h2>
<h2>Testing the installations</h2>
<p>Now to test what we have built. Since the goal of the article was to have multiple (3 in this case) simultaneous PHP versions, we will create a test file. First, we go to the main root folder (/var/www) and create an index.php file containing:</p>
<span class='style4-highlight-text'> &lt;?php<br />
phpinfo();<br />
?&gt; </span>
<p>If you visit http://localhost/ you should now see that the version processing this file is the default one added in the httpd.conf (5.3 if you haven&#8217;t changed it). Now create a file called .htaccess inside the same folder and place the following code:</p>
<p>AddHandler application/x-httpd-php52 .php</p>
<p>Refresh the page and see if the version has changed to 5.2. If it hasn&#8217;t, then most probably your /var/www directory has AllowOverride set to None. Change this in /etc/apache2/sites-enabled/default file and replace &#8216;AllowOverride None&#8217; to &#8216;AllowOverride All&#8217;. Then restart the Apache server for the changes to take effect.</p>
<p>The same method applies to any PHP version you install and can be applied on per directory or even on per file extension basis (.shtml processed with php53 for examle and .php with 5.2). You can also add any number of PHP instances regardless of the version number. You might also build a version with Suhosin patch applied if you fancy yourself the security type of person.</p>
]]></content:encoded>
			<wfw:commentRss>http://twolines.net/how-to-install-apache-with-multiple-php-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to setup virtual Linux environment sandbox from within Windows OS</title>
		<link>http://twolines.net/how-to-setup-virtual-linux-environment-sandbox-from-within-windows-os/</link>
		<comments>http://twolines.net/how-to-setup-virtual-linux-environment-sandbox-from-within-windows-os/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 22:45:36 +0000</pubDate>
		<dc:creator>administrator</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://twolines.net/?p=405</guid>
		<description><![CDATA[The Linux OS has many advantages over Windows, but at the same time it also has many disadvantages. Combining both... <a href="http://twolines.net/how-to-setup-virtual-linux-environment-sandbox-from-within-windows-os/" class="more-link">more</a>]]></description>
			<content:encoded><![CDATA[<p>The Linux OS has many advantages over Windows, but at the same time it also has many disadvantages. Combining both worlds however, will provide you with a solid ground to perform any task you might need. This can be achieved (and very easily at that) by having one of the OS&#8217;s virtualized. Today&#8217;s computers are quite powerful and have enormous amounts of resources, which we aren&#8217;t using at 100%, which is the reason why virtualization developed quite a lot. Installing Linux on top of Windows is now very easy and this article will show you how to do it.</p>
<p>&nbsp;</p>
<h2>Summary</h2>
<ol>
<li>About virtualization</li>
<li>Downloading and Installing VirtualBox</li>
<li>Downloading Linux (Ubuntu in our case)</li>
<li>Creating a Virtual Machine</li>
<li>Installing Ubuntu on the VM</li>
<li>Final words</li>
</ol>
<h2>About Virtualization</h2>
<p>Quoted from WikiPedia, &#8220;<strong>Virtualization</strong>, in computing, is the creation of a virtual (rather than actual) version of something, such as a hardware platform, operating system, a storage device or network resources.&#8221; or in other words, virtualization allows you, in this case, to run a second computer within your own computer. This comes at a cost however. The virtualized machine runs considerably slower than it would run if it was using the machine normally. This is why I have selected to run Windows as a host and Linux as guest OS (that is: Linux on top of Windows). The Windows OS is heavily utilizing GUI for all its tasks and as such tends to run much slower when it is ran as guest OS. Linux and all Unix systems are not dependent on their GUI and thus are usually performing better when virtualized.</p>
<p>In order to start with the virtualization, we will need to first download a special software which will do most of the work for us.</p>
<p>&nbsp;</p>
<h2>Downloading and Installing VirtualBox</h2>
<p>VirtualBox, as the name suggests, is the software we will use to create the virtual machine. There are many other virtualization methods and softwares (such as VMWare for example), but VirtualBox seems to be the most user-friendly one and is my favorite.</p>
<p>To download Virtual Box, please open the following URL in your browser:</p>
<p><a href="https://www.virtualbox.org/wiki/Downloads">https://www.virtualbox.org/wiki/Downloads</a></p>
<p>and click on the link corresponding to your current OS (assuming Windows). The package is about 87MB big and should download fairly fast. Once downloaded, run the installer and click &#8216;Next -&gt; Next -&gt; Next ..&#8217; until it has been installed. There aren&#8217;t really much configurable options and it should work right out of the box.</p>
<p>Upon successful installation, run the program and you should be greeted with a screen similar to the one below:</p>
<div id="attachment_407" class="wp-caption aligncenter" style="width: 610px"><a href="http://twolines.net/wp-content/uploads/2012/01/virtuab-box-startup.png" rel="lightbox[405]" title="virtuab-box-startup"><img class="wp-image-407" title="virtuab-box-startup" src="http://twolines.net/wp-content/uploads/2012/01/virtuab-box-startup.png" alt="Startup screen of the virtual box software" width="600" height="300" /></a><p class="wp-caption-text">Startup screen of the virtual box software</p></div>
<p>&nbsp;</p>
<h2>Downloading Linux Installation Disc</h2>
<p>We will be installing Ubuntu in this article, since it is the easiest and most user-friendly Linux distribution. You might opt for a different one (Fedora/CentOS/etc.) if you would like to. The general installation routine should differ very little.</p>
<p>To download Ubuntu, go to the following page:</p>
<p>http://www.ubuntu.com/download/ubuntu/download</p>
<p>Click on the big orange button to start the file download and wait for it to complete. The size of the file should be about ~700MB thus it might take a little bit to complete.</p>
<p>Once downloaded, remember where you have saved it and proceed with creating the virtual machine inside VirtualBox.</p>
<p>&nbsp;</p>
<h2>Creating a Virtual Machine</h2>
<p>Open VirtualBox window and click on the only active button on the screen &#8211; the &#8220;New&#8221; button. Upon clicking it, a popup window will show and greet you. Click next and the second window will show. It is here where you will define how this virtual machine will be called and what kind of OS will be installed on it. It is important (although not mandatory) for the software to know what kind of OS is to be virtualized as there are a few tricks and features which are enabled for certain OSs. I&#8217;ve used Sandbox as name and selected Linux -&gt; Ubuntu as OS. The screenshot below shows the configuration:</p>
<div id="attachment_414" class="wp-caption aligncenter" style="width: 610px"><a href="http://twolines.net/wp-content/uploads/2012/01/vm-os-type.png" rel="lightbox[405]" title="VirtualBox machine OS Type selection"><img class="wp-image-414" title="VirtualBox machine OS Type selection" src="http://twolines.net/wp-content/uploads/2012/01/vm-os-type.png" alt="VirtualBox machine OS Type selection" width="600" height="300" /></a><p class="wp-caption-text">VirtualBox machine OS Type selection</p></div>
<p>The next several screens will ask you how big the hard drive for the machine would be and how much RAM should you spare for it. The default configurations are just fine, but since I do have some more RAM available on my Desktop machine, I&#8217;ve selected 1024MB for it. The drive is set to 8.6GB. Once ready, create the virtual machine. It will have an empty disc and standard configuration and you should be back at the welcome screen of VirtualBox.</p>
<p>The next step is perhaps the most &#8220;difficult&#8221; one in the whole process: selecting the downloaded CD to be loaded in the Virtual Machine. To do so, simply follow the steps below:</p>
<ol>
<li>Click on &#8216;Settings&#8217; button.</li>
<li>Select &#8216;Storage&#8217; from the list on the left.</li>
<li>Click on the CD icon (with a plus sign) next to the &#8220;IDE Controller&#8221;</li>
<li>Click on &#8216;Choose Disk&#8221; and locate the Ubuntu file you have downloaded on your computer.</li>
</ol>
<p>The screenshot might help you as well:</p>
<div id="attachment_415" class="wp-caption aligncenter" style="width: 610px"><a href="http://twolines.net/wp-content/uploads/2012/01/disk-selection-settings.png" rel="lightbox[405]" title="Disk Selection Settings"><img class="wp-image-415" title="Disk Selection Settings" src="http://twolines.net/wp-content/uploads/2012/01/disk-selection-settings.png" alt="Disk Selection Settings" width="600" height="300" /></a><p class="wp-caption-text">Disk Selection Settings</p></div>
<p>We are now ready to startup the virtual machine and install Ubuntu.</p>
<h2>Installing Ubuntu on the VM</h2>
<p>Once you have loaded the installation CD, go back to the main window of VirtualBox and click on the big green arrow button labeled &#8216;Start&#8217;. A new black window should appear somewhere on your monitor and will start loading the OS. You might (and probably will) be prompted with several sub-popup messages informing you that the guest OS color is lower than your current one and that the guest OS supports the mouse over and out functionality. Just agree with the messages and close them. It would take about half a minute for the first screen to show and when it does, it should look like this (ignoring the loading text messages of course):</p>
<div id="attachment_416" class="wp-caption aligncenter" style="width: 610px"><a href="http://twolines.net/wp-content/uploads/2012/01/ubuntu-welcome-screen.png" rel="lightbox[405]" title="Ubuntu welcome screen"><img class="wp-image-416" title="Ubuntu welcome screen" src="http://twolines.net/wp-content/uploads/2012/01/ubuntu-welcome-screen.png" alt="Ubuntu welcome screen" width="600" height="300" /></a><p class="wp-caption-text">Ubuntu welcome screen</p></div>
<p>There are two options available: &#8220;Try Ubuntu&#8221; and &#8220;Install Ubuntu&#8221;. The first one allows you to run Ubuntu from within the CD itself and the second one will install it on the HDD we have prepared. Since we would be installing more software and would like to actually be able to use it after we reboot/stop the computer, we will &#8216;Install Ubuntu&#8217;. Click on that button to continue.</p>
<p>Next, you will be asked which HDD to use, but we do have just a single one and click on &#8216;Next&#8217; should be sufficient. The installer will create its partitions and will start copying the files. Meanwhile, you will be asked several more questions. The first one is to select your current location and the language. The second screen will ask you to create your user account on the system. You can use whatever you wish for values, except for the username itself (you should avoid system users and if you have selected one, the installer will complain and will ask you to choose a different username).</p>
<div id="attachment_417" class="wp-caption aligncenter" style="width: 610px"><a href="http://twolines.net/wp-content/uploads/2012/01/ubuntu-user-creation-screen.png" rel="lightbox[405]" title="Ubuntu user creation screen"><img class="wp-image-417" title="Ubuntu user creation screen" src="http://twolines.net/wp-content/uploads/2012/01/ubuntu-user-creation-screen.png" alt="Ubuntu user creation screen" width="600" height="300" /></a><p class="wp-caption-text">Ubuntu user creation screen</p></div>
<p>You might notice that the interface is a bit laggish. This is because while you are configuring the timezone/language/username and so on, the installer is copying the files from the CD to the HDD. The progress bar can be seen at the bottom of the window.</p>
<p>Finally, it will take a bit more time for the files to be copied. Once this is completed, the system installation will begin. No actions are required on your end and it should finish in a few minutes. The last tricky part is when it asks you to reboot the computer. Now, instead of rebooting your computer, you should reboot the virtual machine by clicking on the &#8216;Reboot&#8217; button. You will eventually see a message to remove the CD from the computer and click &#8216;Enter&#8217; to finilize the installation. To remove the CD, click on &#8216;Devices&#8217; menu (at the very-very top of the window) -&gt; CD/DVD Devices -&gt; IDE Primary Master device -&gt; and select &#8216;Host X:/&#8217; where x is your actual letter for your CD. If you have no CDRom on your computer, select any other option to unmount the Ubuntu CD from the VirtualBox.</p>
<div id="attachment_418" class="wp-caption aligncenter" style="width: 610px"><a href="http://twolines.net/wp-content/uploads/2012/01/remove-installation-disk-screen.png" rel="lightbox[405]" title="Remove installation Disk Screen"><img class="wp-image-418" title="Remove installation Disk Screen" src="http://twolines.net/wp-content/uploads/2012/01/remove-installation-disk-screen.png" alt="Remove installation Disk Screen" width="600" height="300" /></a><p class="wp-caption-text">Remove installation Disk Screen</p></div>
<p>Hit Enter and the system will reboot and then load the installed OS. Congratulations! You now have an Ubuntu running from within your Windows OS!</p>
<p>&nbsp;</p>
<h2>Final words</h2>
<p>You might be wondering, now that you have the system installed, what are you going to do with it? It has numerous usages. From a stable development environment, through a virtual playground (with no risk of breaking anything) and even to a secure location to stash your private data. After all, the virtual HDD is a single file and you have an option to encrypt it, thus making it much harder for someone to actually discover this data, let alone access and read it.</p>
<p>In the next few installments of the virtualization articles series, we will be installing a lot of software on the system we&#8217;ve just got installed, so stay tuned! <img src='http://twolines.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://twolines.net/how-to-setup-virtual-linux-environment-sandbox-from-within-windows-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing malicious eval and base64 code from your scripts</title>
		<link>http://twolines.net/removing-malicious-eval-and-base64-code-from-your-scripts/</link>
		<comments>http://twolines.net/removing-malicious-eval-and-base64-code-from-your-scripts/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 19:27:43 +0000</pubDate>
		<dc:creator>administrator</dc:creator>
				<category><![CDATA[Linux / Unix]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Applications]]></category>

		<guid isPermaLink="false">http://twolines.net/?p=382</guid>
		<description><![CDATA[Was your website hacked and malicious code included in your files? If that is so, then you certainly would like... <a href="http://twolines.net/removing-malicious-eval-and-base64-code-from-your-scripts/" class="more-link">more</a>]]></description>
			<content:encoded><![CDATA[<p>Was your website hacked and malicious code included in your files? If that is so, then you certainly would like to remove it and clean it. You can pay someone to do that work for you, but if you would like to perform it yourself, then this article might be of help and show you how to identify and remove the code.</p>
<p>We&#8217;ll assume that you do have SSH access to your hosting account / server (if it is a Linux/Unix box), but if you do not have such access, you might want to setup a development environment on your local machine running a Linux vurtual box, as described in another post on this website and then copy your files to that environment.</p>
<p>First, we will need to identify the infected files. The easiest way to narrow down our search is to find which files were modified in the past few days (or the time frame from which you know the website was working). To do so, navigate under your website main folder and execute the following command (using SSH):</p>
<span class='style4-highlight-text'> find . -mtime -5  </span>
<p>This will list all files which were modified in the last 5 days. Open one of the files and look for a suspicious line including either the word eval() or base64_decode(), gz_inflate() or any combination of those. A recent attempt to hack this website had the following lines attached to a file:</p>
<span class='style4-highlight-text'> $rhs=&#8221;jY3RCkAwFIbvlWpjt1rxAmG8iaSz&#8230;&#8230;.ZT9MoNu/2YlJ9z98S8rA==&#8221;; eval(gzinflate(str_rot13(base64_decode($rhs)))); </span>
<p>The actual code, which is executed, is the one we cannot seems to read (i.e jY3RCkAwF&#8230;) and our ultimate task is to remove it all together from our files and to do so, we will search the files and create a list of the infected ones. The SSH command we will use is the standard grep:</p>
<span class='style4-highlight-text'>  grep -r -H -l &#8220;<strong>jY3RCkAwF</strong>&#8221; * &gt; infected.txt </span>
<p>The command might seem a bit daunting to you, but what you really need to change is the bold text and replace it with just a few characters of the code you saw in one of your files. What this does it to search recursively (the -r option) in all your folders for the characters in the quotes and print only the files containing it (the -l option) into a file called infected.txt. The command might take awhile to execute, depending on how many files and folders you have and once it is completed you will have a file containing each infected file.</p>
<p>The last step is to actually remove the code from the files. In 99% of the cases I&#8217;ve seen, the code is added either at the top of the file or at the bottom and is on its own separate line (if that is not the case with you, check the alternative sed commands provided below). This makes it really easy to remove it with one single command using the SED tool. Prior running the command, you should create a backup of your files, just in case something goes terribly wrong. Then run:</p>
<span class='style4-highlight-text'> for i in `cat infected.txt`; do sed &#8216;/<strong>jY3RCkAwF</strong>/d&#8217; -i $i ; done </span>
<p>The only thing to edit in the command is the bold text (just as with the grep, replace it with a few characters of code you found in your files). What the command does is as follows:</p>
<ol>
<li>It lists all results from the infected.txt file</li>
<li>For each of the results it runs sed &#8216;/code/d&#8217; which removes the line containing the &#8216;code&#8217; string</li>
<li>It then saves the file without that code</li>
</ol>
<p>That&#8217;s all about it. You should repeat this for each type of malicious code you found in step 1 (while using the find . -mtime command) and when finished, your website should be pretty clean.</p>
<p>&nbsp;</p>
<h2>Additional SED Commands</h2>
<p>Below are some additional/alternative sed commands which you might want to use:</p>
<ul>
<li>All-in-one command. It combines the grep and sed commands into one:</li>
</ul>
<span class='style4-highlight-text'> for i in `grep -r -l jY3RCkAwF *` ; do sed &#8216;/jY3RCkAwF/d&#8217; -i $i ; done </span>
<ul>
<li>Replace with opening tag, in case the malicious code is on the same line</li>
</ul>
<span class='style4-highlight-text'> for i in `cat infected.txt`; do sed &#8216;s/.*jY3RCkAwF.*/&lt;?php/&#8217; -i $i; done </span>
<ul>
<li>Delete the first n lines (3 in this example)</li>
</ul>
<span class='style4-highlight-text'> for i in `cat indected.txt`; do sed -i &#8217;1d;2d;3d&#8217; $i; done </span>
<ul>
<li>Delete the first line and add an opening php tag</li>
</ul>
<span class='style4-highlight-text'> for i in `cat infected.txt`; do sed &#8217;1i\&lt;?php&#8217; -i $i ; done </span>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://twolines.net/removing-malicious-eval-and-base64-code-from-your-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove &#8216;Your browser is out of date&#8217; warning in your WordPress dashboard</title>
		<link>http://twolines.net/how-to-remove-your-browser-is-out-of-date-warning-in-your-wordpress-dashboard/</link>
		<comments>http://twolines.net/how-to-remove-your-browser-is-out-of-date-warning-in-your-wordpress-dashboard/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 23:44:01 +0000</pubDate>
		<dc:creator>administrator</dc:creator>
				<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nag]]></category>
		<category><![CDATA[out-of-date]]></category>
		<category><![CDATA[outdated]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://twolines.net/?p=328</guid>
		<description><![CDATA[Certainly, at some point you are bound to see this error in your WordPress dashboard. Especially if you are using... <a href="http://twolines.net/how-to-remove-your-browser-is-out-of-date-warning-in-your-wordpress-dashboard/" class="more-link">more</a>]]></description>
			<content:encoded><![CDATA[<p>Certainly, at some point you are bound to see this error in your WordPress dashboard. Especially if you are using Chrome or Firefox, which are now racing who will post a new upgrade (I&#8217;ve tracked at least 3 minor updates to my Chrome browser in the last week!).</p>
<p>While the feature is a neat one and ensures that your visitors (and you) are able to use all features of the dashboard, it is somehow an added distraction. I personally wouldn&#8217;t want my visitors to actually focus on something which is NOT related to my own blog and sure enough, I do not want them to leave my website to upgrade their browser, simply because upgrading usually means that they would need to restart it (the browser) at some point and they might never return back, abandoning the task they came for.</p>
<p>Disabling this feature of the dashboard is rather easy. For the tech-savvy, there is an add_filter which can be used:</p>
<span class='style1-highlight-text'> add_filter( &#8216;site_transient_browser_[browser-name-version], [callback-function] ); </span>
<p>For everyone else, there is a plugin which will do all the work for you:</p>
<p><a title="No browser nag plugin" href="http://wordpress.org/extend/plugins/no-browser-nag/faq/" target="_blank">http://wordpress.org/extend/plugins/no-browser-nag/faq/</a></p>
<p>Installing the plugin is trivial and standard. <strong>Dashboard</strong> -&gt; <strong>Plugins</strong> -&gt; <strong>Add New</strong> section and either search for no-browser-nag and install it online or download it to your own computer and upload it via the install page.</p>
<p>It has no configurable options, since all it does is to enable/disable the out of date browser nag. Just activate it and you will never see the nag again.</p>
]]></content:encoded>
			<wfw:commentRss>http://twolines.net/how-to-remove-your-browser-is-out-of-date-warning-in-your-wordpress-dashboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

