<?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>Hawk Host Blog &#187; Tips</title>
	<atom:link href="http://blog.hawkhost.com/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hawkhost.com</link>
	<description>All things Hawk Host</description>
	<lastBuildDate>Mon, 23 Aug 2010 18:08:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>TMUX – The Terminal Multiplexer (Part 2)</title>
		<link>http://blog.hawkhost.com/2010/07/02/tmux-%e2%80%93-the-terminal-multiplexer-part-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=tmux-%25e2%2580%2593-the-terminal-multiplexer-part-2</link>
		<comments>http://blog.hawkhost.com/2010/07/02/tmux-%e2%80%93-the-terminal-multiplexer-part-2/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 20:03:05 +0000</pubDate>
		<dc:creator>Cody</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[tmux]]></category>

		<guid isPermaLink="false">http://blog.hawkhost.com/?p=798</guid>
		<description><![CDATA[In part 1 I went over the basics of tmux and how to utilize its basic features. In this portion I&#8217;m going to dive a bit more into customizing tmux to make it easier and prettier to work with. I&#8217;ll &#8230; <a href="http://blog.hawkhost.com/2010/07/02/tmux-%e2%80%93-the-terminal-multiplexer-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In <a title="The Terminal Multiplexer Part 1" href="http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/" target="_blank">part 1</a> I went over the basics of <em>tmux</em> and how to utilize its basic features. In this portion I&#8217;m going to dive a bit more into customizing <em>tmux</em> to make it easier and prettier to work with. I&#8217;ll also give some examples on how to utilize the client/server model.</p>
<p><span id="more-798"></span></p>
<p>Since this part is less of a tutorial and more of a tips / reference I decided a table of contents based layout would be a bit easier to use:</p>
<p><strong>Note: If you have any tips, tricks or pre-made configurations you want to contribute to this post please do so in the comments and I&#8217;ll append them to this post.</strong></p>
<p><strong>Note**: You can type the commands into a live tmux session or place them in ~/.tmux.conf file which is automatically loaded when tmux is started.</strong></p>
<p><strong>Modify tmux bindings</strong></p>
<ul>
<li><a href="#rebinding-action-key">Rebinding the action key (Ctrl-b)</a></li>
<li><a href="#bind-last-window">Bind a key to switch between last active window</a></li>
<li><a href="#rebinding-pane-bindings">Rebinding pane splitting bindings</a></li>
</ul>
<p><strong>Modify tmux looks &amp; style</strong></p>
<ul>
<li><a href="#modifying-tab-color">Modifying tab color &amp; looks</a></li>
<li><a href="#adding-information">Adding information to your session</a></li>
</ul>
<p><strong>Misc tips &amp; tricks</strong></p>
<ul>
<li><a href="#tmux-shell-scripting">Setting up your tmux environment via shell scripting</a></li>
<li><span style="color: #000000;"><a href="#tmux-window-activity">Notify you when a window has activity</a></span></li>
<li><span style="color: #000000;"><a href="#tmux-window-rename">Have tmux rename window automatically on command run</a></span></li>
</ul>
<h3>Modify tmux bindings</h3>
<p>By default <em>tmux</em> has a decent default layout for hotkeys however there are a few keys that either made my fingers contort into ways they shouldn&#8217;t have or keys I simply always forgot. Luckily <em>tmux</em> offers a very simple syntax to rebind any key.</p>
<h4 id="rebinding-action-key" style="font-size: 18px;">Rebinding the Action Key</h4>
<p>Here is how you can rebind the <strong><em>Ctrl-b</em> </strong>prefix to be something a bit easier to type. I personally use <strong><em>Ctrl-a</em></strong> similar to screen:</p>
<blockquote><p>set-option -g prefix C-a</p></blockquote>
<p><strong><em>Note: The &#8220;-g&#8221; switch stands for global so the binding will affect every window. Alternatively the set-option command accepts arguments to specify the session and target of that particular binding if you like.</em></strong></p>
<p>Now every subsequent command will be prefixed with <strong><em>Ctrl-a</em><span style="font-weight: normal;"> instead of </span><em>Ctrl-b</em><span style="font-weight: normal;">.</span></strong></p>
<h4 id="bind-last-window" style="font-size: 18px;">Binding a key for &#8220;last-window&#8221;</h4>
<p>One of my favorite screen hotkeys is the last window hotkey which allows you to quickly switch between the current window and last window that was active. By default tmux doesn&#8217;t have a binding for this however it can easily be achieved by using the following:</p>
<blockquote><p>bind-key C-a last-window</p></blockquote>
<p>What this does is binds <strong><em>Ctrl-a</em></strong> to switch between the last active window. To use this binding you would hit <strong><em>Ctrl-a</em></strong> twice (since the prefix is set to <em><strong>Ctrl-a</strong></em> and the binding <em><strong>Ctrl-a</strong></em>).</p>
<h4 id="rebinding-pane-bindings" style="font-size: 18px;">Rebinding the pane splitting bindings</h4>
<p>One of the most powerful features of tmux is the ability to natively split your windows into several panes. Unfortunately the default bindings to achieve this are simply unintuitive. As a result I&#8217;ve rebound the splitting commands to something I could remember:</p>
<blockquote><p>unbind % # Remove default binding since we&#8217;re replacing<br />
bind | split-window -h<br />
bind &#8211; split-window -v</p></blockquote>
<p>At first this may look odd but for me it&#8217;s easier to remember that <em><strong>&#8220;|&#8221;</strong></em> splits the screen vertically while <em><strong>&#8220;-&#8221;</strong></em> splits the screen horizontally.  To achieve the below window structure you would type the following sequence:</p>
<blockquote><p>Ctrl-a |<br />
Ctrl-a -<br />
Ctrl-a -</p></blockquote>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/07/splitting-panes.png"><img class="aligncenter size-medium wp-image-814" title="TMUX - Splitting Panes" src="http://blog.hawkhost.com/wp-content/uploads/2010/07/splitting-panes-300x182.png" alt="" width="300" height="182" /></a></p>
<p>The first <em><strong>Ctrl-a |</strong></em>command splits the current window in half. The active window is the pane on the right so the subsequent <strong><em>Ctrl-a -</em></strong> splits that window into two vertically. Hitting <em><strong>Ctrl-a -</strong></em> once more now splits that active window into two more by splitting it vertically.</p>
<p><strong><em>Note: Depending on the active layout you&#8217;re using the behavior of how the windows split may be different.</em></strong></p>
<h3>Modify tmux look &amp; style</h3>
<p>The default colors and style of tmux isn&#8217;t awful however it&#8217;s somewhat bland for my liking. I personally only have modified tmux slightly however it allows you to do quite a bit. In this section I&#8217;ll go over some of tmux&#8217;s style features.</p>
<h4 id="modifying-tab-color" style="font-size: 18px;">Modifying tab color &amp; looks</h4>
<p>By default the tab colors are pretty bland and it makes it difficult to distinguish the active window from the other windows. Here is the default tmux tabs vs. the modified ones (snippet below):</p>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-tabs.png"><img class="aligncenter size-full wp-image-822" title="tmux-tabs" src="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-tabs.png" alt="" width="221" height="34" /></a><a href="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-tabs2.png"><img class="aligncenter size-full wp-image-823" title="tmux-tabs2" src="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-tabs2.png" alt="" width="275" height="34" /></a>As you can see the latter version is much more clear and uses some variable expansions tmux provides (hostname, etc). You can achieve this output with the following:</p>
<blockquote><p># Set status bar<br />
set -g status-bg black<br />
set -g status-fg white<br />
set -g status-left &#8216;#[fg=green]#H&#8217;</p></blockquote>
<p>The first two commands set the background to black and the text to white. The third command is where the magic happens: the <strong>status-left </strong>command tells tmux to display the following text to the left of the terminal. The <strong><em>[fg=green]#H</em></strong> portion tells tmux to display the hostname of localhost and make it green. The <em><strong>#H</strong></em> portion is part of <em>tmux</em> variable expansion &#8211; please refer to the <a href="http://cheasy.de/tmux.pdf" target="_blank">man pages</a> for more information on other ones you can use.</p>
<p>That alone doesn&#8217;t account for highlighting the active window. If you want to do that use the following snippet:</p>
<blockquote><p># Highlight active window<br />
set-window-option -g window-status-current-bg red</p></blockquote>
<p>The <strong>set-window-option -g window-status-current-bg red </strong>command tells tmux to change the background of the current active window to red. The <strong>set-window-option </strong>command has several other options you can pass to it to achieve similar affects.</p>
<h4 id="adding-information" style="font-size: 18px;">Adding information to your session</h4>
<p>Sometimes it might be useful to add some information from your local machine to the <em>tmux</em> screen. Earlier we played with the <strong>status-left</strong> command which sets the left portion of the status bar. Let&#8217;s use the <strong>status-right</strong> command to add some information to the right side:</p>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-right-status.png"><img class="aligncenter size-full wp-image-826" title="tmux-right-status" src="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-right-status.png" alt="" width="661" height="33" /></a></p>
<p>As you can see I&#8217;ve added the amount of users logged in and the current load average for my computer. This was achieved with the following snippet:</p>
<blockquote><p>set -g status-right &#8216;#[fg=yellow]#(uptime | cut -d &#8220;,&#8221; -f 2-)&#8217;</p></blockquote>
<p>Similar to before the <strong>#[fg=yellow]</strong> portion tells tmux to make the font yellow. The <strong>#(uptime | cut -d &#8220;,&#8221; -f 2-)</strong> portion tells tmux to run that cmd and output it on the right of the status bar.</p>
<p><strong>Note: If you&#8217;re not familiar with shell scripting this command is very simple. It runs the <em>uptime</em> command and then passes it to the <em>cut</em> command which splits it at the commas (,). The <em>-f 2-</em> portion says to print out everything from the second comma onward.</strong></p>
<p><strong>Note**: By default the status bar is redrawn every 15 seconds however you can modify this by setting the <em>status-interval</em> command.</strong></p>
<h3>Misc tips &amp; tricks</h3>
<h4 id="tmux-shell-scripting" style="font-size: 18px;">Using shell scripting to setup your tmux enviroment</h4>
<p>Tmux allows you to easily run commands for your different sessions through the command line without having to ever login to the session. This also allows us to make a simple bootstrap script which will setup your tmux environment and log you into it. Here is an example script I personally use:</p>
<pre class="brush: bash;">
#!/bin/sh
tmux new-session -d -s hawkhost

tmux new-window -t hawkhost:1 -n 'Server1' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:2 -n 'Server2' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:3 -n 'Server3' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:4 -n 'Server4' 'ssh root@10.x.x.x'
tmux new-window -t hawkhost:5 -n 'Server5' 'ssh root@10.x.x.x'

tmux select-window -t hawkhost:1
tmux -2 attach-session -t hawkhost
</pre>
<p>The command <strong>new-session</strong> <strong>-d -s hawkhost </strong>creates a new <em>tmux</em> session, detaches it (so it doesn&#8217;t open in your current terminal) and names it <em>hawkhost</em> in this case.</p>
<p>The following set of <strong>new-window </strong>commands create five new windows and executes the command at the end. The arguments are broken down as follows: <strong>-t hawkhost :1 </strong>tells tmux to &#8220;target&#8221; the session <em><strong>hawkhost</strong></em> and the window with the id of <em><strong>1</strong><span style="font-style: normal;">. The <strong>-n &#8216;Server1&#8242; &#8216;ssh root@10.x.x.x&#8217;</strong> portion tells tmux to name the window </span><strong>Server1</strong><span style="font-style: normal;"> and execute the <strong><em>ssh root@10.x.x.x</em></strong> command in it.</span></em></p>
<p><em><span style="font-style: normal;">The last two commands are pretty straight forward. The <strong>select-window -t hawkhost:1</strong> command tells tmux that you want the active window the session to be </span><span style="font-style: normal;"><strong>hawkhost</strong></span><span style="font-style: normal;"> and window </span><span style="font-style: normal;"><strong>1</strong></span><span style="font-style: normal;">. The <strong>-2 attach-session -t hawkhost</strong> tells tmux you want to attach the terminal with 256 colors and attach to the session </span><span style="font-style: normal;"><strong>hawkhost</strong></span><span style="font-style: normal;">.</span></em></p>
<p><strong>Note: This is the command that brings the tmux session to the foreground. If you recall earlier when the script created the session we specified the </strong><em><strong>-d</strong></em><strong> switch which prevents it from loading in your terminal.</strong></p>
<h4 id="tmux-window-activity" style="font-size: 18px;">Notify you when a window has activity</h4>
<p>This quick snippet will have tmux notify you in the status area when a window has activity:</p>
<blockquote><p># Set window notifications<br />
setw -g monitor-activity on<br />
set -g visual-activity on</p></blockquote>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-window-activity.png"><img class="aligncenter size-full wp-image-839" title="tmux-window-activity" src="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-window-activity.png" alt="" width="410" height="59" /></a><a href="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-window-activity2.png"><img class="aligncenter size-full wp-image-840" title="tmux-window-activity2" src="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-window-activity2.png" alt="" width="343" height="37" /></a>As you can see in the first image it lets me know that there was activity in window 0 (in this case <strong><em>sleep 10 &amp;&amp; echo &#8220;narwhal&#8221;</em></strong> and switching the window).</p>
<h4 id="tmux-window-rename" style="font-size: 18px;">Automatic window rename</h4>
<p>You can have <em>tmux</em> rename the window to the command that is currently running. This is useful when you load up something such as <em>irssi</em> and the window is labeled accordingly:</p>
<blockquote><p># Automatically set window title<br />
setw -g automatic-rename</p></blockquote>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-window-rename.png"><img class="aligncenter size-full wp-image-846" title="tmux-window-rename" src="http://blog.hawkhost.com/wp-content/uploads/2010/07/tmux-window-rename.png" alt="" width="301" height="43" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2010/07/02/tmux-%e2%80%93-the-terminal-multiplexer-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>TMUX &#8211; The Terminal Multiplexer (Part 1)</title>
		<link>http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=tmux-the-terminal-multiplexer</link>
		<comments>http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 15:31:05 +0000</pubDate>
		<dc:creator>Cody</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[tmux]]></category>
		<category><![CDATA[tmux tutorial]]></category>

		<guid isPermaLink="false">http://blog.hawkhost.com/?p=587</guid>
		<description><![CDATA[tmux is similar to screen as it lets you run numerous TTY&#8217;s in the same terminal window. It supports some very cool and intuitive features natively as well as a much more readable configuration syntax (ever looked at a .screenrc &#8230; <a href="http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/2.png"></a>tmux</em> is similar to <em>screen</em> as it lets you run numerous TTY&#8217;s in the same terminal window. It supports some very cool and intuitive features natively as well as a much more readable configuration syntax (ever looked at a .screenrc file?).</p>
<p><span id="more-587"></span></p>
<h3>Why TMUX over Screen?</h3>
<p>Well according to the FAQ for <em>tmux</em> it has the following advantages over screen:</p>
<ul>
<li>A clearly defined cilent/server model (windows are their own clients which allows flexibility on how you handle windows. You can attach and detach different windows in different sessions without any issues)</li>
<li>Consistent, well-documented command interface. (You can use the same commands interactively as in the .tmux.conf file, more on that later)</li>
<li>Easily scriptable</li>
<li>Multiple paste buffers</li>
<li>Vi &amp; Emacs keybindings</li>
<li>A more usable status line syntax (which also allows you to embed the output of a shell command, handy indeed.</li>
</ul>
<h3>Default keybindings &amp; Functionality</h3>
<p>The default keybindings for tmux are actually pretty intuitive, though if you&#8217;re used to screen you&#8217;ll likely get a little peeved with the default action binding of <em>C-b</em>, though this is easily changed to mimic screens behavior:</p>
<p><strong>*NOTE* </strong>If you&#8217;re like me the <em>Ctrl-b</em> binding isn&#8217;t horribly intuitive especially if you&#8217;re used to <em>screen</em>. You can rebind this by putting the following in <strong><em>~/.tmux.conf</em><span style="font-weight: normal;">:</span></strong></p>
<blockquote><p><strong><span style="font-weight: normal;">set -g prefix Ctrl-a</span></strong></p></blockquote>
<ul>
<li><strong><em>Ctrl-b c</em></strong> Create new window</li>
<li><strong><em>Ctrl-b d</em></strong> Detach current client</li>
<li><em><strong>Ctrl-b l</strong></em> Move to previously selected window</li>
<li><em><strong>Ctrl-b n</strong></em> Move to the next window</li>
<li><em><strong>Ctrl-b p</strong></em> Move to the previous window</li>
<li><em><strong>Ctrl-b &amp;</strong></em> Kill the current window</li>
<li><em><strong>Ctrl-b ,</strong></em> Rename the current window</li>
<li><em><strong>Ctrl-b %</strong></em> Split the current window into two panes</li>
<li><em><strong>Ctrl-b q</strong></em> Show pane numbers (used to switch between panes)</li>
<li><em><strong>Ctrl-b o</strong></em> Switch to the next pane</li>
<li><em><strong>Ctrl-b ?</strong></em> List all keybindings</li>
</ul>
<p>Now these are pretty self explanatory &#8211; the real magic (for me) of <em>tmux</em> is the ease of modifying the default behavior to do what <em>you</em> want, but first things first: let&#8217;s explore the default behavior of <em>tmux.</em></p>
<h3>Basic Window Handling</h3>
<p>Start up tmux with the tmux command and you should be greeted with a simplistic terminal window that resembles screen &#8211; the only difference is it has a default status bar which is nice (easily added to screen as well).</p>
<p style="text-align: center;"><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/1.png"><img class="size-medium wp-image-753 aligncenter" title="TMUX" src="http://blog.hawkhost.com/wp-content/uploads/2010/06/1-300x219.png" alt="Terminal Multiplexer" width="300" height="219" /></a></p>
<p>Now let&#8217;s create a couple of windows and go through them (we&#8217;ll be using the default bindings). Hit <em><strong>Ctrl-b c</strong></em> a few times to create a few windows, you should notice that there are more tabs in the status bar.</p>
<p>Now if you&#8217;re like me you like to have descriptive names of which each window is for, so let&#8217;s rename them by hitting <em><strong>Ctrl-b ,</strong></em>. It should prompt you to rename the current window &#8211; type anything you want and hit enter. Now the current window is renamed to what you specified. Now going forward I&#8217;m going to have two windows open respectively named &#8220;window1&#8243; and &#8220;window2&#8243;.</p>
<p>Once you rename your windows lets switch back and forth. We have several different ways of switching windows, so I&#8217;ll go over the ones I personally use:</p>
<ul>
<li><em><strong>Ctrl-b n</strong></em> (Move to the next window)</li>
<li><em><strong>Ctrl-b p</strong></em> (Move to the previous window)</li>
<li><em><strong>Ctrl-b l</strong></em> (Move to the previously selected window)</li>
<li><em><strong>Ctrl-b w</strong></em> (List all windows / window numbers)</li>
<li><em><strong>Ctrl-b &lt;window number&gt;</strong></em> (Move to the specified window number, the default bindings are from 0 &#8211; 9)</li>
</ul>
<p>Now these ones fairly self explanatory however they don&#8217;t really cater to a lot of different windows. What if you have 10+ windows open? It becomes quite tedious to find the window you want &#8211; but don&#8217;t fret! Tmux has a <em>find-window</em> option &amp; keybinding. Type <em><strong>Ctrl-b f</strong></em> and type in the window name you want (it actually searches for the window so you can type in only part of the name of the window you&#8217;re looking for).</p>
<p>You can also get a list of the windows in the current session by executing the <em>list-windows</em> command. To execute commands interactively you type <em><strong>Ctrl-b :</strong></em> which will bring up a text prompt. From there you can execute any command <em>tmux</em> supports interactively (tab completion is supported).</p>
<p style="text-align: center;"><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/2.png"><img class="aligncenter size-medium wp-image-761" title="TMUX - Interactive Prompt" src="http://blog.hawkhost.com/wp-content/uploads/2010/06/2-300x218.png" alt="Terminal Multiplexer - Interactive Prompt" width="300" height="218" /></a><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/3.png"><img class="aligncenter size-medium wp-image-759" title="TMUX - List Windows" src="http://blog.hawkhost.com/wp-content/uploads/2010/06/3-300x218.png" alt="Terminal Multiplexer - List Windows" width="300" height="218" /></a></p>
<h3>Basic Pane Handling</h3>
<p>One of the most powerful features tmux offers is the ability to split up your current window into &#8220;panes&#8221;. Anyone whose familiar with tiling windows managers will feel quite at home. It&#8217;s a bit difficult to explain this in words so a simple screenshot will suffice:</p>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/4.png"><img class="aligncenter size-medium wp-image-765" title="TMUX - Split Windows" src="http://blog.hawkhost.com/wp-content/uploads/2010/06/4-300x219.png" alt="Terminal Multiplexer - Split Windows" width="300" height="219" /></a></p>
<p>Now here are some basic key bindings and commands to split the terminal window (vertically and horizontally) and to switch between them</p>
<ul>
<li><em><strong>Ctrl-b %</strong></em> (Split the window vertically)</li>
<li><em><strong>Ctrl-b : &#8220;split-window&#8221;</strong></em> (Split window horizontally)</li>
<li><em><strong>Ctrl-b o</strong></em> (Goto next pane)</li>
<li><em><strong>Ctrl-b q</strong></em> (Show pane numbers, when the numbers show up type the key to goto that pane)</li>
<li><em><strong>Ctrl-b {</strong></em> (Move the current pane left)</li>
<li><em><strong>Ctrl-b }</strong></em> (Move the current pane right)</li>
</ul>
<p>Now some obviously the default bindings don&#8217;t encompass some of features, such as splitting horizontally. I personally rebind the keys so &#8220;|&#8221; splits the current window vertically, and &#8220;-&#8221; splits it horizontally. Not the easiest things to type, though easy to remember.</p>
<p>You can achieve this by putting the following in <strong><em>~/.tmux.conf </em><span style="font-weight: normal;">or by typing it in the interactive prompt (</span><em>Ctrl-b :</em><span style="font-weight: normal;">). Keep in mind if you do the latter it will only be in effect for that session:</span></strong></p>
<blockquote><p><strong><span style="font-weight: normal;">unbind %<br />
bind | split-window -h<br />
bind &#8211; split-window -v </span></strong><strong><span style="font-weight: normal;"> </span></strong></p></blockquote>
<h3>Advanced Window Handling</h3>
<p>Now that we went over the basics lets dive a little deeper into some &#8220;advanced&#8221; features of <em>tmux</em>. This includes moving windows around, linking windows together, switching windows from different sessions and much more. By default <em>tmux</em> doesn&#8217;t have key bindings for these features, so we&#8217;ll be entering them in the interactive dialog (accessed by typing <em><strong>Ctrl-b :</strong></em>) &#8211; keep in mind <em>tmux</em> is very scriptable and you can easily create your own key bindings for all of these.</p>
<h3>Moving Windows</h3>
<p>Now if you want to move a window you can use the <strong><em>move-window</em></strong> command. The command to do this:</p>
<blockquote>
<div id="_mcePaste">move-window [ −d] [ −s src-window] [ −t dst-window]</div>
<div>swap-window [ -d] [ -s src-window] [ -t dst-window]</div>
</blockquote>
<p>Similar to the above command except both windows have to exist &#8211; if they both do the window with the ID source and destination windows will be swapped.</p>
<h3>Advanced Pane Handling</h3>
<p>When you split up a window into multiple smaller windows they&#8217;re referred to as panes. Tmux also offers &#8220;layouts&#8221; for the panes, or the default positioning and behavior when you create a new window. You can switch through the panes by using the key binding <em><strong>Ctrl-b &lt;space&gt;</strong></em> which will toggle through the different layouts. Each one has different behaviors such as <em><strong>main-vertical</strong></em> which means the current active pane will take up more space in the current window, or <strong><em>even-vertical</em></strong> which will split the panes equally. Since this is difficult to describe in text I believe a few screen shots are in order:</p>
<p style="text-align: center;"><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/main-vertical.png"><img class="aligncenter size-medium wp-image-776" title="main-vertical" src="http://blog.hawkhost.com/wp-content/uploads/2010/06/main-vertical-300x219.png" alt="" width="300" height="219" /></a><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/even-horizontal.png"><img class="aligncenter size-medium wp-image-774" title="even-horizontal" src="http://blog.hawkhost.com/wp-content/uploads/2010/06/even-horizontal-300x218.png" alt="" width="300" height="218" /></a><a href="http://blog.hawkhost.com/wp-content/uploads/2010/06/even-vertical.png"><img class="size-medium wp-image-775 aligncenter" title="even-vertical" src="http://blog.hawkhost.com/wp-content/uploads/2010/06/even-vertical-300x218.png" alt="" width="300" height="218" /></a></p>
<p>Now that you&#8217;ve seen the different layouts let&#8217;s see what we can do with these panes. As mentioned above in the &#8220;Pane Handling&#8221; section you can switch through panes by issuing the <em><strong>Ctrl-b o</strong></em> key combination (which is using the <em><strong>down-pane</strong></em> command) or by typing <em><strong>Ctrl-b q</strong></em> which will list the pane ID&#8217;s and you select the one you want.</p>
<h3>Make your pane into its own window</h3>
<p>If you want to take a pane and make it into its own window you do the following:</p>
<blockquote><p><strong>Ctrl-b : &#8220;break-pane&#8221;</strong></p></blockquote>
<p>Simple enough, you should now have the pane in its brand new window. If you don&#8217;t want it to automatically make the pane you just broke out as the active window issue the &#8220;-d&#8221; switch which will simply break the pane to a new window but keep you in the current window.</p>
<h3>Resizing Panes</h3>
<p>You can also resize panes if you don&#8217;t like the layout defaults. I personally rarely need to do this, though it&#8217;s handy to know how. Here is the basic syntax to resize panes:</p>
<blockquote><p><strong>Ctrl-b : resize-pane</strong> (By default it resizes the current pane down)<br />
<strong> Ctrl-b : resize-pane -U</strong> (Resizes the current pane upward)<br />
<strong> Ctrl-b : resize-pane -L</strong> (Resizes the current pane left)<br />
<strong> Ctrl-b : resize-pane -R</strong> (Resizes the current pane right)<br />
<strong> Ctrl-b : resize-pane 20</strong> (Resizes the current pane down by 20 cells)<br />
<strong> Ctrl-b : resize-pane -U 20</strong> (Resizes the current pane upward by 20 cells)<br />
<strong> Ctrl-b : resize-pane -L 20</strong> (Resizes the current pane left by 20 cells)<br />
<strong> Ctrl-b : resize-pane -R 20</strong> (Resizes the current pane right by 20 cells)<br />
<strong> Ctrl-b : resize-pane -t 2 20</strong> (Resizes the pane with the id of 2 down by 20 cells)<br />
<strong> Ctrl-b : resize-pane -t -L 20</strong> (Resizes the pane with the id of 2 left by 20 cells)<br />
&#8230; etc</p></blockquote>
<p>Hopefully you get the jist &#8211; don&#8217;t get confused! Simply load up a tmux session and split the window a couple of times and issue the above commands. It should become fairly evident how it behaves after fiddling with it for a bit.</p>
<h3>Utilizing the client / server model</h3>
<p>I&#8217;ve avoided mentioning that a lot of these commands can actually be applied to numerous tmux sessions which allows quite a bit of flexibility &#8211; the reason for avoiding it is it&#8217;s too much information all at once! An example of using this functionality is if you have two sessions open you can &#8220;link&#8221; or &#8220;move&#8221; windows across different sessions &#8211; unfortunately the actual &#8220;how-to&#8221; will be in Part 2.</p>
<h3>Conclusion</h3>
<p>Tmux may be a bit confusing however it&#8217;s worth putting in a few minutes to check it out and see what it has to offer &#8211; quick easy and intuitive.</p>
<h3>Upcoming in Part 2</h3>
<p>I&#8217;ll be going over several tips and tricks for tmux including:</p>
<ul>
<li>Custom hotkeys</li>
<li>Custom window styles &amp; colors</li>
<li>Scripting with <em>tmux</em> (bash, sh)</li>
<li>How to use the server / client model further</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to Install and Configure Litespeed for cPanel</title>
		<link>http://blog.hawkhost.com/2010/04/23/how-to-install-configure-litespeed-for-cpanel/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-install-configure-litespeed-for-cpanel</link>
		<comments>http://blog.hawkhost.com/2010/04/23/how-to-install-configure-litespeed-for-cpanel/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 18:36:38 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.hawkhost.com/?p=691</guid>
		<description><![CDATA[Unless you&#8217;ve been living under a rock you know we run Litespeed and have so for a year now.  I&#8217;ve noticed since we&#8217;ve been using Litespeed the installation information and tutorials as far as setting it up in a cPanel &#8230; <a href="http://blog.hawkhost.com/2010/04/23/how-to-install-configure-litespeed-for-cpanel/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Unless you&#8217;ve been living under a rock you know we run Litespeed and have so for a year now.  I&#8217;ve noticed since we&#8217;ve been using Litespeed the installation information and tutorials as far as setting it up in a cPanel environment have become really out of date.  This could be my fault with asking for fixes and features to be added to cater to cPanel and solve various problems.  Obviously I don&#8217;t know if that&#8217;s correct it&#8217;s me causing it but since we started using it seems like we&#8217;ve found a lot of issues relating to cPanel integration with have been fixed.  Unfortunately though the wiki entries Litespeed has on their site still reference things not necessary anymore.  So I&#8217;m going to quickly run by how to install and setup Litespeed on a cPanel server.<span id="more-691"></span></p>
<p>So first of all obviously you&#8217;ll want to have a license then go and download Litespeed from their <a href="http://www.litespeedtech.com/litespeed-web-server-downloads.html">download page</a>.</p>
<p>You&#8217;ll extract the archive and run through the installer picking cPanel as your control panel then everything else should be fine as the defaults.  I&#8217;m avoiding talking about these early steps as really if you cannot download a file then run the installer then you should have a system admin.</p>
<p>So now we&#8217;ve got Litespeed installed but now is where you need to start configuring things.  By default Litespeed is not configured to be exactly like Apache in some ways so could cause issues for some users.  The first thing I do is login to the control panel which would be http://yourip:7080/</p>
<p>So you&#8217;ll be greeted with a page like this:</p>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/04/lsws_mainpage.png"><img class="aligncenter size-medium wp-image-692" title="Litespeed Main Page" src="http://blog.hawkhost.com/wp-content/uploads/2010/04/lsws_mainpage-300x145.png" alt="" width="300" height="145" /></a></p>
<p>So from here you&#8217;ll want to go to configuration so you&#8217;ll be sent to the following page:</p>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/04/lsws_configuration_page.png"><img class="aligncenter size-medium wp-image-693" title="lsws_configuration_page" src="http://blog.hawkhost.com/wp-content/uploads/2010/04/lsws_configuration_page-300x221.png" alt="" width="300" height="221" /></a></p>
<p>The first step is to go to the log page and change the debug level to none and and log level to INFO.  So like the picture below</p>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/04/lsws_log.png"><img class="aligncenter size-medium wp-image-696" title="LSWS Log Page" src="http://blog.hawkhost.com/wp-content/uploads/2010/04/lsws_log-300x59.png" alt="" width="300" height="59" /></a></p>
<p>Obviously in your case you&#8217;ll click the edit button then save it rather than looking at just the text version like the screen shot.</p>
<p>So now you&#8217;ve set the logs next you need to change the auto index which you do back on the general configuration page you at the index files portion.  You&#8217;ll want to set it as follows:</p>
<blockquote><p>Auto Index =&gt; Yes<br />
Auto Index URI =&gt; /_autoindex/default.php</p></blockquote>
<p>Then as root you&#8217;ll want to run</p>
<blockquote><p>ln -sf /usr/local/lib/php/autoindex /usr/local/lsws/share/autoindex</p></blockquote>
<p>Now finally on the same general configuration page if you plan on supporting frontpage extensions you&#8217;ll want to turn it on.  You do this under the Using Apache Configuration File portion of the general configuration page.</p>
<p>Once you&#8217;ve done all of this restart Litespeed as it&#8217;ll be asking you to and all your changes will take effect.</p>
<p>You&#8217;ve now setup Litespeed from the panel side it should act pretty much the same as Apache as far as the users are concerned.  They&#8217;ll have the error log portions working in cPanel and nothing extra confusing for them.  The auto index when no index file is found will work as expected no weird errors there.  Then finally if you choose to support frontpage extensions they should work fine with no changes from your end.  This is one portion the wiki is out of date on now none of the commands it says to run are actually necessary.</p>
<p>We&#8217;re not done yet though we still have to configure PHP which is very easy to do.  Login to your WHM and go to plugins on the left menu and you&#8217;ll see a LiteSpeed Web Server link.  Your page should look something like this:</p>
<p><a href="http://blog.hawkhost.com/wp-content/uploads/2010/04/litespeed_whm_plugin.png"><img class="aligncenter size-medium wp-image-698" title="Litespeed WHM Plugin" src="http://blog.hawkhost.com/wp-content/uploads/2010/04/litespeed_whm_plugin-300x102.png" alt="" width="300" height="102" /></a></p>
<p>The first step on this page is to get the same PHP version on Litespeed as you have on Apache.  What you want to select is the Build Matching PHP Binary option which will look at your current PHP version in Apache.  What it will attempt to do is use the source from /home/cpeasyapache/src if available to build it&#8217;s PHP identical to cPanel as it would use the cPanel PHP source.  If it&#8217;s not available then it will download it&#8217;s own copy from php.net and build the same options in from there.</p>
<p>You give that 10 minutes and now you just need to switch to Litespeed which you do from the switch to LiteSpeed option from the WHM plugin.  It will turn off Apache and turn on Litespeed and have it read the httpd.conf file.  Then you just need to check make sure everything is still working as it should.  If it&#8217;s a production server you can also access Litespeed from an alternate port when Apache is still running which typically is 2080.  So you could go to http://somesite.com:2080/ and make sure it&#8217;s PHP works fine and such.</p>
<p>Well I hope that was helpful to anyone out there trying to configure Litespeed and are not sure what portions of their wiki are up to date and which are not.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2010/04/23/how-to-install-configure-litespeed-for-cpanel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Suspension Pages &#8211; The Unforeseen Bane Of Web Hosting</title>
		<link>http://blog.hawkhost.com/2010/03/29/suspension-pages-the-unforeseen-bane-of-web-hosting/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=suspension-pages-the-unforeseen-bane-of-web-hosting</link>
		<comments>http://blog.hawkhost.com/2010/03/29/suspension-pages-the-unforeseen-bane-of-web-hosting/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 01:58:14 +0000</pubDate>
		<dc:creator>Cody</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[scaling]]></category>
		<category><![CDATA[suspension]]></category>

		<guid isPermaLink="false">http://blog.hawkhost.com/?p=677</guid>
		<description><![CDATA[A few months ago we created a custom suspension page for shared accounts that are suspended. Now normally this is pretty straightforward task and you wouldn&#8217;t put much thought into it &#8211; we didn&#8217;t either. So we went ahead and &#8230; <a href="http://blog.hawkhost.com/2010/03/29/suspension-pages-the-unforeseen-bane-of-web-hosting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few months ago we created a custom suspension page for shared accounts that are suspended. Now normally this is pretty straightforward task and you wouldn&#8217;t put much thought into it &#8211; we didn&#8217;t either. So we went ahead and setup a sub-domain, modified our layout accordingly setup cPanel. That&#8217;s it!</p>
<p>Well they say hindsight is 20/20 and we would tend to agree. Suddenly we got a huge surge of traffic from suspended accounts which was to be expected but due to a single oversight we had to skurry before the server decided to go kaput: PHP! We use PHP (Zend Framework, etc) for our website and portal so naturally we carried over some code from our website to our suspension page without thinking about the amount of traffic that would be hitting it. The result was a large amount of PHP processes bogging down the CPU causing our suspension page to almost become suspended itself. Obviously to fix it we simply put up a static page and called it a day.</p>
<h2>Oops!</h2>
<p><strong>Moral of the story: </strong>Even the most trivial of things can cause issues to a server; this is even more true when you&#8217;re running robust scripts such as WordPress in a shared environment. Think about<a href="http://blog.hawkhost.com/2009/09/13/why-you-should-use-wp-super-cache/"> caching and scaling</a> in general &#8211; not only will you learn you&#8217;ll prevent silly mistakes. One common issue we see constantly in our environment is people setup their 404&#8242;s to a non-static / heavily dynamic page and as a result if they get any sort of flux of traffic / spiders to the 404 pages their MySQL and CPU usage goes insane. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2010/03/29/suspension-pages-the-unforeseen-bane-of-web-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using netcat as an intercepting proxy</title>
		<link>http://blog.hawkhost.com/2009/12/12/using-netcat-as-an-intercepting-proxy/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-netcat-as-an-intercepting-proxy</link>
		<comments>http://blog.hawkhost.com/2009/12/12/using-netcat-as-an-intercepting-proxy/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 20:47:11 +0000</pubDate>
		<dc:creator>Cody</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.hawkhost.com/?p=580</guid>
		<description><![CDATA[A couple of days ago I needed a way to see how a particular client was interacting with a server. Obviously there are numerous ways to do this, but I was curious how easy it would be to implement something &#8230; <a href="http://blog.hawkhost.com/2009/12/12/using-netcat-as-an-intercepting-proxy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I needed a way to see how a particular client was interacting with a server. Obviously there are numerous ways to do this, but I was curious how easy it would be to implement something similar with a quick <a href="http://en.wikipedia.org/wiki/Netcat">netcat</a> command. Sure enough after a little bit of fiddling I was able to produce exactly what he needed.</p>
<blockquote><p>nc -l -p 12345 &lt; pipe | tee outgoing.log | nc server 12345 | tee pipe incoming.log</p></blockquote>
<p>Now this may seem a little cryptic so I&#8217;m going to dissect each portion to explain how it works. Keep in mind the &#8220;pipe&#8221; references an actual <a href="http://en.wikipedia.org/wiki/Named_pipe">pipe</a>. You can make a FIFO pipe by running &#8220;<a href="http://linux.die.net/man/3/mkfifo">mkfifo</a> pipe&#8221; or &#8220;<a href="http://linux.die.net/man/3/mknod">mknod</a> pipe p&#8221; &#8211; the former is the most usual way. If you&#8217;re not familiar with named pipes I recommend <a href="http://en.wikipedia.org/wiki/Named_pipe">reading up on them</a> before continuing with this post as you may get a little confused.</p>
<blockquote><p>nc -l -p 12345 &lt; pipe</p></blockquote>
<p>This portion simply has netcat listen on port 12345 and send anything from the pipe to the connected client. If you&#8217;re not familiar with the pipes think of it as a simple file with the word &#8220;hello&#8221; in it. When someone were to successfully connect to the netcat instance it would send the &#8220;hello&#8221; to the client.</p>
<p><span id="more-580"></span></p>
<blockquote><p>| tee outgoing.log</p></blockquote>
<p>If you&#8217;re not familiar with <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?tee">tee</a> this may seem a bit obscure. Tee prints the things piped to it to stdout as well as writing it to a file. In this instance any traffic from the connected client will get printed to stdout and to the file &#8220;outgoing.log&#8221;. An example of how this would work is if I connected to the netcat instance and simply typed &#8220;hello&#8221; it would print it out to the screen and log it to the &#8220;outgoing.log&#8221; file.</p>
<blockquote><p>| nc server 12345</p></blockquote>
<p>This is the server that you would normally want to connect to. Remember the goal is to make a quick intercepting proxy to see how the client reacts to the server. This is the server.</p>
<blockquote><p>| tee pipe incoming.log</p></blockquote>
<p>Here is where the magic happens. This completes the relay so the client and server can communicate across the proxy. What this does is takes the network traffic from the server and using tee prints it to stdout while piping it to our &#8220;pipe&#8221; and &#8220;incoming.log&#8221; files respectively.</p>
<p>Now all of this may make sense individually, though how they work together might be slightly confusing.</p>
<p>If you recall the first command sends all data from our &#8220;pipe&#8221; to the client &#8211; and at the end we pipe all data from the server to the &#8220;pipe&#8221;. See now? We&#8217;re simply taking all data the server send and sending it to the client completing the relay and allowing for normal operation.</p>
<p>Now in this case I needed this for a quick look at how a normal IRC client interacts with the server since the RFC is lacking &#8211; so here is a real world example of where this was used (though there&#8217;s likely infinite better ways to do it):</p>
<blockquote><p>nc -l -p 12345 &lt; pipe | tee outgoing.log | nc irc.freenode.net 6667 | tee pipe incoming.log</p></blockquote>
<p>You&#8217;ll notice when you execute the above command you&#8217;ll start seeing some traffic from the server instantly:</p>
<blockquote><p>NOTICE AUTH :*** Looking up your hostname&#8230;<br />
NOTICE AUTH :*** Checking ident<br />
NOTICE AUTH :*** No identd (auth) response<br />
NOTICE AUTH :*** Couldn&#8217;t look up your hostname</p></blockquote>
<p>Now we connect to the netcat server &#8211; in this case localhost on port 12345 and if everything goes as planned it should connect like normal to Freenode. If you take a peak at the netcat server you&#8217;ll see a bunch of activity!</p>
<p>The cool part is the logs &#8211; we can see exactly how this particular IRC client (IRSSI) and server (Freenode) interact.</p>
<p><a href="http://rhinoass.com/incoming.log">incoming.log</a><br />
<a href="http://rhinoass.com/outgoing.log">outgoing.log</a></p>
<p>Once again this isn&#8217;t the best way to do this &#8211; tcpdump, wireshark and infinite other choices are available. That being said it&#8217;s fun to fiddle and learn.</p>
<p>-Cody</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2009/12/12/using-netcat-as-an-intercepting-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Theme Performance</title>
		<link>http://blog.hawkhost.com/2009/09/24/wordpress-theme-performance/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wordpress-theme-performance</link>
		<comments>http://blog.hawkhost.com/2009/09/24/wordpress-theme-performance/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 21:00:02 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.hawkhost.com/?p=511</guid>
		<description><![CDATA[When people are looking for a wordpress theme they very rarely are looking at the performance of it.  The person is looking at how pretty the design is and if it fits their site.  There is however a lot more &#8230; <a href="http://blog.hawkhost.com/2009/09/24/wordpress-theme-performance/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When people are looking for a wordpress theme they very rarely are looking at the performance of it.  The person is looking at how pretty the design is and if it fits their site.  There is however a lot more to it then simple the design of the wordpress.  A wordpress theme can add a lot of extra CPU and memory usage depending on how it&#8217;s designed.</p>
<p>I&#8217;m seeing more and more where wordpress themes are not using style.css or at least .css for their style sheets.  More and more they are using style.php which in turn simply outputs the style sheet.  This sort of setup suddenly requires an extra PHP process every page load thus increased memory as well to compensate.  The fact it&#8217;s just going to output CSS still does not matter it&#8217;s really bad to be doing.  This is especially bad when a wordpress blog is running say wp-super-cache they&#8217;re probably trying to serve everything via html files.  Well that purpose is defeated when every page load PHP is loading up to serve their style sheet.  Now as to why more themes are doing this I&#8217;m not sure maybe it&#8217;s make them look more professional in the eyes of the users I have no idea.</p>
<p>Of course if you see style sheets being displayed via php you also get the same thing with java script.  All the js files become js.php with simply the javascript being output in the php file.  There is no actual using of PHP logic besides the print &#8220;js stuff&#8221;</p>
<p>There is one other problem I see quite a bit and that&#8217;s extra features included in the theme.  For example we&#8217;ve had several users use themes with phpthumb included.  The theme was using it in several places to make smaller images of portions.  Along with that they also did not configure it properly and some bots found it and started using the install to generate thumbnails for other web sites.<br />
That&#8217;s just a few examples but I would advise anyone when installing a wordpress theme take a look at what it offers and what it&#8217;s doing.  If it&#8217;s using php files everywhere you might want to see if it&#8217;s actually necessary.  If they include extra features or include third party scripts you might want to check if they even set it up properly.  I would not rely on the theme developers on these sort of things.  I&#8217;ve seen some free themes not even doing relative paths properly resulting in serving images and such via their own demo of their script.  So I really would not trust the theme maker has done a great job with the other aspects of the theme.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2009/09/24/wordpress-theme-performance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>cPanel x86_64 Reseller unable to Add Packages</title>
		<link>http://blog.hawkhost.com/2009/09/14/cpanel-x86_64-reseller-unable-to-add-packages/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=cpanel-x86_64-reseller-unable-to-add-packages</link>
		<comments>http://blog.hawkhost.com/2009/09/14/cpanel-x86_64-reseller-unable-to-add-packages/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 00:43:48 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.hawkhost.com/blog/?p=505</guid>
		<description><![CDATA[Using 64bit is really common now in fact most hosts are using this on their newer systems due to using more than 4GB of memory.  On cPanel there is a common problem that crops up with errors showing up after &#8230; <a href="http://blog.hawkhost.com/2009/09/14/cpanel-x86_64-reseller-unable-to-add-packages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using 64bit is really common now in fact most hosts are using this on their newer systems due to using more than 4GB of memory.  On cPanel there is a common problem that crops up with errors showing up after a while in WHM for resellers after there is quite a few accounts on the server.  cPanel sets the memory limit relatively low and on 64bit systems int&#8217;s and such are using more memory due to the 64bit system.  cPanel added a feature which allows you to set a maximum amount of memory used by a cPanel process before it is killed.  As a result in 64bit systems they&#8217;re more frequently hitting the modest 256MB limit while 32bit systems do not run into this issue as often.  The reseller user will receive the following error when adding a package:</p>
<blockquote><p><span>[an error occurred while processing this directive]</span></p></blockquote>
<p>The user will see this error over and over again when adding the package.  There is also an error in the cPanel error_log which I cannot remember at this point as we had a machine give this error a while back.  The thing is we know what causes it now so I did not bother checking the error_log of cPanel.  So all you need to do is go into tweak settings and find the following setting:</p>
<blockquote><p>The maximum memory a cPanel process can use before it is killed off (in megabytes). Values less than 256 megabytes can not be specified. A value of &#8220;0&#8243; will disable the memory limits.</p></blockquote>
<p>We typically set this value at 768-1024 MB on our higher end systems (12GB ram total).</p>
<p>Do not feel bad if you did not know as I honestly did not until I made a ticket with cPanel support.  Even then at the time they needed to login to figure out what was causing it.  It&#8217;s really not a well documented problem but it seems to be coming up more often now.  You probably see the same thing with other applications and even the languages themselves.  For example PHP the memory limit of 32MB is really problematic on 64bit systems which is why we use 128MB.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2009/09/14/cpanel-x86_64-reseller-unable-to-add-packages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why You Should Use WP-Super-Cache</title>
		<link>http://blog.hawkhost.com/2009/09/13/why-you-should-use-wp-super-cache/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=why-you-should-use-wp-super-cache</link>
		<comments>http://blog.hawkhost.com/2009/09/13/why-you-should-use-wp-super-cache/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 19:48:02 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.hawkhost.com/blog/?p=502</guid>
		<description><![CDATA[At Hawk Host we deal with CPU usage issues with accounts like every other host out there.  I&#8217;ve noticed an ever growing pattern of the problems always coming from WordPress blogs and almost always they have no caching what so &#8230; <a href="http://blog.hawkhost.com/2009/09/13/why-you-should-use-wp-super-cache/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At Hawk Host we deal with CPU usage issues with accounts like every other host out there.  I&#8217;ve noticed an ever growing pattern of the problems always coming from WordPress blogs and almost always they have no caching what so ever.  When a web page is served without any caching in wordpress it will load up PHP then grab the data via MySQL.  These are both the slowest and most intensive portions of a web page.  The images, css files ect. are all served nearly instantly by the web server and it can serve a lot more of these static files per second then PHP pages.</p>
<p>This is where WP-Super-Cache comes into play what it does is when pages are served the first time it checks the caches and if they do not exist it then creates the cached file and serves it.  It has two options using rewrite rules to send users to .html versions if they&#8217;re available or to have PHP still handle it but load the PHP files instead.  How the HTML version works is the rewrite rules it inserts into the .htaccess file checks for file existence in the cache folder and if it&#8217;s there that&#8217;s where the file is served out of.  This is the ideal situation as no PHP being loaded at all means a server can handle a lot of traffic meaning even being on the frontpage of digg may very well be handled fairly easily.  There are some cases where users forget this portion so we always make sure to remind users to get the rewrite rules in.  In a lot of cases their blog goes from using a lot of resources under traffic to being a user we have no idea we&#8217;re even hosting.</p>
<p>So how do you know if the cache is working?  Well on each page if you view the HTML source you&#8217;ll see something like this:</p>
<blockquote><p>&lt;!&#8211; Dynamic page generated in 0.277 seconds. &#8211;&gt;<br />
&lt;!&#8211; Cached page generated by WP-Super-Cache on 2009-09-13 14:22:03 &#8211;&gt;</p></blockquote>
<p>You should also make sure the cache page generated time has not changed on a refresh of the page seconds later (tells you it&#8217;s broken).  So if I refresh the page again and I have made no changes to the blog I should see this again:</p>
<blockquote><p>&lt;!&#8211; Cached page generated by WP-Super-Cache on 2009-09-13 14:22:03 &#8211;&gt;</p></blockquote>
<p>This tells me the cache is working and the page was served via a html file.</p>
<p>I hope this convinces everyone who is not running WP-Super-Cache to install it now and configure it!  Especially if you&#8217;re hosting with us because eventually if your site becomes popular I&#8217;m sure you&#8217;ll hear from us about installing it to reduce your usage so that your site can scale up much better.</p>
<p>I plan on posting some more WordPress related posts in the next few weeks regarding things I&#8217;ve noticed on blogs that decrease performance and increase resource usage.  Hopefully the tips help users who think they might not belong in a shared hosting environment to think otherwise after correcting these issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2009/09/13/why-you-should-use-wp-super-cache/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Catch All Email</title>
		<link>http://blog.hawkhost.com/2009/08/28/catch-all-email/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=catch-all-email</link>
		<comments>http://blog.hawkhost.com/2009/08/28/catch-all-email/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 23:39:45 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.hawkhost.com/blog/?p=496</guid>
		<description><![CDATA[The catch all email was a great thing back in the day it was neat you could retrieve mail for sales@domain.com billing@domain.com ect. ect. all through one simple email address.  A lot of users used it without issue and it &#8230; <a href="http://blog.hawkhost.com/2009/08/28/catch-all-email/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The catch all email was a great thing back in the day it was neat you could retrieve mail for sales@domain.com billing@domain.com ect. ect. all through one simple email address.  A lot of users used it without issue and it solved having to check various emails they could just tell users to email random addresses and it would arrive at it&#8217;s spot.  Fast forward to now and the large amounts of mail received by pretty much any domain on the internet and this once cool feature is now a major headache for us as well as any other hosting provider.</p>
<p>With the rise of spam and users no longer displaying their emails on sites the spam bots have become much smarter.  It&#8217;s no longer use email addresses found on web sites and only use them.  The spam bots now send mail to jimmy@domain.com, johnny@domain.com, susan@domain.com ect. ect.  As a result of this a simple spam email could become a mail bomb of thousands of emails hitting a single email account thus putting extreme strain on the server as well as quickly filling a users mail box.  So a lot of users stopped using this feature in favor of forwarders for the specific email accounts so it&#8217;s been less of a problem.  Of course some users still use this feature until they get hit by mail bomb and they end up switching out as it&#8217;s impossible to manage their own mail anymore.</p>
<p>Even with this no longer being a preferred feature of users we still run into problems with people having the default/catch all set to their accounts username.  We by default have this set to fail rather than catch the mail unfortunately by cPanel last I checked the default was catch-all.  The majority of web hosts do not do a great job with managing their servers so they have it set to catch all.  When we have to restore a users account from another server we inherit the ugly catch all that was setup.  So we get to deal with the spam and mail the user receives to any possible email address to their domain.</p>
<p>Now you might be saying well doesn&#8217;t spam help prevent all this mail?  It does but it cannot stop it all and it also slows down a server.  The mail portion on a server is one of the most intensive portions due to just the volume of mail coming in every day.  This is why a lot of providers have suggested to their users use services like google apps or have outside mail servers.  They are attempting to off load one of the most expensive things on their servers which is mail.  Now add in the fact the mail includes spam from every possible email address for a domain and it becomes much more of a problem.  So us using spam blocking techniques do not solve the issues they just help the user while we still need to process the mail going through our spam checker system then if the spam count is high enough getting thrown away.  Also spam blocking systems do not come near effective at blocking everything without blocking a lot of legitimate mail in the process.</p>
<p>All the CPU usage from the mail does not factor in the pure amount of mail you will receive when you have a default mail address set to say the username of your account.  We&#8217;ve had users move from another host and it&#8217;s enabled and they do not check the default email address.  A few years later and they&#8217;ve hit their quota as their default mail address is 2GB of mail or more.  So it can fill a users quota up pretty easily if left unchecked for a long time which is usually the case since the user is not aware it&#8217;s even enabled.</p>
<p>So the only solution here is to say no to the catch all email feature.  If you&#8217;ve never checked it out in cPanel I suggest visiting the &#8220;Default Address&#8221; feature in cPanel and making sure it is set to &#8220;Discard with error to sender (at SMTP time)&#8221;.  A lot of hosts do not have this set so if you came from another host it&#8217;s probably not set to fail on a non existent email address.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2009/08/28/catch-all-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenVZ Apache mpm_worker Memory Issues</title>
		<link>http://blog.hawkhost.com/2009/08/01/openvz-apache-mpm_worker-memory-issues/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=openvz-apache-mpm_worker-memory-issues</link>
		<comments>http://blog.hawkhost.com/2009/08/01/openvz-apache-mpm_worker-memory-issues/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 00:51:26 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.hawkhost.com/blog/?p=479</guid>
		<description><![CDATA[A lot of users look to run Apache&#8217;s mpm_worker rather than the prefork mpm as it&#8217;s regarded to be much more efficient than the perfork mpm.  Add in FastCGI rather than mod_php and it&#8217;s a great combination of stability as &#8230; <a href="http://blog.hawkhost.com/2009/08/01/openvz-apache-mpm_worker-memory-issues/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A lot of users look to run Apache&#8217;s mpm_worker rather than the prefork mpm as it&#8217;s regarded to be much more efficient than the perfork mpm.  Add in FastCGI rather than mod_php and it&#8217;s a great combination of stability as well as performance.  Unfortunately there is one issue with running this on OpenVZ and that is the stack size.  Even the modest VPS with very little traffic will end up using it&#8217;s allowed memory as well as it&#8217;s burst memory.  Many suggest just not running mpm_worker with OpenVZ but this is not the best solution.  The problem has to do with the default thread stack size of 8MB which with OpenVZ becomes real memory rather than simply virtual that will not actually be used by the system unless necessary.  There are several easy fixes for this:</p>
<p>The first one is to modify the init.d script of Apache to reduce the stack size.  So for a cPanel system it&#8217;ll be located at /etc/init.d/httpd and you&#8217;ll want to add the following:</p>
<blockquote><p>ulimit -s 256</p></blockquote>
<p>This will make the stack size just 256KB which will suffice for most users.  I prefer to just do this with Apache but if you like you could modify this globally by changing /etc/security/limits.conf or for all services you could change /etc/init.d/rc .  I believe though the best action is to just change Apache until you run into an issue with another service having the same issue.  As you may not want just 256 but higher for a specific service or the defaults are fine in other cases and lower may reduce performance.</p>
<p>Well I hope that helps everyone out to get the performance of mpm_worker while not having to deal with the memory issues with regards to the default stack size.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hawkhost.com/2009/08/01/openvz-apache-mpm_worker-memory-issues/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
