<?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>AskApache &#187; WiredTree</title>
	<atom:link href="http://www.askapache.com/wiredtree/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.askapache.com</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Wed, 08 Sep 2010 14:09:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Magic in the Terminal: Screen, Bash, and SSH</title>
		<link>http://www.askapache.com/hacking/magic-in-the-terminal-screen-bash-and-ssh.html</link>
		<comments>http://www.askapache.com/hacking/magic-in-the-terminal-screen-bash-and-ssh.html#comments</comments>
		<pubDate>Tue, 07 Sep 2010 04:14:47 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[500]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[CCZE]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[password protection]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[SetEnvIf]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[tmpfs]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=3923</guid>
		<description><![CDATA[<div><div id="magicbashmatrix"></div></div>
<p><strong>Oh ya lets get it on!</strong>  <em>short but sweet</em></p>
<p><a href="http://uploads.askapache.com/2010/02/htopp.png"><img src="http://uploads.askapache.com/2010/02/htopp.png" alt="running htop in bash over ssh to different server" title="running htop in bash over ssh to different server" width="561" height="370" class="alignnone size-full wp-image-3984" /></a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Back in the mid-90&#8242;s</strong> I was doing a lot of <a href="#war_dialing" rel="nofollow" >war-dialing</a> with modems (<em>a more recent phenomenon is wardriving, the searching for wireless networks (Wi-Fi) from a moving vehicle. Wardriving was named after wardialing, since both techniques involve brute-force searches to find computer networks</em>) and discovering all sorts of networks and machines, many of them were Unix and Solaris based public systems, and when I managed to gain access to the system and found myself staring at a unix shell I was very excited but also a total idiot.  In those days of using the phone networks to research unknown systems it was very difficult for anyone to actually get the phone company to trace a call, so instead of what happens today where it is child&#8217;s play to trace an IP address, back then it was a very real back-and-forth battle between the system admin and whoever was gaining access to their system.</p>
<div>
<div id="screenmagic"></div>
</div>
<p>Essentially, I would gain a shell or some kind of terminal, and just go at it trying to figure out what it could do, trying all kinds of commands.  Inevitably this would eventually alert even the laziest admin and they would proceed to attempt to lock me out. It was great sport and extremely addictive.  When my favorite system (a massive sun machine in the basement of a big library) finally locked me out and I couldn&#8217;t get back in I went to my local library and got some reading material &#8212; one of my favorites was the red hat bible.  I was able to acquire my own computer and the first thing I did was install red hat linux onto it from the discs included with the book.  For the next several years I was essentially offline, all we had at home was a modem and it was becoming difficult to locate any more systems in my area code.. I was into phreaking of course as well, but I never was able to make free long-distance war-dialing a reality.</p>
<p>So I just read the books and learned what I could.  I would also goto the library when I could in order to use their machines which were connected to the internet (before aol it was much different than today&#8217;s internet) and since my time was short I would download as many documents as I could so that I could read them offline.  The TLDP documentation that we know today was around back then in various forms, and I read every HOWTO in the index, though not understanding half.  The other big resource I found for really intense reading was the <a href="http://www.kernel.org/doc/Documentation/" rel="nofollow" >kernel documentation</a>, which admitedly I still don&#8217;t comprehend 1/4th of..   I try and peruse all the new documents when a new kernel is released, since the kernel is where all the real action is, hence the military authoritative name, and that is how I discovered one of the coolest features of Linux that I have found.  TMPFS!</p>
<h3>What I learned</h3>
<p>I learned that with our present technology, which I try to keep somewhat updated on, using a mouse to point and click your way to a solution is always much much much slower than just getting dirty and writing straight code to a terminal.  BTW, you know they are close (within 100 years) of enabling connection at the speed of thought.  Yes it&#8217;s a mind-meld between you and a super-computer AI to process it.  That&#8217;s the whole story behind popular Japanese anime like &#8220;Ghost in the Shell&#8221;.</p>
<p>That&#8217;s also a fundamental reason that certain vast segments of the computing world have a dislike of Microsoft, the way they build (to sell) their operating systems..  no open-code, which is their obvious #1 problem, and why they have a million viruses.  Perhaps even a bigger issue some have with &#8220;the empire&#8221;, is how they stuck this gooey, thats how you pronounce GUI &#8211; graphical user interface, in a way that tries to create multiple classes of people, those behind the scenes with all the control (they are a middleman between you and your real computer, for millions), and a second group of people on the outside, sheep &#8211; I believe they are referred to as sheep.</p>
<p><a href='http://uploads.askapache.com/2010/02/screenrc-example.txt' >screenrc-example</a></p>
<p><a href="http://uploads.askapache.com/2010/02/vim-in-screen.png" rel="nofollow" ><img src="http://uploads.askapache.com/2010/02/vim-in-screen.png" alt="256color Enabled Vim Syntax Highlighting" title="256color Enabled Vim Syntax Highlighting" width="561" height="256" class="alignnone size-full wp-image-3986" /></a></p>
<h3>Cleanup Screenrc Files</h3>
<p>You can run this command to get a wildly confusing screenrc file under control.  You could have a heavily commented version, and then run this to create the actual&#8230; I like to start there but because the screenrc file is read in order, you should take out the &#8216;sort&#8217;.</p>
<pre>sed -e &#039;/^#/d; s/^[\t\ ]*//g; /^[a-z]/I!d&#039; /etc/screenrc|sort|tr -s &#039; \t&#039; | tr -d &#039;\015\032&#039;</pre>
<h3>Read lots of .screenrc files</h3>
<p>This is easy with Google&#8217;s futuristic Code Searching Engine!  I get excited about this search engine because it is sooo dope!  Here&#8217;s a <a href="http://www.google.com/codesearch?q=file%3Ascreenrc&#038;hl=en&#038;btnG=Search+Code" rel="nofollow" >search for files named .screenrc</a>, thanks for this <strong>free</strong> tool Google, much love!</p>
<p>Here it is with lots of messy comments still in place.</p>
<pre>autodetach on
bufferfile $HOME/.screen/buffer
&nbsp;
nethack on # print wackier status messages
chdir $HOME
password HJa4Dp4UIDlLA
&nbsp;
setenv LC_CTYPE en_US.UTF-8
sorendition =s Gk
startup_message off
shell bash # use the default shell
shelltitle &quot;$ |bash&quot;
term screen-256color #By default, screen uses an 8-color terminal emulator. Use the following line to enable more colors, more-capable terminal emulator:
&nbsp;
defmode 620
defmonitor off # turn monitoring on
defnonblock 5 # flaky/slow ssh lines
defscrollback 300
defutf8 on
hardcopydir ~/.hardcopy/screen_%y-%m-%d_%0c.%n
&nbsp;
defbce on # erase background with current bg color
defencoding UTF-8
defflow auto # will force screen to process ^S/^Q
defflow on # disable Ctrl-S/Ctrl-Q &quot;flow control&quot;
defhstatus &quot;screen: ^En (^Et)&quot;
deflogin off
&nbsp;
deflog off
logfile ~/.screen/screen_%y-%m-%d_%0c.%n
&nbsp;
silencewait 15
vbell_msg &quot; Wuff &#45;&#45;&#45;- Wuff!! &quot;
&nbsp;
activity &quot;%C -&gt; %n%f %t activity!&quot;
bell &quot;%C -&gt; %n%f %t bell!~&quot;
&nbsp;
altscreen on # restore window contents after using (e.g.) vi
attrcolor b &quot;.I&quot; # allow bold colors - necessary for some reason
&nbsp;
hardstatus on
hardstatus alwayslastline &quot;[%02c] %`%-w%{=b bw}%n %t%{-}%+w %=%{..Lw} %H %{..g} %m/%d %C%a &quot;
caption always &quot;%{kG}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kG}%?%+Lw%?&quot;
&nbsp;
idle 3600 eval &quot;screen nice -n 19 /opt/s/cmatrix&quot; &quot;idle 6400 detach&quot;
&nbsp;
msgwait 5 # 1 second messages
multiuser off
nonblock on # If a window goes unresponsive, don&#039;t block the whole session waiting for it.
pow_detach_msg &quot;Screen session of $LOGNAME $:cr:$:nl:ended.&quot; # emulate .logout message
&nbsp;
screen -h 500 -t &#039;bash&#039; sh $HOME/welcome.sh
screen -h 0 -t &#039;MATRIX&#039; nice -n 19 /opt/s/cmatrix
screen -h 0 -t &#039;WHO&#039; sudo /opt/s/whowatch
screen -h 100 -t &#039;gator&#039; sh $HOME/.ssh/start_control.sh
screen -h 100 -t &#039;gator&#039; ssh gator sh ~/welcome.sh
screen -h 500 -t &#039;root&#039; sudo bash -l
screen -h 0 -t &#039;MEM&#039; nice -n 19 sh -c &#039;sleep 4 &amp;&amp; tput civis; CLS=$`tput clear`; trap &quot;tput cnorm; exit 0&quot; 1 2 3; while :; do free -olt &amp;&amp; sleep 2 &amp;&amp; echo $CLS; done;&#039;
screen -h 0 -t &#039;TOP&#039; nice -n 19 sh -c &#039;sleep 4 &amp;&amp; tput civis; CLS=$`tput clear`; trap &quot;tput cnorm; exit 0&quot; 1 2 3; while :; do top -b -n 1 -H -d 10 -c |sed &quot;/$USER/!d&quot; &amp;&amp; echo $CLS; done;&#039;
screen -h 0 -t &#039;NET&#039; nice -n 19 sh -c &#039;while :; do /bin/netstat &#45;-numeric-ports -a -e &#45;-tcp |sort &#45;-key=4 &amp;&amp; sleep 5; done;&#039;
select 0
&nbsp;
#select -h 100 -t &#039;log&#039; 4 sudo sh -c &#039;nice tail -n 60 -s 10 -f /var/log/everything.log | ccze -A&#039;
&nbsp;
zombie &quot;^[&quot; # don&#039;t kill window after the process died</pre>
<p><a id="war_dialing" name="war_dialing"></a></p>
<h2>More on War Dialing</h2>
<blockquote cite="">
<p>
<p>War dialing or wardialing is a technique of using a modem to automatically scan a list of telephone  numbers, usually dialing every number in a local area code to search for computers, Bulletin board systems and fax machines. Hackers use the resulting lists for various purposes, hobbyists for exploration, and crackers - hackers that specialize in computer security - for password guessing.</p>
<p>A single wardialing call would involve calling an unknown number, and waiting for one or two rings, since answering computers usually pick up on the first ring. If the phone rings twice, the modem hangs up and tries the next number. If a modem or fax machine answers, the wardialer program makes a note of the number. If a human or answering machine answers, the wardialer program hangs up. Depending on the time of day, wardialing 10,000 numbers in a given area code might annoy dozens or hundreds of people, some who attempt and fail to answer a phone in two rings, and some who succeed, only to hear the wardialing modem's carrier tone and hang up. The repeated incoming calls are especially annoying to businesses that have many consecutively numbered lines in the exchange, such as used with a Centrex telephone system.</p>
<p>The popularity of wardialing in 1980s and 1990s prompted some states to enact legislation prohibiting the use of a device to dial telephone numbers without the intent of communicating with a person.</p>
<p>The name for this technique originated in the 1983 film WarGames. In the film, the protagonist programmed his computer to dial every telephone number in Sunnyvale, California to find other computer systems. 'WarGames Dialer' programs became common on bulletin board systems of the time, with file names often truncated to wardial.exe and the like due to length restrictions on such systems. Eventually, the etymology of the name fell behind as "war dialing" gained its own currency within computing culture.[1]</p>
<p>A more recent phenomenon is wardriving, the searching for wireless networks (Wi-Fi) from a moving vehicle. Wardriving was named after wardialing, since both techniques involve brute-force searches to find computer networks. The aim of wardriving is to collect information about wireless access points (not to be confused with piggybacking).</p>
<p>Similar to war dialing is a port scan under TCP/IP, which "dials" every TCP port of every IP address to find out what services are available. Unlike wardialing, however, a port scan will generally not disturb a human being when it tries an IP address, regardless of whether there is a computer responding on that address or not. Related to wardriving is warchalking, the practice of drawing chalk symbols in public places to advertise the availability of wireless networks. Despite its widespread coverage [in the news?], warchalking never particularly caught on as a popular activity.</p>
<p>The term is also used today by analogy for various sorts of exhaustive brute force attack against an authentication mechanism, such as a password. While a dictionary attack might involve trying each word in a dictionary as the password, "wardialing the password" would involve trying every possible password. Password protection systems are usually designed to make this impractical, by making the process slow and/or locking out an account for minutes or hours after some low number of wrong password entries.</p>
<p>War dialing is sometimes used as a synonym for demon dialing, a related technique which also involves automating a computer modem in order to repeatedly place telephone calls.</p>
</p>
</blockquote>
<p class="wikicop">This page contains content by <a href="http://en.wikipedia.org/w/index.php?title=War_dialing&#038;action=history"title="* New Window" rel="nofollow" >Author</a> of <a href="http://en.wikipedia.org/wiki/War_dialing"title="* New Window"  rel="nofollow">Article</a> from <a href="http://en.wikipedia.org/wiki/Main_Page"title="* New Window"  rel="nofollow">Wikipedia</a> and is licensed under the <a href="http://www.askapache.com/gnu-fdl.txt" rel="nofollow" title="GNU BABY!">GNU FDL</a>.</p>
<p><a href="http://uploads.askapache.com/2010/02/htopp.png" rel="nofollow" ><img src="http://uploads.askapache.com/2010/02/htopp-350x230.png" alt="running htop in bash over ssh to different server" title="running htop in bash over ssh to different server" width="350" height="230" class="alignnone size-medium wp-image-3984" /></a></p>
<p><a href="http://www.askapache.com/hacking/magic-in-the-terminal-screen-bash-and-ssh.html"></a><a href="http://www.askapache.com/hacking/magic-in-the-terminal-screen-bash-and-ssh.html">Magic in the Terminal: Screen, Bash, and SSH</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/hacking/magic-in-the-terminal-screen-bash-and-ssh.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Session File Hacks</title>
		<link>http://www.askapache.com/php/php-session-hack.html</link>
		<comments>http://www.askapache.com/php/php-session-hack.html#comments</comments>
		<pubDate>Fri, 25 Jun 2010 00:00:09 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Sessions]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[umask]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=1019</guid>
		<description><![CDATA[<p><strong>What they say about kung-fu is true</strong>..</p>
<p>It can be attained by anyone through <em>hard work over time</em>.   You can become as good as the amount of work you put in.   Here's a short look at a basic technique that I use.  Simply reverse engineering the source code and taking notes along the way...</p>
<pre>static void php_session_send_cookie(TSRMLS_D)
  if (SG(headers_sent)) {
          if (output_start_filename) {
                  php_error_docref(NULL TSRMLS_CC, E_WARNING, &#34;Cannot send session cookie - headers already sent by (output started at %s:%d)&#34;,
                          output_start_filename, output_start_lineno);
          } else {
                  php_error_docref(NULL TSRMLS_CC, E_WARNING, &#34;Cannot send session cookie - headers already sent&#34;);
          }
          return;
  }
&#160;
  /* URL encode session_name and id because they might be user supplied */
  e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)), NULL);</pre>]]></description>
			<content:encoded><![CDATA[<p>If you want to learn best tricks and tips, there&#8217;s only one way to do it&#8230; at least only one way that I know of.  Here are some notes I created while learning about the intricacies of php sessions, it&#8217;s all in the code.</p>
<pre>[Session]
; Handler used to store/retrieve data.
session.save_handler = files</pre>
<p>Argument passed to save_handler.  In the case of files, this is the path where data files are stored. As of PHP 4.0.1, you can define the path as:</p>
<pre>session.save_path = &quot;N;/path&quot;</pre>
<p> where N is an integer.  Instead of storing all the session files in<br />
 /path, what this will do is use subdirectories N-levels deep, and<br />
 store the session data in those directories.  This is useful if you<br />
 or your OS have problems with lots of files in one directory, and is<br />
 a more efficient layout for servers that handle lots of sessions.</p>
<pre>;
; NOTE 1: PHP will not create this directory structure automatically.
;         You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
;         use subdirectories for session storage
;
; The file storage module creates files using mode 600 by default.
; You can change that by using
;
;     session.save_path = &quot;N;MODE;/path&quot;
;
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process&#039;s umask.
;session.save_path = &quot;/tmp&quot;</pre>
<h3>session.c</h3>
<pre>/* {{{ PHP_INI
 */
PHP_INI_BEGIN()
        STD_PHP_INI_BOOLEAN(&quot;session.bug_compat_42&quot;,    &quot;1&quot;,         PHP_INI_ALL, OnUpdateBool,   bug_compat,         php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.bug_compat_warn&quot;,  &quot;1&quot;,         PHP_INI_ALL, OnUpdateBool,   bug_compat_warn,    php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.save_path&quot;,          &quot;&quot;,          PHP_INI_ALL, OnUpdateSaveDir,save_path,          php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.name&quot;,               &quot;PHPSESSID&quot;, PHP_INI_ALL, OnUpdateString, session_name,       php_ps_globals,    ps_globals)
        PHP_INI_ENTRY(&quot;session.save_handler&quot;,           &quot;files&quot;,     PHP_INI_ALL, OnUpdateSaveHandler)
        STD_PHP_INI_BOOLEAN(&quot;session.auto_start&quot;,       &quot;0&quot;,         PHP_INI_ALL, OnUpdateBool,   auto_start,         php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.gc_probability&quot;,     &quot;1&quot;,         PHP_INI_ALL, OnUpdateLong,    gc_probability,     php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.gc_divisor&quot;,         &quot;100&quot;,       PHP_INI_ALL, OnUpdateLong,    gc_divisor,        php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.gc_maxlifetime&quot;,     &quot;1440&quot;,      PHP_INI_ALL, OnUpdateLong,    gc_maxlifetime,     php_ps_globals,    ps_globals)
        PHP_INI_ENTRY(&quot;session.serialize_handler&quot;,      &quot;php&quot;,       PHP_INI_ALL, OnUpdateSerializer)
        STD_PHP_INI_ENTRY(&quot;session.cookie_lifetime&quot;,    &quot;0&quot;,         PHP_INI_ALL, OnUpdateLong,    cookie_lifetime,    php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cookie_path&quot;,        &quot;/&quot;,         PHP_INI_ALL, OnUpdateString, cookie_path,        php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cookie_domain&quot;,      &quot;&quot;,          PHP_INI_ALL, OnUpdateString, cookie_domain,      php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.cookie_secure&quot;,    &quot;&quot;,          PHP_INI_ALL, OnUpdateBool,   cookie_secure,      php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.cookie_httponly&quot;,  &quot;&quot;,          PHP_INI_ALL, OnUpdateBool,   cookie_httponly,    php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.use_cookies&quot;,      &quot;1&quot;,         PHP_INI_ALL, OnUpdateBool,   use_cookies,        php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN(&quot;session.use_only_cookies&quot;, &quot;0&quot;,         PHP_INI_ALL, OnUpdateBool,   use_only_cookies,   php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.referer_check&quot;,      &quot;&quot;,          PHP_INI_ALL, OnUpdateString, extern_referer_chk, php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.entropy_file&quot;,       &quot;&quot;,          PHP_INI_ALL, OnUpdateString, entropy_file,       php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.entropy_length&quot;,     &quot;0&quot;,         PHP_INI_ALL, OnUpdateLong,    entropy_length,     php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cache_limiter&quot;,      &quot;nocache&quot;,   PHP_INI_ALL, OnUpdateString, cache_limiter,      php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.cache_expire&quot;,       &quot;180&quot;,       PHP_INI_ALL, OnUpdateLong,    cache_expire,       php_ps_globals,    ps_globals)
        PHP_INI_ENTRY(&quot;session.use_trans_sid&quot;,          &quot;0&quot;,         PHP_INI_ALL, OnUpdateTransSid)
        STD_PHP_INI_ENTRY(&quot;session.hash_function&quot;,      &quot;0&quot;,         PHP_INI_ALL, OnUpdateLong,    hash_func,          php_ps_globals,    ps_globals)
        STD_PHP_INI_ENTRY(&quot;session.hash_bits_per_character&quot;,      &quot;4&quot;,         PHP_INI_ALL, OnUpdateLong,    hash_bits_per_character,          php_ps_globals,    ps_globals)
&nbsp;
        /* Commented out until future discussion */
        /* PHP_INI_ENTRY(&quot;session.encode_sources&quot;, &quot;globals,track&quot;, PHP_INI_ALL, NULL) */
PHP_INI_END()
/* }}} */</pre>
<h3>Session Errors</h3>
<pre>The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and &#039;-,&#039;
fcntl(%d, F_SETFD, FD_CLOEXEC) failed: %s (%d)
open(%s, O_RDWR) failed: %s (%d)
ps_files_cleanup_dir: opendir(%s) failed: %s (%d)
read failed: %s (%d)
read returned less bytes than requested
write failed: %s (%d)
write wrote less bytes than requested
mm_malloc failed, avail %d, err %s
cannot allocate new data segment
Skipping numeric key %ld.
A session is active. You cannot change the session module&#039;s ini settings at this time.
Cannot find save handler %s
Cannot find serialization handler %s
Unknown session.serialize_handler. Failed to encode session object.
Cannot encode non-existent session.
Unknown session.serialize_handler. Failed to decode session object.
Failed to decode session object. Session has been destroyed.
Invalid session hash function
The ini setting hash_bits_per_character is out of range (should be 4, 5, or 6) - using 4 for now
No storage module chosen - failed to initialize session.
Failed to initialize storage module: %s (path: %s)
The session bug compatibility code will not
Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively.
Failed to write session data (%s). Please
Cannot send session cache limiter - headers already sent (output started at %s:%d)
Cannot send session cache limiter - headers already sent
Cannot send session cookie - headers already sent by (output started at %s:%d)
Cannot send session cookie - headers already sent
Cannot find save handler %s
Cannot find unknown save handler
purged %d expired session objects
Trying to destroy uninitialized session
Session object destruction failed
Cannot find named PHP session module (%s)
Argument %d is not a valid callback
Cannot regenerate session id - headers already sent
Session object destruction failed</pre>
<pre>PS_GC_FUNC(files)
{
        PS_FILES_DATA;
&nbsp;
        /* we don&#039;t perform any cleanup, if dirdepth is larger than 0.
           we return SUCCESS, since all cleanup should be handled by
           an external entity (i.e. find -ctime x | xargs rm) */
&nbsp;
        if (data-&gt;dirdepth == 0) {
                *nrdels = ps_files_cleanup_dir(data-&gt;basedir, maxlifetime TSRMLS_CC);
        }
&nbsp;
        return SUCCESS;
}</pre>
<h3>mod_files.c</h3>
<pre>/* If you change the logic here, please also update the error message in
 * ps_files_open() appropriately */
static int ps_files_valid_key(const char *key)
{
        size_t len;
        const char *p;
        char c;
        int ret = 1;
&nbsp;
        for (p = key; (c = *p); p++) {
                /* valid characters are a..z,A..Z,0..9 */
                if (!((c &gt;= &#039;a&#039; &amp;&amp; c &lt;= &#039;z&#039;)
                                || (c &gt;= &#039;A&#039; &amp;&amp; c &lt;= &#039;Z&#039;)
                                || (c &gt;= &#039;0&#039; &amp;&amp; c &lt;= &#039;9&#039;)
                                || c == &#039;,&#039;
                                || c == &#039;-&#039;)) {
                        ret = 0;
                        break;
                }
        }
&nbsp;
        len = p - key;
&nbsp;
        if (len == 0) {
                ret = 0;
        }
&nbsp;
        return ret;
}</pre>
<pre>static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC)
{
        DIR *dir;
        char dentry[sizeof(struct dirent) + MAXPATHLEN];
        struct dirent *entry = (struct dirent *) &amp;dentry;
        struct stat sbuf;
        char buf[MAXPATHLEN];
        time_t now;
        int nrdels = 0;
        size_t dirname_len;
&nbsp;
        dir = opendir(dirname);
        if (!dir) {
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, &quot;ps_files_cleanup_dir: opendir(%s) failed: %s (%d)&quot;, dirname, strerror(errno), errno);
                return (0);
        }
&nbsp;
        time(&amp;now);
&nbsp;
        dirname_len = strlen(dirname);
&nbsp;
        /* Prepare buffer (dirname never changes) */
        memcpy(buf, dirname, dirname_len);
        buf[dirname_len] = PHP_DIR_SEPARATOR;
&nbsp;
        while (php_readdir_r(dir, (struct dirent *) dentry, &amp;entry) == 0 &amp;&amp; entry) {
                /* does the file start with our prefix? */
                if (!strncmp(entry-&gt;d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1)) {
                        size_t entry_len = strlen(entry-&gt;d_name);
&nbsp;
                        /* does it fit into our buffer? */
                        if (entry_len + dirname_len + 2 &lt; MAXPATHLEN) {
                                /* create the full path.. */
                                memcpy(buf + dirname_len + 1, entry-&gt;d_name, entry_len);
&nbsp;
                                /* NUL terminate it and */
                                buf[dirname_len + entry_len + 1] = &#039;\0&#039;;
&nbsp;
                                /* check whether its last access was more than maxlifet ago */
                                if (VCWD_STAT(buf, &amp;sbuf) == 0 &amp;&amp;
#ifdef NETWARE
                                                (now - sbuf.st_mtime.tv_sec) &gt; maxlifetime) {
#else
                                                (now - sbuf.st_mtime) &gt; maxlifetime) {
#endif
                                        VCWD_UNLINK(buf);
                                        nrdels++;
                                }
                        }
                }
        }
&nbsp;
        closedir(dir);
&nbsp;
        return (nrdels);
}</pre>
<h3>ext/session/mod_files.c</h3>
<pre>#define PS_FILES_DATA ps_files *data = PS_GET_MOD_DATA()
&nbsp;
PS_OPEN_FUNC(files)
{
        ps_files *data;
        const char *p, *last;
        const char *argv[3];
        int argc = 0;
        size_t dirdepth = 0;
        int filemode = 0600;
&nbsp;
        if (*save_path == &#039;\0&#039;) {
                /* if save path is an empty string, determine the temporary dir */
                save_path = php_get_temporary_directory();
&nbsp;
                if (strcmp(save_path, &quot;/tmp&quot;)) {
                        if (PG(safe_mode) &amp;&amp; (!php_checkuid(save_path, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
                                return FAILURE;
                        }
                        if (php_check_open_basedir(save_path TSRMLS_CC)) {
                                return FAILURE;
                        }
                }
        }
&nbsp;
        /* split up input parameter */
        last = save_path;
        p = strchr(save_path, &#039;;&#039;);
        while (p) {
                argv[argc++] = last;
                last = ++p;
                p = strchr(p, &#039;;&#039;);
                if (argc &gt; 2) break;
        }
        argv[argc++] = last;
&nbsp;
        if (argc &gt; 1) {
                errno = 0;
                dirdepth = (size_t) strtol(argv[0], NULL, 10);
                if (errno == ERANGE) {
                        php_error(E_WARNING, &quot;The first parameter in session.save_path is invalid&quot;);
                        return FAILURE;
                }
        }
&nbsp;
        if (argc &gt; 2) {
                errno = 0;
                filemode = strtol(argv[1], NULL, 8);
                if (errno == ERANGE || filemode &lt; 0 || filemode &gt; 07777) {
                        php_error(E_WARNING, &quot;The second parameter in session.save_path is invalid&quot;);
                        return FAILURE;
                }
        }
        save_path = argv[argc - 1];
&nbsp;
        data = emalloc(sizeof(*data));
        memset(data, 0, sizeof(*data));
&nbsp;
        data-&gt;fd = -1;
        data-&gt;dirdepth = dirdepth;
        data-&gt;filemode = filemode;
        data-&gt;basedir_len = strlen(save_path);
        data-&gt;basedir = estrndup(save_path, data-&gt;basedir_len);
&nbsp;
        PS_SET_MOD_DATA(data);
&nbsp;
        return SUCCESS;
}</pre>
<blockquote><pre>[PHP 5.2.0 session.save_path safe_mode and open_basedir bypass]
&nbsp;
Author: Maksymilian Arciemowicz (SecurityReason)
Date:
- - Written: 02.10.2006
- - Public: 08.12.2006
SecurityAlert Id: 43
CVE: CVE-2006-6383
SecurityRisk: High
Affected Software: PHP 5.2.0
Advisory URL: http://securityreason.com/achievement_securityalert/43
Vendor: http://www.php.net
&nbsp;
- &#45;&#45;- 0.Description &#45;&#45;-
PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from
C, Java and Perl with a couple of unique PHP-specific features thrown in. The
goal of the language is to allow web developers to write dynamically generated
pages quickly.
&nbsp;
A nice introduction to PHP by Stig Sather Bakken can be found at
http://www.zend.com/zend/art/intro.php on the Zend website. Also, much  of the
PHP Conference Material is freely available.
&nbsp;
Session support in PHP consists of a way to preserve certain data across
subsequent accesses. This enables you to build more customized applications and
increase the appeal of your web site.
&nbsp;
A visitor accessing your web site is assigned a unique id, the so-called
session id. This is either stored in a cookie on the user side or is propagated
in the URL.
&nbsp;
session.save_path defines the argument which is passed to the save handler. If
you choose the default files handler, this is the path where the files are
created. Defaults to /tmp. See also session_save_path().
&nbsp;
There is an optional N argument to this directive that determines the number of
directory levels your session files will be spread around in. For example,
setting to &#039;5;/tmp&#039; may end up creating a session file and location like
/tmp/4/b/1/e/3/sess_4b1e384ad74619bd212e236e52a5a174If . In order to use N you
must create all of these directories before use. A small shell script exists in
ext/session to do this, it&#039;s called mod_files.sh. Also note that if N is used
and greater than 0 then automatic garbage collection will not be performed, see
a copy of php.ini for further information. Also, if you use N, be sure to
surround session.save_path in &quot;quotes&quot; because the separator (;) is also used
for comments in php.ini.
&nbsp;
- &#45;&#45;- 1. session.save_path safe mode and open basedir bypass &#45;&#45;-
session.save_path can be set in ini_set(), session_save_path() function. In
session.save_path there must be path where you will save yours tmp file. But
syntax for session.save_path can be:
&nbsp;
[/PATH]
&nbsp;
OR
&nbsp;
[N;/PATH]
&nbsp;
N - can be a string.
&nbsp;
EXAMPLES:
&nbsp;
1. session_save_path(&quot;/DIR/WHERE/YOU/HAVE/ACCESS&quot;)
2. session_save_path(&quot;5;/DIR/WHERE/YOU/HAVE/ACCESS&quot;)
&nbsp;
and
&nbsp;
3.
session_save_path(&quot;/DIR/WHERE/YOU/DONT/HAVE/ACCESS\0;/DIR/WHERE/YOU/HAVE/ACCESS&quot;)</pre>
</blockquote>
<pre>CACHE_LIMITER_FUNC(public)
{
        char buf[MAX_STR + 1];
        struct timeval tv;
        time_t now;
&nbsp;
        gettimeofday(&amp;tv, NULL);
        now = tv.tv_sec + PS(cache_expire) * 60;
#define EXPIRES &quot;Expires: &quot;
        memcpy(buf, EXPIRES, sizeof(EXPIRES) - 1);
        strcpy_gmt(buf + sizeof(EXPIRES) - 1, &amp;now);
        ADD_HEADER(buf);
&nbsp;
        snprintf(buf, sizeof(buf) , &quot;Cache-Control: public, max-age=%ld&quot;, PS(cache_expire) * 60); /* SAFE */
        ADD_HEADER(buf);
&nbsp;
        last_modified(TSRMLS_C);
}
&nbsp;
CACHE_LIMITER_FUNC(private_no_expire)
{
        char buf[MAX_STR + 1];
&nbsp;
        snprintf(buf, sizeof(buf), &quot;Cache-Control: private, max-age=%ld, pre-check=%ld&quot;, PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */
        ADD_HEADER(buf);
&nbsp;
        last_modified(TSRMLS_C);
}
&nbsp;
CACHE_LIMITER_FUNC(private)
{
        ADD_HEADER(&quot;Expires: Thu, 19 Nov 1981 08:52:00 GMT&quot;);
        CACHE_LIMITER(private_no_expire)(TSRMLS_C);
}
&nbsp;
CACHE_LIMITER_FUNC(nocache)
{
        ADD_HEADER(&quot;Expires: Thu, 19 Nov 1981 08:52:00 GMT&quot;);
        /* For HTTP/1.1 conforming clients and the rest (MSIE 5) */
        ADD_HEADER(&quot;Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0&quot;);
        /* For HTTP/1.0 conforming clients */
        ADD_HEADER(&quot;Pragma: no-cache&quot;);
}
&nbsp;
static php_session_cache_limiter_t php_session_cache_limiters[] = {
        CACHE_LIMITER_ENTRY(public)
        CACHE_LIMITER_ENTRY(private)
        CACHE_LIMITER_ENTRY(private_no_expire)
        CACHE_LIMITER_ENTRY(nocache)
        {0}
};
&nbsp;
static int php_session_cache_limiter(TSRMLS_D)
{
        php_session_cache_limiter_t *lim;
&nbsp;
        if (PS(cache_limiter)[0] == &#039;\0&#039;) return 0;
&nbsp;
        if (SG(headers_sent)) {
                char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
                int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
&nbsp;
                if (output_start_filename) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cache limiter - headers already sent (output started at %s:%d)&quot;,
                                output_start_filename, output_start_lineno);
                } else {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cache limiter - headers already sent&quot;);
                }
                return -2;
        }
&nbsp;
        for (lim = php_session_cache_limiters; lim-&gt;name; lim++) {
                if (!strcasecmp(lim-&gt;name, PS(cache_limiter))) {
                        lim-&gt;func(TSRMLS_C);
                        return 0;
                }
        }
&nbsp;
        return -1;
}</pre>
<pre>static void php_session_send_cookie(TSRMLS_D)
{
        smart_str ncookie = {0};
        char *date_fmt = NULL;
        char *e_session_name, *e_id;
&nbsp;
        if (SG(headers_sent)) {
                char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
                int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
&nbsp;
                if (output_start_filename) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cookie - headers already sent by (output started at %s:%d)&quot;,
                                output_start_filename, output_start_lineno);
                } else {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, &quot;Cannot send session cookie - headers already sent&quot;);
                }
                return;
        }
&nbsp;
        /* URL encode session_name and id because they might be user supplied */
        e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)), NULL);
        e_id = php_url_encode(PS(id), strlen(PS(id)), NULL);
&nbsp;
        smart_str_appends(&amp;ncookie, COOKIE_SET_COOKIE);
        smart_str_appends(&amp;ncookie, e_session_name);
        smart_str_appendc(&amp;ncookie, &#039;=&#039;);
        smart_str_appends(&amp;ncookie, e_id);
&nbsp;
        efree(e_session_name);
        efree(e_id);
&nbsp;
        if (PS(cookie_lifetime) &gt; 0) {
                struct timeval tv;
                time_t t;
&nbsp;
                gettimeofday(&amp;tv, NULL);
                t = tv.tv_sec + PS(cookie_lifetime);
&nbsp;
                if (t &gt; 0) {
                        date_fmt = php_std_date(t TSRMLS_CC);
                        smart_str_appends(&amp;ncookie, COOKIE_EXPIRES);
                        smart_str_appends(&amp;ncookie, date_fmt);
                        efree(date_fmt);
                }
        }
&nbsp;
        if (PS(cookie_path)[0]) {
                smart_str_appends(&amp;ncookie, COOKIE_PATH);
                smart_str_appends(&amp;ncookie, PS(cookie_path));
        }
&nbsp;
        if (PS(cookie_domain)[0]) {
                smart_str_appends(&amp;ncookie, COOKIE_DOMAIN);
                smart_str_appends(&amp;ncookie, PS(cookie_domain));
        }
&nbsp;
        if (PS(cookie_secure)) {
                smart_str_appends(&amp;ncookie, COOKIE_SECURE);
        }
&nbsp;
        if (PS(cookie_httponly)) {
                smart_str_appends(&amp;ncookie, COOKIE_HTTPONLY);
        }
&nbsp;
        smart_str_0(&amp;ncookie);
&nbsp;
        /*      &#039;replace&#039; must be 0 here, else a previous Set-Cookie
                header, probably sent with setcookie() will be replaced! */
        sapi_add_header_ex(ncookie.c, ncookie.len, 0, 0 TSRMLS_CC);
}</pre>
<p><a href="http://www.askapache.com/php/php-session-hack.html"></a><a href="http://www.askapache.com/php/php-session-hack.html">PHP Session File Hacks</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/php/php-session-hack.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Crazy POWERFUL Bash Prompt</title>
		<link>http://www.askapache.com/linux-unix/bash-power-prompt.html</link>
		<comments>http://www.askapache.com/linux-unix/bash-power-prompt.html#comments</comments>
		<pubDate>Tue, 25 May 2010 19:02:34 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Making Money]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[.bashrc]]></category>
		<category><![CDATA[404 Not Found]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bash_profile]]></category>
		<category><![CDATA[CommandLine]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Kung-Fu]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[PROMPT_COMMAND]]></category>
		<category><![CDATA[PS1]]></category>
		<category><![CDATA[Putty]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell History]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[Username]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4069</guid>
		<description><![CDATA[<p><a class="IFL" href='http://www.askapache.com/linux-unix/bash-power-prompt.html' title='bash power prompt PS1'><img width="350" height="65" src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1-350x65.png" class="attachment-thumbnail" alt="bash power prompt PS1" title="bash power prompt PS1" /></a>This <a href='http://www.askapache.com/linux-unix/bash-power-prompt.html' title='amazing bash linux prompt'>amazing bash linux prompt</a> does more than meets the eye.  If you want to know how to become really good with technology, linux is the secret sauce behind the AskApache articles.  Open Source is elixir of the web.  Thanks to everyone who helped me for the past 20 years.  <strong>I use linux/bsd</strong> because <strong>homey don't play</strong>, so this is geared to be as productive a prompt as I can make it.<br /><br /><strong>Don't have much time.. or just don't care?</strong> Not a problem, here are the 3 lines to copy and paste - you can just paste them right in your shell to test it, or add to a startup script.<br class="C" /></p>
<pre style='font-size:8px'>export AA_P=&#34;export PVE=\&#34;\\033[m\\033[38;5;2m\&#34;\$(( \`sed -n \&#34;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&#34; /proc/meminfo\` / 1024 ))\&#34;\\033[38;5;22m/\&#34;\$((\`sed -n \&#34;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&#34; /proc/meminfo\`/ 1024 ))MB\&#34;\\t\\033[m\\033[38;5;55m\$(&#60; /proc/loadavg)\\033[m\&#34;;echo -en \&#34;\&#34;&#34;
export PROMPT_COMMAND=&#34;history -a;((\$SECONDS % 10==0 ))&#38;&#38;eval \&#34;\$AA_P\&#34;;echo -en \&#34;\$PVE\&#34;;&#34;
export PS1=&#34;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &#34; &#38;&#38; eval $AA_P</pre>]]></description>
			<content:encoded><![CDATA[<p><a style="display:block;width:140px;float:left;padding:1em;" href='http://www.askapache.com/linux-unix/bash-power-prompt.html' title='bash power prompt screenshot'><img width="116" height="62" src="http://uploads.askapache.com/2010/03/bash-power-prompt-ss-116x62.png" class="attachment-thumbnail" alt="bash power prompt screenshot" title="bash power prompt screenshot" /></a>From <strong>setting the window title</strong> to show the last run command (filtered), saving your <strong>history</strong> and keeping multi-session history intact, resetting the <strong>color/cursor/highlighting</strong> of errant color-emitting commands, these 2 prompt examples do more than meet the eye and are extremely fast.</p>
<p>Don&#8217;t have much time or just don&#8217;t care? No problem, this is a simple copy and paste&#8230; here&#8217;s one to start (all 1 line, just cut and paste right into the shell, once you&#8217;ve made sure its safe).<br class="C" /></p>
<pre>PS1=&quot;\n\[\033[1;30m\][$$:$PPID - \j:\!\[\033[1;30m\]]\[\033[0;36m\] \T \
\[\033[1;30m\][\[\033[1;34m\]\u@\H\[\033[1;30m\]:\[\033[0;37m\]${SSH_TTY:-o} \
\[\033[0;32m\]+${SHLVL}\[\033[1;30m\]] \[\033[1;37m\]\w\[\033[0;37m\] \n\$ &quot;</pre>
<p><a href='http://www.askapache.com/linux-unix/bash-power-prompt.html/toprc/' rel='attachment wp-att-4414'>toprc</a></p>
<p>Or for POWER PROMPT</p>
<pre>PROMPT_COMMAND=&#039;history -a;echo -en &quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/1024))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip&quot; /proc/meminfo`/1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;&#039;
PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
 </pre>
<h2>Or for Extreme Power Prompt</h2>
<p>Updated!  5/25/2010,  This is what I use at the moment.. It&#8217;s the coolest code I&#8217;ve ever seen to do this.  I rewrote the above (and below) bash prompts to this format because it is much more robust, and believe it or not its way faster for your machine.  Yes the code below is correct, it looks a little weird to export vars from within an exported var statement..  but this is correct. If you just learn this one bit of code, you will gain a lot of shell kung fu, at least I have!  Enjoy!</p>
<pre style='font-size:9px'>export AA_P=&quot;export PVE=\&quot;\\033[m\\033[38;5;2m\&quot;\$(( \`sed -n \&quot;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\` / 1024 ))\&quot;\\033[38;5;22m/\&quot;\$((\`sed -n \&quot;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\`/ 1024 ))MB\&quot;\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\&quot;;echo -en \&quot;\&quot;&quot;
export PROMPT_COMMAND=&quot;history -a;((\$SECONDS % 10==0 ))&amp;&amp;eval \&quot;\$AA_P\&quot;;echo -en \&quot;\$PVE\&quot;;&quot;
export PS1=&quot;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &quot;
export PVE=&quot;\\033[m\\033[38;5;2m813\\033[38;5;22m/1024MB\\t\\033[m\\033[38;5;55m0.25 0.22 0.18 1/66 26820\\033[m&quot; &amp;&amp; eval $AA_P</pre>
<pre>[24574:16122 0:344] 05:49:07 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:344)$ export AA_P=&quot;export PVE=\&quot;\\033[m\\033[38;5;2m\&quot;\$(( \`sed -n \&quot;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\` / 1024 ))\&quot;\\033[38;5;22m/\&quot;\$((\`sed -n \&quot;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\`/ 1024 ))MB\&quot;\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\&quot;;echo -en \&quot;\&quot;&quot;
&gt;&gt;&gt; export &#039;AA_P=export PVE=&quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo` / 1024 ))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/ 1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;;echo -en &quot;&quot;&#039;
&gt;&gt;&gt; AA_P=&#039;export PVE=&quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo` / 1024 ))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/ 1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;;echo -en &quot;&quot;&#039;</pre>
<pre>[24574:16122 0:345] 05:49:09 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:345)$ export PROMPT_COMMAND=&quot;history -a;((\$SECONDS % 10==0 ))&amp;&amp;eval \&quot;\$AA_P\&quot;;echo -en \&quot;\$PVE\&quot;;&quot;
&gt;&gt;&gt; export &#039;PROMPT_COMMAND=history -a;(($SECONDS % 10==0 ))&amp;&amp;eval &quot;$AA_P&quot;;echo -en &quot;$PVE&quot;;&#039;
&gt;&gt;&gt; PROMPT_COMMAND=&#039;history -a;(($SECONDS % 10==0 ))&amp;&amp;eval &quot;$AA_P&quot;;echo -en &quot;$PVE&quot;;&#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 66 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.35 0.24 0.19 1/68 27241\033[m&#039;</pre>
<pre>813/1024MB      0.35 0.24 0.19 1/68 27241
[24574:16122 0:346] 05:49:09 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:346)$ export PS1=&quot;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &quot;
&gt;&gt;&gt; export &#039;PS1=\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
&gt;&gt;&gt; PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 67 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.35 0.24 0.19 1/68 27241\033[m&#039;</pre>
<pre>813/1024MB      0.35 0.24 0.19 1/68 27241
[24574:16122 0:347] 05:49:10 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:347)$ export PVE=&quot;\\033[m\\033[38;5;2m813\\033[38;5;22m/1024MB\\t\\033[m\\033[38;5;55m0.25 0.22 0.18 1/66 26820\\033[m&quot;
&gt;&gt;&gt; export &#039;PVE=\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;
&gt;&gt;&gt; PVE=&#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 67 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;</pre>
<h2>256 Color Prompt Command</h2>
<p class="bnote"><strong>NOTE:</strong> I have been preparing a 256color terminal article for some time now, as I have tweaked, hacked, read, and experimented with more than I would ever like to admit.  So stay tuned, there isn't any tutorial, book, or online howto remotely close to as good as what I'm close to posting...</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html/super-optimized-256color-prompt/" rel="attachment wp-att-4297"><img src="http://uploads.askapache.com/2010/03/super-optimized-256color-prompt.png" alt="Super-optimized 256color BASH Prompt" title="Super-optimized 256color BASH Prompt" width="726" height="177" class="size-full wp-image-4297" /></a></p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html/256-color-prompt/" rel="attachment wp-att-4280"><img src="http://uploads.askapache.com/2010/03/256-color-prompt.png" alt="256 color prompt_command and PS1" title="256 color prompt" width="642" height="147" class="size-full wp-image-4280" /></a></p>
<p>If you have a 256-color enabled terminal try this..<br class="C" /></p>
<pre>    export PROMPT_COMMAND=&#039;echo -en &quot;\033[m\033[38;5;2m&quot;$(( `sed -n &quot;s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p&quot; /proc/meminfo`/1024))&quot;\033[38;5;22m/&quot;$((`sed -n &quot;s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip&quot; /proc/meminfo`/1024 ))MB&quot;\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m&quot;&#039;
    export PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;</pre>
<p>Which double-quoted is:</p>
<pre>declare -x PROMPT_COMMAND=&quot;echo -en \&quot;\\033[m\\033[38;5;2m\&quot;\$(( \`sed -n \&quot;s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\&quot; /proc/meminfo\`/1024))\&quot;\\033[38;5;22m/\&quot;\$((\`sed -n \&quot;s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/Ip\&quot; /proc/meminfo\`/1024 ))MB\&quot;\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\&quot;&quot;
declare -x PS1=&quot;\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ &quot;</pre>
<p class="cnote"><strong>For Commandlinefu.com users</strong>:  Here ya go!  <a href='http://www.askapache.com/linux-unix/bash-power-prompt.html/toprc/' rel='attachment wp-att-4414'>toprc</a></p>
<p>That looks great, and is practicallly totally free in terms of how much cpu/work it makes the shell do for each command.  So for slow terminals, or text-terminals like I use, this is great.  Other than PS1, there is 1 other variable..  It&#8217;s called PROMPT_COMMAND and is execed right in front of the PS1.  I show 2 ways to utilize this, the goal being to show there is no right way.. fast is fast and money is money.  I use a function called aa_pc I threw together that shows me in color how much memory is on my system.. very cool.</p>
<h2>PROMPT = ?</h2>
<p>Here&#8217;s a screenshot of the code in my vim + screen multiplexed bash 4 environment..   It&#8217;s placed all the way at the bottom of the file and is the last thing executed by the client processing the script.  Also, while it&#8217;s great to look so good, this is all 100% for efficiency since I use one shell or another every day.</p>
<div id="attachment_4177" class="wp-caption alignnone" style="width: 805px"><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html/bash-prompt-screenshot/" rel="attachment wp-att-4177"><img src="http://uploads.askapache.com/2010/03/bash-prompt-screenshot.png" alt="Custom Power Prompt - currently mine" title="Custom Power Prompt -<br />
currently mine" width="795" height="596" class="size-full wp-image-4177" /></a><p class="wp-caption-text">Custom Power Prompt - currently mine</p></div>
<p>Here&#8217;s the code I&#8217;m using today, that produced this screen-shot &#8212; I am always changing stuff so it&#8217;s a little more tough to figure out.</p>
<pre>  function aa_pc()
  {
        local M=$( free -olm|sed &quot;/Mem/!d; s/Mem:[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\).*/ \
        ${GREP_COLOR}\2MB${R}\/\3MB/&quot;; ); echo -e &quot;$M `pwd`&quot;
  }
&nbsp;
  aa_grep_color(){ export GREP_COLOR=`tput setaf $(aa_random_under 6)`; }
  aa_random_under(){ echo -en $(( $RANDOM % ${1:-$RANDOM} + 1 )); }
  uptime1(){ sed &#039;/.*,  \([0-9]*\) users,  load average: \(.*\)/!d; s//[ \2, \1 users ]/;q&#039;;
&nbsp;
  $SED -n &#039;/i/!Q2&#039; &lt;&lt;&lt; $- &amp;&amp; \
  {
        case ${TERM:-dummy} in xterm*|screen*|*color*)echo; ;; *) return; esac;
  }
&nbsp;
  # hack for being able to source all the functions in this file from a script
  MASTER_RESET=$`echo -e &quot;rs1\nrs2\ninitc\nis2\ncnorm\nrmso\nsgr0&quot; | tput -S`
&nbsp;
  # only for color-aware (some guessing) terminals, kick everyone else OUT
  case ${TERM:-dummy} in xterm*|screen*|*color*)echo; ;; *) return; esac;
&nbsp;
  [[ -r /etc/DIR_COLORS ]] &amp;&amp; eval `dircolors -b /etc/DIR_COLORS`
&nbsp;
  # changes the window title in terminals like putty or konsole
  echo -ne &quot;\033]0; ${USER}@${HOSTNAME}  +${SHLVL} @${SSH_TTY/\/dev\/} - `uptime1` \007&quot;
&nbsp;
  # show title, setup the colors, vars, funcs, settings
  asetup_colors &amp;&amp; ascript_title
  export PROMPT_COMMAND=&#039;history -a;aa_pc&#039;
  export PS1=&#039;\[\033[1;30m\][$$:$PPID - \j:\!\[\033[1;30m\]]\[\033[0;36m\] \T\
  \d \[\033[1;30m\][\[\033[1;34m\]\u@\H\[\033[1;30m\]:\[\033[0;37m\]${SSH_TTY} \
  \[\033[0;32m\]+${SHLVL}\[\033[1;30m\]] \[\033[1;37m\]\w\[\033[0;37m\] \n\$ &#039;</pre>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ss.png" alt="bash power prompt screenshot" title="bash power prompt screenshot" width="898" height="480" /></a></p>
<p>I&#8217;ve used many shells over the years and have learned many tweaks and tricks for a powerful prompt.  It may look deceptively simple.  One cool thing this prompt does is display the command line (filtered) in the putty/konsole/xterm window, so if you have several windows minimized you can easily find the one you are looking for.<br class="C" /></p>
<p>There is a lot of good info about the BASH prompt around the net, but it can be complicated for a new user, and as an advanced user you will notice most of the info is very outdated and not very optimized for speed.  To get this articles recommended prompt working is devastatingly simple, just export the <code>PROMPT_COMMAND</code> and <code>PS1</code> variables that are shown below.  Most &#8220;power prompts&#8221; that utilize things like PROMPT_COMMAND do so very haphazardly or very extravagantly.</p>
<p>I&#8217;ve been called a lot of things but not extravagant, and because I use this prompt on many different servers, platforms, and systems I made sure to not make things complicated.  To test them just copy and paste the code below into your shell which will <strong>export PROMPT_COMMAND</strong> and <strong>PS1</strong> variables and work right away.  So test it out, and if you like it add it to your .bashrc or other startup file (please do a <code>$ man bash</code>).</p>
<ul>
<li><a href="#power-prompt-commands" rel="nofollow" >Custom Power Prompt Commands</a>
<ol>
<li><a href="#prompt_command" rel="nofollow" >PROMPT_COMMAND Detailed</a></li>
<li><a href="#detailed-ps1" rel="nofollow" >PS1 Detailed</a></li>
</ol>
</li>
<li><a href="#hacker-prompts" rel="nofollow" >Additional Info for Hackers</a>
<ol>
<li><a href="#set-xterm-title" rel="nofollow" >Setting Window Title</a></li>
<li><a href="#strip-colors" rel="nofollow" >Stripping Colors from PS1</a></li>
<li><a href="#uptime-alt" rel="nofollow" >Alternative to Uptime/Loadavg (proc)</a></li>
<li><a href="#multi-prompt-switcher" rel="nofollow" >Multi-Prompt Switcher Function</a></li>
</ol>
</li>
<li><a href="#bash-prompt-reading" rel="nofollow" >Bash Prompts &#8211; More Reading</a>
<ol>
<li><a href="#ps1-examples" rel="nofollow" >Other Simple Power Prompt Examples</a></li>
<li><a href="#bash-prompt-vars" rel="nofollow" >All Prompt Variables</a></li>
<li><a href="#prompt-escapes" rel="nofollow" >Escape Codes for PS1</a></li>
<li><a href="#more-reading" rel="nofollow" >Additional Reading</a></li>
</ol>
</li>
</ul>
<p><a id="power-prompt-commands" name="power-prompt-commands"></a></p>
<h2>Bash Power Prompt</h2>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1.png" alt="bash power prompt PS1" title="bash power prompt PS1" width="513" height="96" /></a><br />From setting the window title to show the last run command (filtered), saving your history and keeping multi-session history intact, resetting the color/cursor/highlighting of errant color-emitting commands, this prompt does more than meets the eye extremely fast.</p>
<p class="enote">Don&#8217;t have much time? Don&#8217;t care?  You may copy and paste these 2 lines into your shell and that&#8217;s all there is to it!</p>
<pre>export PROMPT_COMMAND=&#039;export H1=&quot;`history 1|sed -e &quot;s/^[\ 0-9]*//; s/[\d0\d31\d34\d39\d96\d127]*//g; s/\(.\{1,50\}\).*$/\1/g&quot;`&quot;;history -a;echo -e &quot;sgr0\ncnorm\nrmso&quot;|tput -S&#039;
export PS1=&#039;\n\e[1;30m[\j:\!\e[1;30m]\e[0;36m \T \d \e[1;30m[\e[1;34m\u@\H\e[1;30m:\e[0;37m`tty 2&gt;/dev/null` \e[0;32m+${SHLVL}\e[1;30m] \e[1;37m\w\e[0;37m\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;</pre>
<p><a id="prompt_command" name="prompt_command"></a></p>
<h2>PROMPT_COMMAND</h2>
<p>This holds commands to be run prior to displaying the prompt.  Let&#8217;s break it down.</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/askapache-prompt.jpg" alt="PS1 Prompt Example" title="PS1 Prompt Example" width="663" height="120" class="size-full wp-image-4150" /></a></p>
<p>First this takes the last command executed and filters it using sed to remove the initial history command number, and also to remove any quotes (single or double) and/or backticks.  Also, it only saves the first 50 chars, which are then exported as the value of H1, which because it is exported is now globally accessible to the rest of the shell.  This is important because we use this variable in PS1 to print the last run command as the title of our putty window (or konsole).</p>
<pre>export H1=`history 1 | sed -e &#039;s/^[\ 0-9]*//; s/[\d0\d31\d34\d39\d96\d127]*//g; s/\(.\{1,50\}\).*$/\1/g&#039;`</pre>
<p>The next command simply appends your last command to the history file.  Usually this is <code>~/.bash_profile</code>, or whatever <code>$HISTFILE</code> is.  This makes sure you never lose history in case of a shell crash or ssh connection terminated. </p>
<pre>history -a</pre>
<p>Finally there is this golden nugget of shell kung-fu.  This outputs 3 terminal escape sequences according to the terminal in use and its capabilities.. so very robust, should work on any shell newer than 1984.  By echoing the following 3 term names separated by a newline <code>\n</code> and using tput -S it will output the terminal sequences for all 3.  sgr0 resets the colors, cnorm resets the cursor, and rmso resets the background color.</p>
<p class="cnote">You can view the escape sequences generated by tput with strace, cat -t, etc..  For instance on my shell (xterm-256color via portaputty) the below command generates: <code>\33(B\33[m\33[?12l\33[?25h\33[27m</code>.  This is helpful because if you aren't coding for several terminals you can hard code that in your echo's instead of using tput, saving some overhead.</p>
<pre>echo -e &#039;sgr0\ncnorm\nrmso&#039; | tput -S
# For my term this is the same as if I just did
# echo -e &quot;\33(B\33[m\33[?12l\33[?25h\33[27m&quot;</pre>
<p><a id="detailed-ps1" name="detailed-ps1"></a></p>
<h2>PS1 Detailed</h2>
<p><code>PS1</code> is the variable that is expanded as your prompt.  So if you did a <code>$ unset PS1</code> then you can still run commands and everything, but your screen will be blank which is confusing to say the least.</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/askapache-htop.jpg" alt="The HTOP command in full color to manage mysql" title="The HTOP command in full color to manage mysql" width="404" height="176" class="size-full wp-image-4149" /></a></p>
<p>This PS1 shows which SHLVL level the shell is in, which is how many levels deep of shells you are currently at.  If you run <code>$ bash -l</code> from a bash shell it will create a new instance of bash as a child of the calling bash, so the SHLVL (shell level) gets incremented by 1.  I usually avoid creating subshells by instead executing a new bash with <code>exec</code> which instead of creating a new bash as a child of the current bash, it replaces the current bash process with the new one: <code>$ exec bash -l</code>.</p>
<pre>export PS1=&#039;\n\e[1;30m[\j:\!\e[1;30m]\e[0;36m \T \d \e[1;30m[\e[1;34m\u@\H\e[1;30m:\e[0;37m`tty 2&gt;/dev/null` \e[0;32m+${SHLVL}\e[1;30m] \e[1;37m\w\e[0;37m\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;
&nbsp;
# with nocolors
# export PS1=&#039;\n[\j:\!] \T \d [\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;</pre>
<h3>TTY</h3>
<p>This command is very useful for me because I use multiplexed terminals, about 6 at a time, so it is crucial sometimes to know which tty I am using.  Since SSH is the ONLY protocol I ever use for anything, I used to depend on the SSH_TTY variable being set instead of using tty, which as a command has more overhead then just echoing a variable.  But I found that when running multiplexing terminals with tmux, screen, etc.. the SSH_TTY variable stays with the initial tty created upon login.   <strong>Note:</strong> <code>2>/dev/null</code> redirects any errors that running the tty command might issue to the /dev/null device, which is the same thing as a black hole, it goes nowhere so is an efficient way to send data for deletion.  Depending on your server and ssh settings you may not even have a tty or it may just appear that you do not.  Some web hosting companies do odd things to prevent their users from using tty devices and programs.  But if you get a little creative you can always find the current tty.. like <code>$ readlink /proc/self/fd/0</code> will return the same thing as <code>$ tty</code>.</p>
<pre>`tty 2&gt;/dev/null`</pre>
<p><a id="set-xterm-title" name="set-xterm-title"></a></p>
<h3>Changing Window Title with PS1</h3>
<p>This simple bash function changes the title of the window to the passed parameter.  The key thing to note is that this works because of the special escapes on either end of the echo'd data.</p>
<pre>function set_window_title()
{
  echo -e &quot;\033]0; ${1:-$USER@$HOST - $SHLVL} \007&quot;;
}</pre>
<p><a id="hacker-prompts" name="hacker-prompts"></a></p>
<h2>Additional Info for Hackers</h2>
<p>More reading and digging.</p>
<p><a id="strip-colors" name="strip-colors"></a></p>
<h3>Strip Colors for Readability</h3>
<p>You can use this command to strip a PS1 of all colors, which shortens the variable dramatically in some cases.</p>
<pre>sed &#039;s/\\[eE][[0-9]*;[0-9]*m//g&#039; &lt;&lt;&lt; $PS1
# ie export PS1=$(sed &#039;s/\\[eE][[0-9]*;[0-9]*m//g&#039; &lt;&lt;&lt; $PS1);</pre>
<p><a id="multi-prompt-switcher" name="multi-prompt-switcher"></a></p>
<h3>Multi-Prompt Switcher Function</h3>
<p>This function demonstrates 1 way that you can change your prompts at will.  It creates an array named AAPS that you can add as many PS1 values to as you want.  Each time the function is run it simply changes the prompt string variable PS1 to the value of the next item in the AAPS array.  Once it reaches the last item in AAPS, it resets back to the first <code>AAPS[0]</code> prompt.  Just an example to play with, not tested very much.</p>
<pre>aa_multi_prompt ()
{
    declare -a AAPS;
    AAPS[0]=&#039;\n[\j:\!] \T \d [\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$&#039;;
    AAPS[1]=&#039;\n[\j:\!] \T \d \n[\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}&#46;.. ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$&#039;;
&nbsp;
    : ${PLVL:=0};
    [[ &quot;${#AAPS[@]}&quot; -lt &quot;$PLVL&quot; || &quot;${#AAPS[@]}&quot; -eq &quot;$PLVL&quot; ]] &amp;&amp; PLVL=0;
    export PS1=${AAPS[$PLVL]} &amp;&amp; (( PLVL++ )) &amp;&amp; export PLVL
}</pre>
<h3>BASH 4 Multi-Prompt</h3>
<p>Here's an example from bash-4, but it works for all bash versions.</p>
<pre>prompt ()
{
    case &quot;$1&quot; in
        d)
            PS1=&#039;$(dirs) \$ &#039;
        ;;
        n)
            PS1=&#039;\$ &#039;
        ;;
        hsw)
            PS1=&#039;\h[$SHLVL]: \w \$ &#039;
        ;;
        hw)
            PS1=&#039;\h: \w \$ &#039;
        ;;
        sh)
            PS1=&#039;[$SHLVL] \h\$ &#039;
        ;;
        sw)
            PS1=&#039;[$SHLVL] \w \$ &#039;
        ;;
        uh)
            PS1=&#039;\u@\h\$ &#039;
        ;;
        uhsHw)
            PS1=&#039;\u@\h[$SHLVL]:\#: \w \$ &#039;
        ;;
        uhsw)
            PS1=&#039;\u@\h[$SHLVL]: \w \$ &#039;
        ;;
        uhw)
            PS1=&#039;\u@\h: \w \$ &#039;
        ;;
        uw)
            PS1=&#039;(\u) \w \$ &#039;
        ;;
        w)
            PS1=&#039;\w \$ &#039;
        ;;
    esac
}</pre>
<p><a id="uptime-alt" name="uptime-alt"></a></p>
<h3>Alternative to uptime:</h3>
<pre>echo &quot;Up for $(( $(sed &#039;s/^\([0-9]*\).*/\1/&#039; /proc/uptime) / (60*60*24) )) days - [`cat /proc/loadavg`]&quot;
# or
echo &quot;Uptime: $(( `sed &#039;s/^\([0-9]*\).*/\1/g&#039; /proc/uptime` / 86400 )) days. Load: $(&lt;/proc/loadavg)&quot;</pre>
<p><a id="bash-prompt-reading" name="bash-prompt-reading"></a></p>
<h2>Bash Prompts - More Reading</h2>
<p><a id="bash-prompt-vars" name="bash-prompt-vars"></a></p>
<h3>All Bash Prompt Variables</h3>
<p>These are the environment variables provided by BASH (and most shells) and control your prompt string.   While all are interesting and good to know about, <code>PROMPT_COMMAND</code> and <code>PS1</code> are the only ones that directly modify the prompt that is displayed.</p>
<dl>
<dt>PROMPT_COMMAND</dt>
<dl>If set, the value is executed as a command <strong>prior</strong> to issuing each primary prompt.</dl>
<dt>PS1</dt>
<dl>The value of this parameter is expanded and used as the primary prompt string.  The default value is "<code>\s-\v\$ </code>".</dl>
<dt>PS2</dt>
<dl>The value of this parameter is expanded as with PS1 and used as the secondary prompt string.  The default is "<code>> </code>".</dl>
<dt>PS3</dt>
<dl>The value of this parameter is used as the prompt for the select command.</dl>
<dt>PS4</dt>
<dl>The  value of this parameter is expanded as with PS1 and the value is printed before each command bash displays during an execution trace.  The first character of PS4 is replicated multiple times, as necessary, to indicate multiple levels of indirection.  The default is "<code>+</code>".</dl>
</dl>
<p><a id="prompt-escapes" name="prompt-escapes"></a></p>
<h3>Prompt Escape Codes</h3>
<p>When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command and the secondary prompt PS2 when it needs more input to complete a command.  Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:</p>
<ul>
<li><code>\a</code> - an ASCII bell character (07)</li>
<li><code>\d</code> - the date in "Weekday Month Date" format (e.g., "Tue May 26")</li>
<li><code>\D{format}</code> - the format is passed to <a href="http://www.freebsd.org/cgi/man.cgi?query=strftime" rel="nofollow" >strftime(3)</a> and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.  The braces are required
<li><code>\e</code> - an ASCII escape character (033)</li>
<li><code>\h</code> - the hostname up to the first '.'</li>
<li><code>\H</code> - the hostname</li>
<li><code>\j</code> - the number of jobs currently managed by the shell</li>
<li><code>\l</code> - the basename of the shellâs terminal device name</li>
<li><code>\n</code> - newline</li>
<li><code>\r</code> - carriage return</li>
<li><code>\s</code> - the name of the shell, the basename of <var>$0</var> (the portion following the final slash)</li>
<li><code>\t</code> - the current time in 24-hour HH:MM:SS format</li>
<li><code>\T</code> - the current time in 12-hour HH:MM:SS format</li>
<li><code>\@</code> - the current time in 12-hour am/pm format</li>
<li><code>\A</code> - the current time in 24-hour HH:MM format</li>
<li><code>\u</code> - the username of the current user</li>
<li><code>\v</code> - the version of bash (e.g., 2.00)</li>
<li><code>\V</code> - the release of bash, version + patch level (e.g., 2.00.0)</li>
<li><code>\w</code> - the current working directory, with <var>$HOME</var> abbreviated with a tilde</li>
<li><code>\W</code> - the basename of the current working directory, with <var>$HOME</var> abbreviated with a tilde</li>
<li><code>\!</code> - the history number of this command</li>
<li><code>\#</code> - the command number of this command</li>
<li><code>\$</code> - if the effective UID is 0, a <strong>#</strong>, otherwise a <strong>$</strong></li>
<li><code>\nnn</code> - the character corresponding to the octal number nnn
<li><code>\\</code> - a backslash</li>
<li><code>\[</code> - begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt</li>
<li><code>\]</code> - end a sequence of non-printing characters</li>
</ul>
<p>The  command  number  and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file, while the command number is the position in the sequence of commands executed during the current shell session.  After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal, subject to the value of the promptvars shell option, which if set, prompt strings undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded as described in PROMPTING above.   <var>promptvars</var> is enabled by default.</p>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1.png" alt="bash power prompt PS1" title="bash power prompt PS1" width="513" height="96" /></a></p>
<p><a id="ps1-examples" name="ps1-examples"></a></p>
<h3>More Example Prompts</h3>
<pre>export PS1=&quot;\n\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]\n$ \e[0m&quot;
[user@host][~/bin/tools]
$</pre>
<pre>export PS1=&quot;\n[$?]\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]($SHLVL:\!)\n\[\033[0m\]\$ &quot;
[0][user@host][~/bin/tools](1:2130)</pre>
<pre>export PS1=&#039;\[\033[1;33m\]\u\[\033[1;37m\]@\[\033[1;32m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]&#039;
user@host:~/bin/tools $</pre>
<pre>export PS1=&quot;\e[1;31m[\h]$NC \W &gt; \[\033]0;\${TERM} [\u@\h] \w\]&quot;
[lifesaver] tools &gt;</pre>
<h2>Benchmarking PROMPT_COMMAND</h2>
<p>When figuring out how resource intensive your prompt_command is (if you choose to do that sort of thing), it's nice to do it like this.  I ended up using  this information from the following test to create the prompt_command used in the first 256-color prompt above.</p>
<pre>#!/bin/bash
&nbsp;
function clean_results()
{
      grep ^real | cut -dm -f2 | sort | uniq -c | sort -n
}
&nbsp;
for i in {0..500};
do
      time sh -c &quot;expr `sed -nu &#039;s/^MemFree:[\t ]\+\([0-9]\+\) kB/\1/Ip&#039; /proc/meminfo`/1024&quot; &amp;&gt;/dev/nulll;
done 2&gt;&amp;1 | clean_results
&nbsp;
# print separating line
printf &quot;%$((${COLUMNS:-`tput cols`} - 10))s\n&quot; &#039; &#039; | sed -u &#039;s/ /-/g&#039;
&nbsp;
for i in {0..500};
do
      time sh -c &quot;echo $(( `sed -nu &#039;s/^MemFree:[\t ]\+\([0-9]\+\) kB/\1/Ip&#039; /proc/meminfo`/1024 ))&quot; &amp;&gt;/dev/null;
done 2&gt;&amp;1 | clean_results
&nbsp;
exit $?</pre>
<p>Generates this output, meaning that using expr takes longer.</p>
<pre>      1 0.011s
      1 0.014s
      2 0.009s
      2 0.012s
      5 0.008s
     12 0.004s
     47 0.007s
    215 0.005s
    216 0.006s
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-
      1 0.003s
      2 0.007s
     59 0.006s
    196 0.004s
    243 0.005s</pre>
<p><a id="more-reading" name="more-reading"></a></p>
<h3>Additional Links</h3>
<ul>
<li><a href="http://tldp.org/HOWTO/From-PowerUp-To-Bash-Prompt-HOWTO.html" rel="nofollow" >From Power Up To Bash Prompt - TLDP</a></li>
<li><a href="http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Bash-Prompt-HOWTO.html" rel="nofollow" >Bash Prompt HOWTO -TLDP</a></li>
<li><a href="http://tldp.org/LDP/abs/html/sample-bashrc.html" rel="nofollow" >A Sample .bashrc File - TLDP</a></li>
<li><a href="http://gentoo.linuxhowtos.org/bash/bash_prompt_howto.htm" rel="nofollow" >Gentoo Linux Howtos: bash -> Bash Prompt Howto - Gentoo</a></li>
<li><a href="http://www.debian-administration.org/article/Fancy_Bash_Prompts" rel="nofollow" >Fancy Bash Prompts - Debian Administration</a></li>
</ul>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"></a><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html">Crazy POWERFUL Bash Prompt</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux-unix/bash-power-prompt.html/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Questions I Ask Web Hosting Companies, Before Buying</title>
		<link>http://www.askapache.com/web-hosting/before-buying-web-hosting.html</link>
		<comments>http://www.askapache.com/web-hosting/before-buying-web-hosting.html#comments</comments>
		<pubDate>Sun, 25 Apr 2010 10:15:16 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Making Money]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Powweb]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[Web Hosts]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4419</guid>
		<description><![CDATA[<p>The following is a transcript of a chat I had with a company called tektonic, and at that time I was looking for a cheap linux host to use for some redundancy/failover operations.  I generally contact a new hosting company like this every few months.. I like to have options available in case of some kind of failure or network attack, so it's always a good idea to have a few ace linux servers in your back pocket.</p>
<p>If you've read any other articles on AskApache, you can see a certain obsession towards optimization, speed, and security -- so that is the purpose of the following questions.</p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always on the lookout for cheap hosting and great hosting companies, and being that I have done this for many years, on many platforms, and with many hosts, my only requirement is that the host uses a UNIX/BSD/LINUX operating system.  I&#8217;m just not one of those people who likes to do things the hard way, constantly, if its even possible on a non-nix, or one of those people who enjoys getting hacked or my sites defaced by a cracker.  So *nix is definitely a requirement.  This is just a current look at the basic idea I use when looking for a web host.  If you were smart you would do a whole lot more than this.</p>
<h2>Research the People</h2>
<p>Ok, in a web hosting company there are 5 distinct groups of people, at least generally, that you will want to get in contact with or at least do some background research on (like the owners/founders).  Depending on which of these groups you talk to will determine the amount and quality of information you get, the difference is night and day. Because of my past experience with really bad hosts (DreamHost), and really great hosts (<a href="http://www.wiredtree.com/298.html"rel="nofollow" >WiredTree</a>), I am very cautious and purposeful in making this decision, so I go to great lengths to contact at least one person from each of these groups.  Most good advice says to also get in touch with customers.. I don&#8217;t usually need/want to do that though because most customers don&#8217;t know jack.  But of course I know a few of the customers because I research the hosts network block and test the speed and servers that run on their IP block.</p>
<h3>Who / Why</h3>
<p>Being a curious and inquisitive person by nature, I always do background research on who started the company, how they started it, and what skills they have.  Knowing who the owners are and if they are real unix/network experts or just snake oil salesmen really makes a difference in this world of smoke and mirrors.</p>
<p> Here&#8217;s my recommendation of which group to contact, in order of best to worst:</p>
<ol>
<li><strong>Owners/Founders</strong> &#8211; The Founders have been involved since the start of the company.  Always contact.</li>
<li><strong>System Admins</strong> &#8211; Programmers and System Operators who keep things running, fix problems tech support cant.  Always contact.</li>
<li><strong>Sales/Marketing</strong> &#8211; Both types have different motivations for what they say, and how they say it.  Always contact both.</li>
<li><strong>Tech Support</strong> &#8211; They make the web go round, will always know a lot about problems and issues their customers frequently experience.  Always contact.</li>
<li><strong>Management</strong> &#8211; These people are in charge of the day-to-day operations, overseers.  Contact optional.</li>
</ol>
<h2>Questions to Ask</h2>
<p>The following is a transcript of a chat I had with a company called <a href="http://tektonic.net/" rel="nofollow" >tektonic</a>, and at that time I was looking for a cheap linux host to use for some redundancy/failover operations.  I generally contact a new hosting company like this every few months.. I like to have options available in case of some kind of failure or network attack, so it&#8217;s always a good idea to have a few ace linux servers in your back pocket.</p>
<p>If you&#8217;ve read any other articles on AskApache, you can see a certain obsession towards optimization, speed, and security &#8212; so that is the purpose of the following questions.</p>
<table cellspacing="0" cellpadding="5" border="1" width="100%" dir="ltr">
<tbody>
<tr>
<td colspan="2">
<div>General Info</div>
</td>
</tr>
<tr>
<td><strong>Chat start time</strong></td>
<td> Apr 7, 2010 7:18:07 AM EST</td>
</tr>
<tr>
<td><strong>Chat end time</strong></td>
<td> Apr 7, 2010 8:38:52 AM EST</td>
</tr>
<tr>
<td><strong>Duration (actual chatting time)</strong></td>
<td> 01:20:44</td>
</tr>
<tr>
<td><strong>Operator</strong></td>
<td> Vish</td>
</tr>
</tbody>
</table>
<h2>Chat Transcript</h2>
<div class="zebra3" style="font-size:1.1em;line-height:.9em;">
<blockquote>
<p style="color:#ccc"><strong>info:</strong> Please wait for a site operator to respond. You are 1 out of 1 in the queue. The average wait time is 0 minutes and 30 seconds.</p>
<p style="color:#ccc"><strong>info:</strong> You are now chatting with &#39;Vish&#39;</p>
<p><strong>Vish:</strong> Hello</p>
<p class="aa21"><strong>AskApache:</strong> Hi vish, i was looking to purchase a planwith you guys but had some questions.. is this the right place to ask?</p>
<p><strong>Vish:</strong> yeah sure</p>
<p><strong>Vish:</strong> Let me know how may I assist you with ?</p>
<p class="aa21"><strong>AskApache:</strong> what is your cheapest plan that includes ssh?</p>
<p><strong>Vish:</strong> <a href="http://tektonic.net/vps.php" rel="nofollow" >http://tektonic.net/vps.php</a></p>
<p><strong>Vish:</strong> Linux-360</p>
<p class="aa21"><strong>AskApache:</strong> im there.. </p>
<p><strong>Vish:</strong> It is cheapest plan you can have</p>
<p class="aa21"><strong>AskApache:</strong> what does full root access mean for you guys? </p>
<p class="aa21"><strong>AskApache:</strong> do you have swap? jailshell?</p>
<p><strong>Vish:</strong> you have full access of you server .</p>
<p class="aa21"><strong>AskApache:</strong> including network interface device access? ie.. is it possible to setup virtual nics?</p>
<p><strong>Vish:</strong> Sorry we do not provide it.</p>
<p><strong>Vish:</strong> hold on </p>
<p><strong>Vish:</strong> Let me check</p>
<p class="aa21"><strong>AskApache:</strong> how can i find out more about the limits of the machine for the Linux-360?</p>
<p class="aa21"><strong>AskApache:</strong> like how many processes, fd descriptors.. </p>
<p><strong>Vish:</strong> You can mail us at sales department.</p>
<p><strong>Vish:</strong> They will get back to you with in few hrs with your answers </p>
<p><strong>Vish:</strong> You can just drop mail at <a href="mailto:sales@tektonic.net" rel="nofollow" >sales@tektonic.net</a></p>
<p class="aa21"><strong>AskApache:</strong> no thanks.</p>
<p class="aa21"><strong>AskApache:</strong> jw if you had that info offhand.</p>
<p class="aa21"><strong>AskApache:</strong> do you know if cpanel is optinoal?</p>
<p class="aa21"><strong>AskApache:</strong> could it be uninstalled?</p>
<p><strong>Vish:</strong> yeah</p>
<p><strong>Vish:</strong> you can install or uninstall as you wish </p>
<p class="aa21"><strong>AskApache:</strong> Thanks vish you are being very helpful&#8230; a few more.. </p>
<p><strong>Vish:</strong> sure</p>
<p class="aa21"><strong>AskApache:</strong> what operating system?</p>
<p><strong>Vish:</strong> Hold on ..</p>
<p><strong>Vish:</strong> allow me a moment. </p>
<p class="aa21"><strong>AskApache:</strong> please take your time</p>
<p><strong>Vish:</strong> We do provide Ubantu , Centos and Debian</p>
<p><strong>Vish:</strong> You can reinstall your server any time with one click </p>
<p class="aa21"><strong>AskApache:</strong> what devices are supported in /dev ?</p>
<p class="aa21"><strong>AskApache:</strong> do you support loop devices, ramdisk/tmpfs/swap?</p>
<p><strong>Vish:</strong> One moment please..</p>
<p class="aa21"><strong>AskApache:</strong> no rush at all, thanks</p>
<p><strong>Vish:</strong> We do provide tmpfs but ramdisk and swap is not available .</p>
<p><strong>Vish:</strong> All basic device are available with us optional devices like TUN is also enabled for you automatically. </p>
<p class="aa21"><strong>AskApache:</strong> sweet</p>
<p class="aa21"><strong>AskApache:</strong> is ipv6 supported?</p>
<p><strong>Vish:</strong> It is there but we do support currently .</p>
<p><strong>Vish:</strong> We are thinking to provide it in near future for our clients ;)</p>
<p class="aa21"><strong>AskApache:</strong> good idea, people will start using it in 5years or so.. maybe</p>
<p class="aa21"><strong>AskApache:</strong> how is the internal network segmented? vlans? </p>
<p class="aa21"><strong>AskApache:</strong> for security..</p>
<p><strong>Vish:</strong> Yeah, We do have Vlans</p>
<p class="aa21"><strong>AskApache:</strong> security is very crucial.</p>
<p><strong>Vish:</strong> You can check  more info in network here <a href="http://tektonic.net/network.php" rel="nofollow" >network</a></p>
<p class="aa21"><strong>AskApache:</strong> ok thanks brb</p>
<p class="aa21"><strong>AskApache:</strong> do you allow kernel modules? or reloading the kernel like kexec?</p>
<p><strong>Vish:</strong> a moment please.</p>
<p><strong>Vish:</strong> What type kernel module you are looking for exactly ?</p>
<p><strong>Vish:</strong> kexex is  for fast reboot .</p>
<p><strong>Vish:</strong> Is there any specific requirement ?</p>
<p><strong>Vish:</strong> As we do not allow kernel modules on VPS they are not supported by virtuzzo. </p>
<p class="aa21"><strong>AskApache:</strong> ok.. so far so good. let me think a minute.</p>
<p class="aa21"><strong>AskApache:</strong> what kind of failovers do you have? </p>
<p class="aa21"><strong>AskApache:</strong> like if a machine fails to reboot or goes offline</p>
<p><strong>Vish:</strong> we do not provide failover services for vpses at this time. You  will have power panel in hand using it you can reboot or reinstall your machine in one click. You can reach us 24*7 for live support.</p>
<p class="aa21"><strong>AskApache:</strong> one problem that I&#39;ve seen on other vps&#39;s is sometimes a vps upon reboot fails to recognize the network interface/fails to connect to the web.. When that happens we are unable to ssh into the box to fix the problem and rely on support.. is this something that would be easy/normal for your support (to have to manually login to the vps locally)</p>
<p><strong>Vish:</strong> There are the possiblities for the issue so we need to check in server but you can reach us anytime for live chat and ticket system.</p>
<p><strong>Vish:</strong> as you are on live chat right now ;)</p>
<p class="aa21"><strong>AskApache:</strong> so your support does have access to the vps locally? </p>
<p class="aa21"><strong>AskApache:</strong> in case the network is down due to vps errors</p>
<p><strong>Vish:</strong> Yes, We have the access</p>
<p class="aa21"><strong>AskApache:</strong> do you run any packet filtering on the network or is this controlled solely with the vps?</p>
<p class="aa21"><strong>AskApache:</strong> like iptables stuff.. switch/router filtering beyond defaults..</p>
<p><strong>Vish:</strong> No , we dont have packet filtering the port we block is IRC only.</p>
<p class="aa21"><strong>AskApache:</strong> great</p>
<p><strong>Vish:</strong> I&#39;m sorry for the delay. I&#39;ll be right with you.</p>
<p><strong>Vish:</strong> Is there anything else I may assist you with ?</p>
<p class="aa21"><strong>AskApache:</strong> no problem, you&#39;ve answered all my questions so far.. trying to think of anything else I&#39;d like to know before buying.. </p>
<p><strong>Vish:</strong> Sure</p>
<p><strong>Vish:</strong> Is there anything else I can help you with ?</p>
<p class="aa21"><strong>AskApache:</strong> Does the Linux-360 support filesystems? what storage devices are included (usually just 1 ext2/3/4 fs for vps).. Is it possible to repartition the drive? </p>
<p class="aa21"><strong>AskApache:</strong> Oh and the other kernel module I would love to have on a vps is fuse so that I can mount remote filesystems (such as sshfs or nbd)</p>
<p><strong>Vish:</strong> We do not provide kernel modules on VPS.</p>
<p class="aa21"><strong>AskApache:</strong> do you allow kernel compilation? (that way i can build the module statically into the kernel) </p>
<p><strong>Vish:</strong> A moment please.</p>
<p><strong>Vish:</strong> We do not allow kernel compilation on VPS.</p>
<p class="aa21"><strong>AskApache:</strong> ok, thats smart security</p>
<p class="aa21"><strong>AskApache:</strong> what about the linux-360 partitioning question?</p>
<p><strong>Vish:</strong> Thanks. :)</p>
<p><strong>Vish:</strong> it is tmpfs on VPS</p>
<p><strong>Vish:</strong> and we dot allow repartition.</p>
<p class="aa21"><strong>AskApache:</strong> which is ultimately mounted on.. filesystems? like could I modify an ext3 / to ext4 or reiserfs?</p>
<p class="aa21"><strong>AskApache:</strong> expected.. ok</p>
<p><strong>Vish:</strong> No, it is vzfs</p>
<p class="aa21"><strong>AskApache:</strong> even better.</p>
<p class="aa21"><strong>AskApache:</strong> thats what i mostly use.</p>
<p><strong>Vish:</strong> great</p>
<p class="aa21"><strong>AskApache:</strong> What vps os install images do you use? like where do you get the CentOS/Ubuntu/Debian vps images? And are they modified/customized by you guys in any way?</p>
<p class="aa21"><strong>AskApache:</strong> Or just all defaults?</p>
<p><strong>Vish:</strong> they include basic services such as httpd, sendmail</p>
<p class="aa21"><strong>AskApache:</strong> sorry for all the q&#39;s &#8230; I wasn&#39;t thinking that I&#39;d actually find a good host to purchase, but so far tek is looking really good.. might go ahead within the hour.</p>
<p><strong>Vish:</strong> otherwise default </p>
<p><strong>Vish:</strong> We get it from parallels</p>
<p><strong>Vish:</strong> Okay great.</p>
<p><strong>Vish:</strong> Is there anything else I can help you with ?</p>
<p class="aa21"><strong>AskApache:</strong> like: <a href="http://download.openvz.org/template/precreated/" rel="nofollow" >http://download.openvz.org/template/precreated/</a></p>
<p class="aa21"><strong>AskApache:</strong> do you use templates like that.. </p>
<p><strong>Vish:</strong> We get it  from parallels</p>
<p class="aa21"><strong>AskApache:</strong> how many employees do you have? how many customers? </p>
<p><strong>Vish:</strong> Sorry, We do not disclose this information</p>
<p class="aa21"><strong>AskApache:</strong> thats fine.. </p>
<p><strong>Vish:</strong> For more you can contact sales department.</p>
<p><strong>Vish:</strong> You are on technical department live chat.</p>
<p class="aa21"><strong>AskApache:</strong> can you give me more info on what type of parallels products you utilize? </p>
<p class="aa21"><strong>AskApache:</strong> I wouldn&#39;t last long on any other chat.. ;)</p>
<p class="aa21"><strong>AskApache:</strong> I&#39;m curious so if it&#39;s a template/container I haven&#39;t used before I can test it out on my own machine.</p>
<p><strong>Vish:</strong> We provide power panel from parallels</p>
<p class="aa21"><strong>AskApache:</strong> i mean like the templates/container versions you use.. I want to check that you use updated/new versions and are valid licensed.</p>
<p><strong>Vish:</strong> you mean OS version ?</p>
<p class="aa21"><strong>AskApache:</strong> basically, do you know if you use the latest available os images from parallels.. </p>
<p class="aa21"><strong>AskApache:</strong> and I will let you go with that.. </p>
<p style="color:#ccc"><strong>info:</strong> Your chat transcript will be sent to your email at the end of your chat.</p>
<p><strong>Vish:</strong> Yes , We do provide latest OS version as per requirement. </p>
<p class="aa21"><strong>AskApache:</strong> thank you vish, you&#39;ve been most helpful. I am going to do a little more digging online about you guys and will probably be back with a couple questions.. cya around, have an awesome day</p>
</blockquote>
</div>
<h2>Hosts used by AskApache.com</h2>
<p><a href="http://www.wiredtree.com/298.html"rel="nofollow" >WiredTree</a> is the main hosting company that I mainly use for this site and my business.  It took me 10+ years of trial and error before I found them, you can believe I will be posting alot more about them on this site, stay tuned.  I also use <a href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=askapache"rel="nofollow" >HostGator</a>, and several other dependable nix hosts that are dirt cheap.</p>
<h2>Finding A Host</h2>
<p>I used to spend days and weeks googling for a host that wouldn&#8217;t end up burning me later, oh that really sucked.  Now I use a site developed by a colleague of mine, <a href="http://www.webhostingsearch.com/" rel="nofollow" >Web Hosting Search</a> as it lets me fairly quickly find a linux host with my bare requirements.  From THERE is when I start my own research.  This includes email and followups on the phone, visiting wiki&#8217;s, googling owners, sneaking around in customer areas, etc..</p>
<h2>Who do you Use?</h2>
<p>I&#8217;d love to hear about anyone&#8217;s experiences with specific hosts, recommendations especially!</p>
<p><a href="http://www.askapache.com/web-hosting/before-buying-web-hosting.html"></a><a href="http://www.askapache.com/web-hosting/before-buying-web-hosting.html">Questions I Ask Web Hosting Companies, Before Buying</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/web-hosting/before-buying-web-hosting.html/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>HOWTO: Uninstall CPANEL over SSH</title>
		<link>http://www.askapache.com/server-administration/uninstall-cpanel.html</link>
		<comments>http://www.askapache.com/server-administration/uninstall-cpanel.html#comments</comments>
		<pubDate>Sat, 24 Apr 2010 18:55:40 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[cpanel uninstall]]></category>
		<category><![CDATA[kill cpanel]]></category>
		<category><![CDATA[linux find]]></category>
		<category><![CDATA[uninstall cpanel]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4404</guid>
		<description><![CDATA[<p>The following is just a quick reference of some of the commands I used to uninstall cpanel.  This is for advanced users of the shell.  If you aren't that advanced and you run a single one of these commands without fully understanding it, you will probably kill your server, probably lose everything on it permanently, probably not have a website or email for weeks..  So backup all your data FIRST.  Also, if you aren't 100% sure you won't run into problems, you should contact your hosts technical support - but be prepared for some MAJOR negativity..  cpanel makes things very easy for hosts, and the last thing tech support wants is to fix a server broken by someone who doesn't know what they are doing.</p>]]></description>
			<content:encoded><![CDATA[<p><strong>WARNING!</strong> This is for advanced users of the shell, this is NOT a howto or tutorial.  The thing is, I googled <strong>how to uninstall cpanel</strong> and for once in my life I came up empty.. And certainly the cpanel official sites themselves don&#8217;t provide any instructions other than to say &#8220;Dont uninstall it, reinstall your entire operating system without it.&#8221;..   they sure don&#8217;t seem confident that they know exactly what their code is doing.  At this point this is more of a series of notes than a guide.  Ok now go have some fun!</p>
<h2>Why Uninstall?</h2>
<p>Why?  Because I have always built my servers, php installations, perl installs, ruby, iptables, everything from source.  I read the INSTALL/README docs, I read the man pages, and I read the info pages as well.  I google for configuration advice, I google for tips, and I don&#8217;t need a web-based perl script messing my stuff up!</p>
<p>The main problems I had with cpanel, which really is a great bit of software for millions of website developers, is that it was incredibly sneaky!  I used it for about 6 months and spent that entire time trying to figure out what the heck it was doing.  A couple issues that I really disliked, it takes over your bind install, it takes over your apache install, it takes over your php install.  And although it does let you configure some things (very few) for custom configurations and the like, I just don&#8217;t need any of that.  By removing the darn thing I am saving GIGS of space on my server, tons of bandwidth, and most importantly to me I am saving CPU and processing time along with RAM and IO speed.</p>
<h3>Anything Else</h3>
<p>Please.. I could go on for DAYS!  Another reason I have wanted to be rid of cpanel is that I like my servers to be as lean and mean as possible.  This means I like as few files and processes as possible.  There are many benefits to this, like it&#8217;s much easier for my integrity checking software and rootkit/antivirus software to run and drastically reduces the false positives.  And there is that glaring security issue of constantly having cpanel run it&#8217;s own software to create the WHM/Cpanel web interface, which is accessible online.  I haven&#8217;t researched cpanel security at all, it&#8217;s possible that it never has security problems that are published, but for me, why take the chance?</p>
<h2>Warning &#8211; Caution!</h2>
<p>The following is just a quick reference of some of the commands I used to uninstall cpanel.  This is for advanced users of the shell.  If you aren&#8217;t that advanced and you run a single one of these commands without fully understanding it, you will probably kill your server, probably lose everything on it permanently, probably not have a website or email for weeks..  So backup all your data FIRST.  Also, if you aren&#8217;t 100% sure you won&#8217;t run into problems, you should contact your hosts technical support &#8211; but be prepared for some MAJOR negativity..  cpanel makes things very easy for hosts, and the last thing tech support wants is to fix a server broken by someone who doesn&#8217;t know what they are doing.</p>
<h2>Last Warning!</h2>
<p>Unless you understand what theses commands do and the purpose they serve, do not try any of this.  These are not the exact commands I used verbatim, they are also not in order.  I only put them up here because I was so amazed that google didn&#8217;t have any uninstall cpanel intructions.  Hopefully it&#8217;s not a conspiracy that will get my site taken down.. ;)</p>
<p>That said and out of the way, it really only took me about 10 minutes to uninstall cpanel completely.  But keep in mind I have been closely monitoring and debugging cpanel for 6 months, so I knew what I was doing.  And finally, I do apologize for not having better instructions.. but hey, if you don&#8217;t get this then you have no business trying to figure out how to uninstall cpanel!  It&#8217;s great software and shouldn&#8217;t be removed unless you are fully capable of managing email/dns/www/ftp and any/all other servers and services on your machine by hand.</p>
<h2>Do This First</h2>
<p>I have a few drafts I&#8217;m working on at the moment with specifics, but for now you will have to figure it out with google.  Basically you want to make sure you don&#8217;t totally knock your machine offline without being able to reconnect.  What I do is compile a static version of openssh and a few other security-type shell tools, and configure this binary sshd to run by using inittab, which is the file run by init (pid 1) and makes sure if it dies it is restarted.  Here is my /etc/inittab to run the static sshd binary:</p>
<pre>hh:12345:respawn:/failover/os/sbin/aassh -D -q -u0 -f /failover/os/etc/aassh</pre>
<p>Another trick is to keep a detached screen logged in to root.  That way if you mess up your sudoers or securetty or pam or whatever, you can just reattach and fix it.</p>
<p>Finally, you may want to setup your syslog to start earlier than usual, and set up more than normal verbosity.  ( I take it to the max ).  Then you should setup a 2nd server or machine somewhere to act as a syslog server.  Lastly, configure your web server syslog to copy all messages to the remote syslog you set up.  I use a reverse ssh tunnel to encrypt the syslog packets, but when I do something serious like reboot after uninstalling cpanel, I prepare for it by adding additional networking routes on my machine to make sure I will get some logs even if sshd cant start or even if my network addresses aren&#8217;t brought up correctly.</p>
<p>If that sounds easy to you, please continue.   If you are saying: Wha??? Continue in read-only mode.</p>
<p class="cnote">Also, you can&#8217;t just uninstall cpanel, I have replaced a lot of cpanel already, like building my own bind, apache, php, syslog and making sure they work and aren&#8217;t being tampered with by cpanel.  Basically cpanel runs everything on your server in most cases, so you should prepare by creating your own static software to replace cpanel, and make sure it works.</p>
<h2>Find files Accessing /var/cpanel</h2>
<p>More than likely these will need to be killed.</p>
<pre>lsof +w -Rg -nP +c15 -x f +D /var/cpanel
lsof +w -Rg -nP +c15 -x f +D /usr/local/cpanel</pre>
<h2>Killing cpanel</h2>
<p>Just an example, your machine may have a lot more than these, I have been slowly taking control of my machine back from cpanel for 6 months, so it was easier for me.</p>
<pre>for P in tailwatchd queueprocd cpanellogd exim; do pkill -9 $P; done</pre>
<h2>Commands and Shortcuts</h2>
<pre>alias NF=&#039;nice find $PWD -mount -depth ! -type d&#039;
alias NFF=&#039;nice find $PWD -mount -depth ! -type d | xargs -IF87 file F87&#039;
alias NA=&#039;nice find $PWD -mount -depth&#039;
alias NAF=&#039;nice find $PWD -mount -depth | xargs -IF87 file F87&#039;</pre>
<h2>Watch out for crontab</h2>
<p>An example of the sneakiness (from my POV, from most it&#8217;s called builtin robustness) that cpanel does is automagically adding crontab entries that make it behave similarly to a self-propagating virus.  If you don&#8217;t disable the cronjobs and kill the right processes within a short period of time, be prepared for a magic resurrection.</p>
<p>Here&#8217;s my awesome crontab information function, you will need to check every file, it lists the default crons on my box, and every users crontab, but it can&#8217;t account for other cron software like at and other crons.</p>
<pre>function askapache_crontab()
{
  local GG i;
  for i in `getent passwd|cut -d &quot;:&quot; -f1`;
  do
    GG=$(sudo crontab -u $i -l 2&gt;$N6 | tr -s &#039;\n\000&#039; | sed &#039;/^#/d&#039;);
    [[ ${#GG} -gt 3 ]] &amp;&amp; sleep 1 &amp;&amp; echo -e &quot;$i \n\n${GG}&quot;
  done;
   sleep 4;
   ls -aLls1ch &#45;-color=always /etc/cron.{hourly,daily,weekly,monthly,d} | sed &#039;/^total/d; /\ drwxr-xr-x/d&#039;;
}</pre>
<pre>grep -ir /var/spool cpan</pre>
<pre>#6 3 * * * /scripts/upcp
#0 1 * * * /scripts/cpbackup
#0 2 * * * /scripts/mailman_chown_archives
#35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check &amp;&amp; /usr/local/cpanel/bin/tail-check
#11,26,41,56 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue &gt; /dev/null 2&gt;&amp;1
#30 */4 * * * /usr/bin/test -x /scripts/update_db_cache &amp;&amp; /scripts/update_db_cache
#45 */8 * * * /usr/bin/test -x /usr/local/cpanel/bin/optimizefs &amp;&amp; /usr/local/cpanel/bin/optimizefs
#*/5 * * * * /usr/local/cpanel/bin/dcpumon &gt;/dev/null 2&gt;&amp;1
#25 1 * * * /usr/local/cpanel/whostmgr/docroot/cgi/cpaddons_report.pl &#45;-notify</pre>
<h2>Delete Crontabs</h2>
<pre>sudo crontab -u mailman -r</pre>
<h2>Find INIT scripts with cpanel</h2>
<p>This is the main startup script: <code>/usr/local/cpanel/etc/init/startup</code></p>
<p>I had no idea ruby-on-rails was being controlled by cpanel.. sneaky bugger.  You can tell by all of these advanced unix commands just how difficult it would be to uninstall cpanel, its totally like the Alien!</p>
<pre>(1:3744)# find . ! -type d -print0|xargs -0 -I&#039;F87&#039; grep -Hi &quot;cpan\|tailwat\|chkser&quot; F87
./fastmail:# Author:       cPanel, Inc. &lt;nick@cpanel.net&gt;
./httpd:        HTTPD=/usr/local/cpanel/bin/chroothttpd
./cpanel:# cpanel8       Start Cpanel Services
./cpanel:# Author:       cPanel, Inc. &lt;nick@cpanel.net&gt;
./cpanel:# description: This is the cpanel webserver and chat.
./cpanel:# processname: cpaneld
./cpanel:# pidfile: /var/run/cpanel.pid
./cpanel:[ -f /usr/local/cpanel/etc/init/startup ] || exit 0
./cpanel:       if [ -f &quot;/var/cpanel/smtpgidonlytweak&quot; ]; then
./cpanel:       echo -n &quot;Starting cPanel services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startcpsrvd
./cpanel:       echo -n &quot;Starting cPanel brute force detector services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startcphulkd
./cpanel:    echo -n &quot;Starting cPanel dav services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startcpdavd
./cpanel:               daemon /usr/local/cpanel/etc/init/startcppop
./cpanel:       echo -n &quot;Starting cPanel Chat services: &quot;
./cpanel:               daemon /usr/local/cpanel/entropychat/entropychat
./cpanel:               daemon /usr/local/cpanel/bin/startmelange
./cpanel:                       /usr/local/cpanel/bin/startinterchange
./cpanel:       echo -n &quot;Starting cPanel ssl services: &quot;
./cpanel:       daemon /usr/local/cpanel/startstunnel
./cpanel:    echo -n &quot;Starting cPanel Queue services: &quot;
./cpanel:       daemon /usr/local/cpanel/etc/init/startqueueprocd
./cpanel:    echo -n &quot;Starting tailwatchd: &quot;
./cpanel:    daemon /usr/local/cpanel/libexec/tailwatchd &#45;-start
./cpanel:       echo -n &quot;Starting cPanel Log services: &quot;
./cpanel:       daemon /usr/local/cpanel/cpanellogd
./cpanel:    action &quot;Starting mailman services: &quot; /usr/local/cpanel/etc/init/startmailman
./cpanel:    action &quot;Stopping tailwatchd: &quot; /usr/local/cpanel/libexec/tailwatchd &#45;-stop
./cpanel:    action &quot;Stopping cPanel services: &quot; /usr/local/cpanel/etc/init/stopcpsrvd
./cpanel:       action &quot;Stopping cPanel dav services: &quot; /usr/local/cpanel/etc/init/stopcpdavd
./cpanel:       action &quot;Stopping cPanel queue services: &quot; /usr/local/cpanel/etc/init/stopqueueprocd
./cpanel:       action &quot;Stopping cPanel brute force detector services: &quot; /usr/local/cpanel/etc/init/stopcphulkd
./cpanel:               action &quot;Stopping pop3 services: &quot; /usr/local/cpanel/etc/init/stopcppop
./cpanel:       echo -n &quot;Stopping cPanel log services: &quot;
./cpanel:       killproc cpanellogd
./cpanel:       echo -n &quot;Stopping cPanel Chat services: &quot;
./cpanel:       action &quot;Stopping cPanel ssl services: &quot; /usr/local/cpanel/etc/init/stopstunnel
./cpanel:       action &quot;Stopping mailman services: &quot; /usr/local/cpanel/etc/init/stopmailman
./cpanel:       if [ -e &quot;/usr/local/cpanel/3rdparty/mailman/bin/mailmanctl&quot; ]; then
./exim:if [ -e &quot;/etc/chkserv.d&quot; ]; then
./exim:        for file in `ls /etc/chkserv.d`
./exim:            if [ ! -e &quot;/usr/local/cpanel/libexec/tailwatchd&quot; ]; then
./exim:    if [ -x &quot;/usr/local/cpanel/etc/init/startspamd&quot; ]; then
./exim:        /usr/local/cpanel/etc/init/startspamd
./exim:        if [ ! -e &quot;/usr/local/cpanel/libexec/tailwatchd&quot; ]; then
./ror:  /usr/local/cpanel/bin/rormgr &#45;-startboot
./ror:  /usr/local/cpanel/bin/rormgr &#45;-stopall
./ror:  /usr/local/cpanel/bin/rormgr &#45;-stopall
./ror:  /usr/local/cpanel/bin/rormgr &#45;-startboot
./ror:  /usr/local/cpanel/bin/rormgr &#45;-statusall
./securetmp:# Author:       cPanel, Inc. &lt;copyright@cpanel.net&gt;</pre>
<h3>Turn off cpanel services</h3>
<p>You should remove the below delete command and start by just disabling the inits by turning them off.  Then reboot. Then delete.  If your machine won&#8217;t reboot, I told you so, Cpanel told you so, and likely your host told you so.</p>
<pre>for S in cpanel ror securetmp fastmail exim; do R=$(command chkconfig &#45;-level 123456 $S off ||echo); R=$(command chkconfig &#45;-del $S ||echo); done</pre>
<h4>HTTPD</h4>
<p>If you are running chrooted httpd then you&#8217;ll need to make sure you don&#8217;t delete your entire webserver on accident.  Here&#8217;s a relevant part from the /etc/init.d/httpd script.</p>
<pre># the path to your httpd binary, including options if necessary
if [ -e &quot;/etc/chroothttpd&quot; ]; then
        HTTPD=/usr/local/cpanel/bin/chroothttpd
else
        HTTPD=/usr/local/apache/bin/httpd
fi</pre>
<h2>Finding files owned by cpanel</h2>
<p>Some super cool bash commands in this post.. let&#8217;s start with one to find all the files and folders on your machine owned by cpanel.  Check your /etc/passwd file for your machines specific usernames and groups.  This command saves all the filenames to ~/cpanel-files-backup.txt, which is used by tar next to create a backup of all of them.</p>
<pre>{ find / -mount -depth -maxdepth 150 \( -group cpanel -o   -group cpanel-phpmyadmin -o -group cpanel-phppgadmin   -o -group cpanelphpmyadmin   -o -group cpanelphppgadmin   -o -group cpanelhorde   -o -group cpanelroundcube \) -print; find / -mount -depth -maxdepth 150 \( -user cpanel -o   -user cpanel-phpmyadmin -o -user cpanel-phppgadmin   -o -user cpanelphpmyadmin   -o -user cpanelphppgadmin   -o -user cpanelhorde   -o -user cpanelroundcube \) -print; } &gt; ~/cpanel-files-backup.txt</pre>
<p>Here&#8217;s another way to search directories.</p>
<pre> grep &#45;-color=always -Hir cpanel /var</pre>
<h2>Create the Backup</h2>
<p>Note that you must have the latest version of tar for this exact command, also you should backup /var/cpanel and /usr/local/cpanel and /etc and heck the whole machine why dontcha!</p>
<pre>tar -T ~/cpanel-files-backup.txt -cvz &#45;-checkpoint=1000 &#45;-checkpoint-action=&quot;ttyout=\rHit %s checkpoint #%u&quot; -f /cpanel-files-backup.tgz &#45;-totals</pre>
<h2>Remove Files</h2>
<p>Once you do this your upstream without a paddle, you better make sure you know what you&#8217;re doing with this.  This removes all those files.</p>
<pre>cat ~/cpanel-files-backup.txt | xargs -I&#039;F87&#039; rm -vfr F87</pre>
<p>Additionally you will want to remove /usr/local/cpanel and /var/cpanel &#8211; What I always do when running as root is alias my rm command to instead simply move the files to a .trash folder.  That way if something goes bork you have a better chance at fixing it.</p>
<h2>Find Group-Owned Files</h2>
<pre>find / -mount -depth -maxdepth 150 \
\(  -group cpanel -o \
  -group cpanel-phpmyadmin \
  -o -group cpanel-phppgadmin \
  -o -group cpanelphpmyadmin \
  -o -group cpanelphppgadmin \
  -o -group mailman \
  -o -group cpanelhorde \
  -o -group cpanelroundcube \
\) -fprintf /root/cpanel-group-files.log &#039;%#8k %#5m %11M %#10u:%-10g %-5U:%-5G %p %f %Y %F\n&#039;</pre>
<h2>Find User-Owned Files</h2>
<pre>find / -mount -depth -maxdepth 150 \(
  -user cpanel \
  -o -user cpanel-phpmyadmin \
  -o -user cpanel-phppgadmin \
  -o -user cpanelphpmyadmin \
  -o -user cpanelphppgadmin \
  -o -user mailman \
  -o -user cpanelhorde \
  -o -user cpanelroundcube
\) -fprintf /root/cpanel-users-files.log &#039;%#8k %#5m %11M %#10u:%-10g %-5U:%-5G %p %f %Y %F\n&#039;</pre>
<pre>       4  0755  drwxr-xr-x     cpanel:cpanel     32002:32004 /var/cpanel/userhomes/cpanel cpanel d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/tmp tmp d reiserfs
       4  0644  -rw-r&#45;-r&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel/caches caches d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/.cpanel .cpanel d reiserfs
       4  0750  drwxr-x&#45;&#45;- cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin/mail mail d reiserfs
       4  0711  drwx&#45;-x&#45;-x cpanel-phpmyadmin:cpanel-phpmyadmin 32005:32007 /var/cpanel/userhomes/cpanel-phpmyadmin cpanel-phpmyadmin d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/sessions sessions d reiserfs
       4  0644  -rw-r&#45;-r&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel/caches caches d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/.cpanel .cpanel d reiserfs
       4  0750  drwxr-x&#45;&#45;- cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin/mail mail d reiserfs
       4  0711  drwx&#45;-x&#45;-x cpanelphppgadmin:cpanelphppgadmin 32009:32011 /var/cpanel/userhomes/cpanelphppgadmin cpanelphppgadmin d reiserfs
       4  0750  drwxr-x&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube/mail mail d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube/sessions sessions d reiserfs
       4  0711  drwx&#45;-x&#45;-x cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/userhomes/cpanelroundcube cpanelroundcube d reiserfs
       4  0644  -rw-r&#45;-r&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches/featurelists/default.cache default.cache f reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches/featurelists featurelists d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel/caches caches d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;-     cpanel:cpanel     32002:32004 /var/cpanel/.cpanel .cpanel d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/roundcube/tmp tmp d reiserfs
       4  0700  drwx&#45;&#45;-&#45;&#45;- cpanelroundcube:cpanelroundcube 514  :514   /var/cpanel/roundcube/log log d reiserfs</pre>
<h3>Find Permissions</h3>
<pre>cat ~/cpanel-group-files.log ~/cpanel-users-files.log |tr -s &#039;\000 \t&#039;|cut -d&#039; &#039; -f3|sort -u</pre>
<h3>Find files tailwatchd</h3>
<pre>(1:3732)# $NICE find ${1:-`pwd`} -mount -name &#039;*tailwatch*&#039;
/usr/local/cpanel/libexec/tailwatchd
/usr/local/cpanel/libexec/tailwatch
/usr/local/cpanel/libexec/tailwatch/tailwatchd
/usr/local/cpanel/etc/init/scripts/freebsd/tailwatchd.sh
/usr/local/cpanel/etc/init/scripts/trustix/tailwatchd
/usr/local/cpanel/etc/init/scripts/centos/tailwatchd
/usr/local/cpanel/etc/init/scripts/suse/tailwatchd
/usr/local/cpanel/etc/init/scripts/caos/tailwatchd
/usr/local/cpanel/etc/init/scripts/whitebox/tailwatchd
/usr/local/cpanel/etc/init/scripts/mandrake/tailwatchd
/usr/local/cpanel/etc/init/scripts/debian/tailwatchd
/usr/local/cpanel/etc/init/scripts/redhat/tailwatchd
/usr/local/cpanel/etc/init/scripts/fedora/tailwatchd
/usr/local/cpanel/etc/init/stoptailwatchd
/usr/local/cpanel/etc/init/starttailwatchd
/usr/local/cpanel/bin/tailwatchd
/usr/local/cpanel/logs/tailwatchd_log
/var/log/cpanel/tailwatchd_log
/var/cpanel/log_rotation/cp_tailwatchd_log.cpanellogd
/var/cpanel/tailwatch.positions
/var/run/tailwatchd.pid
/etc/chkserv.d/tailwatchd
/scripts/restartsrv_tailwatchd</pre>
<h2>Delete cpanel Users/Groups</h2>
<pre>for U in cpanel-phpmyadmin cpanel-phppgadmin cpanelphpmyadmin cpanelphppgadmin cpanelhorde cpanelroundcube machbuild; do userdel -fr $U; groupdel $U; done</pre>
<h2>Check for broken symlinks</h2>
<pre>find / -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039;</pre>
<p>Especially check /etc</p>
<pre>$ find /etc -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039;
/etc/ftpd-rsa.pem                   broken symbolic link to `/var/cpanel/ssl/ftp/ftpd-rsa.pem&#039;
/etc/rc.d/rc1.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc1.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc1.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc3.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc3.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc3.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc6.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc6.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc6.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc5.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc5.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc5.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc2.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc2.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc2.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc4.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/rc.d/rc4.d/S80chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc4.d/S80antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc0.d/K10chkservd         broken symbolic link to `../init.d/chkservd&#039;
/etc/rc.d/rc0.d/K30antirelayd       broken symbolic link to `../init.d/antirelayd&#039;
/etc/rc.d/rc0.d/K80dcc              broken symbolic link to `../init.d/dcc&#039;
/etc/authlib/authProg               broken symbolic link to `/usr/local/cpanel/bin/courier-auth&#039;</pre>
<p>And delete if you are sure</p>
<pre>find /etc -mount -depth -type l -print0 |xargs -0 -P0 -I&#039;F87&#039; file -s &#039;F87&#039; | sed -n &#039;/: broken symbolic link to/p&#039; |cut -d&#039; &#039; -f1|xargs -I&#039;F87&#039; rm -rvf &#039;F87&#039;</pre>
<h2>Reinstall CSF</h2>
<p>The only thing I actually used that came with cpanel is the CSF/LFD Firewall package, which is a fantastic piece of software.  I had to reinstall this, and to get it working without cpanel add the following line to the csf.conf</p>
<pre>GENERIC = &quot;1&quot;</pre>
<h2>Thats It</h2>
<p>Now once you&#8217;ve cleaned up everything, you should try everything conceivable to get an error before rebooting.  Like you should start and stop every service in /etc/init.d/, you should use telinit to check various runlevels (which keeps your sshd connection still live).  Go all out, should take at least a full hour.</p>
<p>Another thing I like to do is rebuild alot of my source-built software again in case anything got messed up.  I upgrade perl from cpanels 5.8.8 to 5.10, which is pretty thorough, and you know, reinstall anything else I think I might need.  One of the benefits of compiling your own software is all I have to do is cd to the source directory and type <code>make -B &#038;&#038; ( { make test || make check || make checks || make tests; } || echo  ) &#038;&#038; sudo make install</code> and that&#8217;s it.  The tests/checks are optional of course.</p>
<p>If anyone actually ever reads this and does it, please share your advice here.. everybody knows we need it!  Good Luck</p>
<p><a href="http://www.askapache.com/server-administration/uninstall-cpanel.html"></a><a href="http://www.askapache.com/server-administration/uninstall-cpanel.html">HOWTO: Uninstall CPANEL over SSH</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/server-administration/uninstall-cpanel.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30x Faster WP-Super Cache Site Speed</title>
		<link>http://www.askapache.com/web-hosting/super-speed-secrets.html</link>
		<comments>http://www.askapache.com/web-hosting/super-speed-secrets.html#comments</comments>
		<pubDate>Thu, 18 Mar 2010 15:43:21 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[Boot]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[devshm]]></category>
		<category><![CDATA[File System]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[ionice]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[memory bandwidth]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Private Server]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[SLRAM]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[speed improvements]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[SymLinks]]></category>
		<category><![CDATA[tmpfs]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[webhosts]]></category>
		<category><![CDATA[WP-Super Cache]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=3220</guid>
		<description><![CDATA[<p><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html" id="id0"></a></p>
<p>NOT a typo..  30x is measurable, well-documented, and easily tested.  This is what <strong>open-source</strong> is about.   I haven’t had time to post much the past year, I'm always working!  So I wanted to make up for that by publishing an article on a topic that would blow your mind and be something that you could actually start using and really get some benefit out of it. This is one of those articles that the majority of web hosting companies would love to see in paperback, <strong>so they could burn it.</strong></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html"><img src="http://uploads.askapache.com/2009/09/top.jpg" alt="Top showing swap and memory" title="Top showing swap and memory" width="434" height="52" class="size-full wp-image-3270" /></a></p>
<p>I haven&#8217;t had time to post much the past year, so I wanted to make up for that by publishing an article on a topic that would blow your mind and be something that you could actually start using and really get some benefit out of it.  This is one of those articles that the majority of web hosting companies would love to see in paperback, <strong>so they could burn it</strong>.  Now ask yourself, if a webhost makes money based on how much memory, bandwidth, and data used by a customer, what would they not want their customers to do?  That&#8217;s right, they do not want their customers to learn how to minimize and drastically reduce these moneymakers.  They get giddy when you complain about slow-site-speed, or that it takes a long time for your site to load, because they have exactly the right answer- upgrade your memory, bandwidth, and data by purchasing a more expensive plan.</p>
<p class="anote"><strong>WARNING</strong>!!  This article has some seriously advanced stuff in it, pretty far beyond my skill level as well (getting there).  I personally shutdown some of my own servers with various webhosts because of this.. Note I said personally, not intentionally.  Even after spending almost a year (this has been in my drafts folder a long time) using TMPFS on as many machines as I can, I still make mistakes (gotta pay attention!) and lose a tmpfs folder..   Oh and if you go experimenting with this stuff on your web host, you will almost definately, most certainly be on the road to getting your account terminated if you are with one of the cheap hosts.  They hate this stuff because it cuts right into the heart of their profit curves and can seriously disrupt a poorly configured machine.  DO NOT TRY THIS!!  (except and of course on your own development machines).   Of course the whole point of this article is how you can take advantage of this incredible filesystem to get crazy speed improvements..  Those are the follow up articles ;)</p>
<p>For those of you who thought modifying your server httpd.conf and htaccess files is very dangerous, you are right.  But this is not like that, this is dangerous in the sense that if you try to rush through with your super amazing &#8220;copy and paste skills&#8221; (script kids) you will easily lose entire folders.  That&#8217;s because TMPFS is stored in RAM/Memory, and upon reboot RAM is cleared.  I personally loathe disclaimers, and if you look around you will see there aren&#8217;t many even with all my sloppy poorly documented articles&#8230;  So be careful if you feel up to going further.</p>
<h2>Introducing tmpfs</h2>
<p>If I had to <strong>explain tmpfs</strong> in one breath, I&#8217;d say that tmpfs is like a ramdisk, but different. Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it&#8217;s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I&#8217;ve had the opportunity to meet.</p>
<h2>Beware of WebHosts</h2>
<p>What is a modern day web hosting company?  What costs do they actually have?  A webhost&#8217;s only unique ability is their connection to the Internet.  That is why you can see such tremendous link speed.  Other than that they consist of servers that are getting smaller and cheaper for them every month.  The servers they use are generally just like any computer, except much larger and built specifically for multi-tasking.</p>
<blockquote cite="http://content.dell.com/us/en/enterprise/virtualization-what-is-it.aspx">
<p>Virtualization allows you to run multiple applications and operating systems independently on a single server. Additionally, administrators can quickly move workloads from one virtual workspace to another — easily prioritizing business needs while maximizing server resources&#8230;.</p>
<p>Virtualization removes the limitations of the traditional IT approach, enabling <strong>a single PowerEdge server</strong> to operate <strong>multiple applications simultaneously in &#8220;virtual machines&#8221;</strong></p>
</blockquote>
<h2>Hosting Company Tricks</h2>
<p>Web hosts like to vaguely describe their products as if you are buying your own powerful machine, but in reality you get placed on the same machine as hundreds or thousands of other customers, and the server basically creates an operating system for each customer using virtualization technology.  Everyone on the machine literally is sharing the same RAM and resources, many times even sharing IP address&#8217;s, and the virtualization software lets them limit the amount of memory / cpu / disk / and bandwidth for each of these virtual machines.  That is why so often when a web host has an outage they make big public announcements and it appears that hundreds or thousands of their customers have been affected.. One of their server farm machines goes offline and it literally takes down all the customers virtualized machines with it.</p>
<h3>Why it gets Evil</h3>
<p>Don&#8217;t get me wrong, I absolutely love this technology, both the hardware virtualization and the software side, but what I truly do not appreciate is how these companies take advantage of their customers every day and know it.  Here&#8217;s what they do, they make justifications about why one plan costs more than another, and these justifications are always about the same thing:  CPU&#8217;s, how fast the data can crunch..  RAM/Memory: How fast and how much your server can handle in terms of traffic&#8230; Disk Usage:  How much storage you have&#8230; And finally bandwidth: How fast can people get data off your sites, and how many people can connect.</p>
<p>Now lets think for a second.  The webhost has a BIG computer/server/machine that has MASSIVE amounts of RAM, DISK, PROCESSING power, and NETWORK bandwidth.. but just like anything they all have limits.   So if this machine has 10GB of RAM, and the webhost offered plans that have 1GB of RAM, then on that machine they can only have 10 customers right?  WRONG.  If each customer pays $100/month, then of course they would love to have as many customers on that machine as possible.  This builtin incentive is just the reality and isn&#8217;t anyone fault.</p>
<h3>Where it gets Evil</h3>
<p>Here&#8217;s what goes on.. all the host advertises is the 1GB of guaranteed RAM with your machine, but for even if the web server was fairly busy it would never use all of that ram because all the software is careful not to use too much, or has no need for any RAM.  Runtime libraries and internal caches use ram, but it&#8217;s not directly accessed by the customer, only the software.   What happens is when those 10 customers aren&#8217;t using 100% of their ram, which never happens, then the virtualization technology can use that RAM elsewhere.  So technically you do have 1GB of RAM available, but if you aren&#8217;t using it then it is essentially FREE RAM that they can sell to another customer.  The only way this wouldn&#8217;t work of course is if all 11 customers somehow used 100% of RAM simultaneously, at that point the 11th customer would be ramless.  But that is impossible because the system is a load-balancing system that provides both an upper and a lower limit to how much RAM is allotted to each virtual machine.</p>
<p>It sounds unrealistic but I see server farms all the time that are stuffed full of virtual machines, like situations where there are 100 1GB customers all sharing 10GB of RAM..  no-one uses the whole 1GB allotted to them as the maximum amount they can use, and they don&#8217;t know because it appears they have a lot of free RAM, but really that is virtual RAM and could be used by anyone else on the machine.</p>
<h3>Where it gets Fun (for me)</h3>
<p><a href="http://www.askapache.com/linux-unix/bash-power-prompt.html"class="IFL" ><img src="http://uploads.askapache.com/2010/03/askapache-htop.jpg" alt="The HTOP command in full color to manage mysql" title="The HTOP command in full color to manage mysql" width="404" height="176" class="size-full wp-image-4149" /></a>This is actually even worse for anyone who is using what they call &#8220;shared-hosting&#8221; which is the budget hosting that is the most common.  With shared-hosting there is actually some skill involved on the hosting companies part, like real linux skills.  In this setup they may or more often may not use any virtualization software.  It&#8217;s just a vanilla multi-user server machine where each customer gets a restricted unix account that powers their website using the same system as thousands of others on the box.  This is usually dirt cheap because it costs so little to do, but alot of companies charge outrageous amounts for shared-hosting because they make it look really full-featured, which it can be, they just don&#8217;t mention 1000 other people use the same machine, hard-drive, /tmp directory, network device, IP address, etc..  Alot of the times the cheaper end of the spectrum is where the most gifted system administrators are located, they are so good with linux administration that they could fit 10 customers and 100 websites on an XBOX converted to run linux, and you&#8217;d think you got a great deal until you found out! lol.  Anyone alive is able to buy more hardware to expand their capacity to take on more customers,  but it takes a lot of knowhow and real skill to have that many users on 1 machine.  I&#8217;ve seen pretty extreme cases that are analogous to the XBOX example (which is possible by the way).<br class="C" /></p>
<p>I personally love shared-hosting environments, because for those of us who know almost as much or more than the system administrators running the machine we are able to use a disproportionate (legally) amount of the CPU and RAM available on the system.  So for example my sites would  all show up fast and be able to handle more traffic than several other customers combined.  Not because<br />
anything has been circumvented, but because I am able to access and utilize as much of the guaranteed 1GB of RAM that I am paying for every month, which is usually just a few bucks.  The downside is that when you have corporate sites or really high-traffic sites then you are forced to move to a more powerful machine..  </p>
<p>This leads to a familiar situation for some of you..  When your site starts becoming popular and you are getting a lot of traffic, this means that your site could be using 10x the amount of RAM and Bandwidth of any other customer in that server farm.  And what that really means to the webhost is that you are costing them 10x what anyone else is..  And if they removed you, they would have the space for 10 new customers to take your place, and they would make 10x more money.  DreamHost is notorious for terminating accounts because of that..  It happened to me except I was given the option to pay 5x more a month for their &#8220;upgrade&#8221; to a VPS.  Giant shared-hosts advertise like crazy how they offer unlimited bandwidth, but <strong>when you start using 100x more bandwidth than anyone on your server you are costing them 100x what you are paying them, every month</strong>.  That&#8217;s why you will never see a webhost offering this kind of unlimited bandwidth that doesn&#8217;t require you to sign a contract giving them permission to terminate your account <em>for any reason</em>.  Seriously read the fine print at DreamHost or anywhere else, it&#8217;s included because that is a core part of their business to terminate anyone using too much bandwidth since that is bandwidth they can&#8217;t sell to dozens of other customers.  That&#8217;s why I eventually closed my account with them and moved to a legitimate company, it&#8217;s a great host for spammers though.</p>
<p>Back in the mid-90&#8242;s I was doing a lot of war-dialing with my modem and discovering all sorts of networks and machines, many of them were Unix and Solaris based public systems, and when I managed to gain access to the system and found myself staring at a unix shell I was very excited but also a total idiot.  In those days of using the phone networks to research unknown systems it was very difficult for anyone to actually get the phone company to trace a call, so instead of what happens today where it is child&#8217;s play to trace an IP address, back then it was a very real back-and-forth battle between the system admin and whoever was gaining access to their system.  Essentially, I would gain a shell or some kind of terminal, and just go at it trying to figure out what it could do, trying all kinds of commands.  Inevitably this would eventually alert even the laziest admin and they would proceed to attempt to lock me out. It was great sport and extremely addictive.  When my favorite system (a massive sun machine in the basement of a big library) finally locked me out and I couldn&#8217;t get back in I went to my local library and got some reading material &#8212; one of my favorites was the red hat bible.  I was able to acquire my own computer and the first thing I did was install red hat linux onto it from the discs included with the book.  For the next several years I was essentially offline, all we had at home was a modem and it was becoming difficult to locate any more systems in my area code.. I was into phreaking of course as well, but I never was able to make free long-distance war-dialing a reality.  So I just read the books and learned what I could.  I would also goto the library when I could in order to use their machines which were connected to the internet (before aol it was much different than today&#8217;s internet) and since my time was short I would download as many documents as I could so that I could read them offline.  The TLDP documentation that we know today was around back then in various forms, and I read every HOWTO in the index, though not understanding half.  The other big resource I found for really intense reading was the <a href="http://www.kernel.org/doc/Documentation/" rel="nofollow" >kernel documentation</a>, which admitedly I still don&#8217;t comprehend 1/4th of..   I try and peruse all the new documents when a new kernel is released, since the kernel is where all the real action is, hence the military authoritative name, and that is how I discovered one of the coolest features of Linux that I have found.  TMPFS!</p>
<h2>TMPFS kills the RAMDISK</h2>
<p>Ok so we all know what RAM is, it&#8217;s the memory cards that most people never see that is used by the computer to store and access data that all programs need.  RAM is very expensive compared to most PC components, because it&#8217;s what makes a computer blazing fast or slow.  So real quick lets look at a few (there are not many) ways that various linux hackers use RAM in non-conventional ways in the past.</p>
<p>Tmpfs is a file system which keeps all files in virtual memory.  Everything is temporary in the sense that no files will be created on your hard drive. If you reboot, everything in tmpfs will be lost.</p>
<p>In contrast to RAM disks, which get allocated a fixed amount of physical RAM, tmpfs grows and shrinks to accommodate the files it contains and is able to swap unneeded pages out to swap space.</p>
<p>Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it&#8217;s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I&#8217;ve had the opportunity to meet.</p>
<p>If I had to <strong>explain tmpfs</strong> in one breath, I&#8217;d say that tmpfs is like a ramdisk, but different. Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it&#8217;s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I&#8217;ve had the opportunity to meet.</p>
<p><br class="C" /></p>
<p>What kind of filesystem is used on your server to store all your site files?  EXT4, REISERFS, EXT3, NFS, etc.. are the usual filesystems, Windows users are limited to the NTFS filesystem.   A filesystem is different than a device, a device is a hard-drive disk.  A filesystem is how the device is formatted to allow for file and folder structures.  A hard drive is slow compared to RAM, no question about that.  So what if instead of your server serving files off a hard-drive it served files stored in RAM?  <strong>30x faster thats what happens!</strong></p>
<p class="wnote">I just figured out how to store my cached static files created by WP-Super Cache in my server&#8217;s RAM, and the difference is unbelievable.  My &#8220;AskApache Crazy Cache&#8221; plugin basically forces WP-Super Cache, Hyper Cache, etc.. to recreate a static cached file for every page on a blog.  For the AskApache.com site this takes around 3 minutes to complete.  Once I switched to using this new method of storing the files on RAM I am able to re-cache the entire site in about 15 seconds!!!!</p>
<p class="wnote">tmpfs is a dynamically expandable/shrinkable ramdisk, and will<br />
# use almost no memory if not populated with files</p>
<blockquote cite="">
<p>Tmpfs is a file system which keeps all files in virtual memory.</p>
<p>Everything in tmpfs is temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost.</p>
<p>tmpfs puts everything into the kernel internal caches and grows and shrinks to accommodate the files it contains and is able to swap unneeded pages out to swap space. It has maximum size limits which can be adjusted on the fly via &#8216;mount -o remount &#8230;&#8217;</p>
<p>If you compare it to ramfs (which was the template to create tmpfs) you gain swapping and limit checking. Another similar thing is the RAM disk (/dev/ram*), which simulates a fixed size hard disk in physical RAM, where you have to create an ordinary filesystem on top. Ramdisks cannot swap and you do not have the possibility to resize them.</p>
<p>Since tmpfs lives completely in the page cache and on swap, all tmpfs pages currently in memory will show up as cached. It will not show up as shared or something like that. Further on you can check the actual RAM+swap use of a tmpfs instance with df(1) and du(1).</p>
</blockquote>
<p>Both tmpfs and ramfs mount will give you the power of fast reading and writing files from and to the primary memory. When you test this on a small file, you may not see a huge difference. You’ll notice the difference only when you write large amount of data to a file with some other processing overhead such as network.</p>
<h2>TMPFS uses RAM+SWAP</h2>
<p>TMPFS is another filesystem with uniquely cool capabilities.  It stores any files contained within it on RAM and in SWAP which means your server can access any files stored on TMPFS without even having to access the disk, which according to technical stats is around 30 times faster than accessing a file off disk.</p>
<p>Some other cool aspects of TMPFS are that it intelligently and automatically sizes itself to be just alittle bigger then it needs to be.  So when you remove files to a folder stored on a TMPFS filesystem, the TMPFS filesystem shrinks by allocating less RAM and/or SWAP.  Conversely when adding files to TMPFS it grows larger.  You can set the max-size and max-number-of-files as a mount option to make sure your TMPFS never uses all of the available RAM and SWAP, which would halt your server.</p>
<h3>Swap</h3>
<p>Find the swap size.</p>
<pre># free -m -t
             total       used       free     shared    buffers     cached
Mem:           458         93        364          0          0          0
-/+ buffers/cache:         93        364
Swap:          900          0        900
Total:        1358         93       1264</pre>
<pre>Adding 3004144k swap on /dev/sdb2.  Priority:-1 extents:1 across:3004144k
Adding 2096472k swap on /dev/sda3.  Priority:-2 extents:1 across:2096472k</pre>
<h2>Using TMPFS for Cache</h2>
<p>The method here will show how to create and use a TMPFS filesystem to hold all the static files created by WP-Super Cache.  These static files are served to visitors instead of loading php for every request, so by moving those static files to TMPFS your server will be able to access and start sending your site to the browser 30x faster!</p>
<p>The WP-Super Cache plugin stores all the static files in the wp-content/cache folder of your WordPress installation, so to enable TMPFS we simply will create a new TMPFS filesystem and mount it to the wp-content/cache folder.  That makes anything in that folder (all the static files) be part of the TMPFS filesystem.</p>
<h2>Boosting Cache with TMPFS</h2>
<p>There are a lot of maybe new concepts surrounding TMPFS and it may seem too complicated, but the process of actually setting up a robust tmpfs to use for wp-super-cache&#8217;s cache folder is actually very simple.  As long as you have shell access to your server and the permissions required (any sudo or private server should be good to go) you can set this up in a couple minutes and not really have to give it a second thought or debug anything.  Here&#8217;s the process I&#8217;ve used on several client sites.</p>
<ol>
<li>Create a TMPFS Filesystem and Mount at /wp-content/cache/</li>
<li>Restore TMPFS Cached Files across Reboots</li>
<li>Keep a semi-current mirror of the TMPFS files on Disk</li>
</ol>
<p><br class="C" /></p>
<h3>Create TMPFS at wp-content/cache</h3>
<p>/etc/fstab</p>
<pre>tmpfs /home/askapache/wp-content/cache tmpfs defaults,size=2g,noexec,nosuid,uid=648,gid=648,mode=1755 0 0</pre>
<h3>Restoring TMPFS across Reboots</h3>
<p>In /etc/rc.local</p>
<pre>ionice -c3 -n7 nice -n 19 rsync -ahv &#45;-stats &#45;-delete /_b/tmpfs/cache/ /home/askapache/wp-content/cache/ 1&gt;/dev/null</pre>
<h3>Mirroring TMPFS to Disk</h3>
<p>Cronjob entry</p>
<pre>*/5 * * * * /usr/bin/ionice -c3 -n7 /bin/nice -n 19 /usr/bin/rsync -ah &#45;-stats &#45;-delete /home/askapache/wp-content/cache/ /_b/tmpfs/cache/ 1&gt;/dev/null</pre>
<p><span id="more-3220"></span></p>
<h2>/tmp, /var/run, and /var/lock</h2>
<p>The directories /tmp, /var/run, and /var/lock contain files that are not needed across reboots.  This means they are ideal candidates for tmpfs.  HEre&#8217;s how to do it.</p>
<pre>tmpfs /var/run tmpfs defaults,rw,nosuid,mode=0755 0 0</pre>
<pre>tmpfs /var/lock tmpfs defaults,rw,noexec,nosuid,nodev,mode=1777 0 0</pre>
<h2>Resize /dev/shm</h2>
<p>You can view your current /dev/shm size with the command <code>df -ha|grep /dev/shm</code> then if you want to resize that use the command:</p>
<pre>mount -t tmpfs -o remount,size-2G,rw,nosuid,nodev tmpfs /dev/shm</pre>
<pre>Secure /dev/shm:
&nbsp;
Step 1: Edit your /etc/fstab:
&nbsp;
nano -w /etc/fstab
&nbsp;
Locate:
&nbsp;
none /dev/shm tmpfs defaults,rw 0 0
&nbsp;
Change it to:
&nbsp;
none /dev/shm tmpfs defaults,nosuid,noexec,rw 0 0
&nbsp;
Step 2: Remount /dev/shm:
&nbsp;
mount -o remount /dev/shm
&nbsp;
guilt makes extensive use of the &#039;$$&#039; shell variable for temporary
files in /tmp. This is a serious security vulnerability; on multi-user
systems it allows an attacker to clobber files with something like the
following:
&nbsp;
for i in `seq 1 32768`; do
ln -sf /etc/passwd /tmp/guilt.log.$i;
done
&nbsp;
(In this example, if root does e.g. &#039;guilt push&#039;, /etc/passwd will get
clobbered.)</pre>
<p><br class="C" /></p>
<h3>Securing and Using /tmp</h3>
<ul>
<li><a href="http://www.sysadmin.md/secure-temporary-folders-on-existing-unix-or-linux-systems.html" rel="nofollow" >Secure temporary folders on existing Unix or Linux systems</a></li>
<li><a href="https://wiki.torproject.org/noreply/TheOnionRouter/OperationalSecurity" rel="nofollow" >Encrypt Storage and Swap Space</a></li>
</ul>
<p><a id="tmpfs-mount"></a></p>
<h2>tmpfs mount parameters</h2>
<p>A good way to find a good tmpfs upper-bound is to use top to monitor your system&#8217;s swap usage during peak usage periods. Then, make sure that you specify a tmpfs upper-bound that&#8217;s slightly less than the sum of all free swap and free RAM during these peak usage times. </p>
<p><strong>mode=1777</strong> sets sticky bit on directory. Only file owners can delete files in this directory.</p>
<p>The following parameters accept a suffix k, m or g for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.</p>
<ul>
<li><strong>size</strong>:  Override default maximum size of the filesystem.  The size is given in bytes, and rounded down to entire pages.  The default is half of the memory.The limit of allocated bytes for this tmpfs instance. The default is half of your physical RAM without swap. If you oversize your tmpfs instances the machine will deadlock since the OOM handler will not be able to free that memory.</li>
<li><strong>nr_inodes</strong>:  Set number of inodes.</li>
<li><strong>nr_blocks</strong>:  Set number of blocks.</li>
<li><strong>mode</strong>: The permissions as an octal number</li>
<li><strong>uid</strong>: The user id</li>
<li><strong>gid</strong>: The group id</li>
</ul>
<pre>mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs</pre>
<p>Will give you tmpfs instance on /mytmpfs which can allocate 10GB RAM/SWAP in 10240 inodes and it is only accessible by root.</p>
<p><a id="tmp-tmpfs"></a></p>
<h2>Using tmpfs for /tmp storage</h2>
<p>Many users find it very convenient to use tmpfs for /tmp and /var/tmp which does a number of positive things.  Any temporary files are instead created in RAM not your hard-drive, which means that reading/writing/accessing those temporary files by various processes doesn&#8217;t slow down your hard-drive read/writes/accesses for your other processes.  This also has a side-effect of making your hard-drive have a longer life as it reduces activity by a huge amount.</p>
<p>Remember that tmpfs uses both RAM and swap, so make sure your machine has a large swapfile, like gigabytes.  If your tmpfs consumes all the swap and RAM then you are screwed, so make sure that you correctly set the mount options for the tmpfs so that it doesn&#8217;t do that.  If your /tmp or /var/tmp gets filled with tmp files that for some reason don&#8217;t get deleted except at reboot, and your machine has a very high uptime, then you will want to run some cron jobs to periodically clean the /tmp and /var/tmp directories of older files&#8230;</p>
<p>Here&#8217;s an example scenario: let&#8217;s say that we have an existing filesystem mounted at /tmp. However, we decide that we&#8217;d like to start using tmpfs for /tmp storage.</p>
<p>with recent 2.4 kernels, you can mount your new /tmp filesystem without getting the &#8220;device is busy&#8221; error: </p>
<pre>mount tmpfs /tmp -t tmpfs -o size=64m</pre>
<p>With a single command, your new tmpfs /tmp filesystem is mounted at /tmp, on top of the already-mounted partition, which can no longer be directly accessed. However, while you can&#8217;t get to the original /tmp, any processes that still have open files on this original filesystem can continue to access them. And, if you umount your tmpfs-based /tmp, your original mounted /tmp filesystem will reappear. In fact, you can mount any number of filesystems to the same mountpoint, and the mountpoint will act like a stack; unmount the current filesystem, and the last-most-recently mounted filesystem will reappear from underneath.</p>
<p><a id="bind-mounts"></a></p>
<h2>Bind Mounts</h2>
<p>Using bind mounts, we can mount all, or even part of an already-mounted filesystem to another location, and have the filesystem accessible from both mountpoints at the same time!</p>
<p>For example, you can use bind mounts to mount your existing /tmp filesystem to /sites/askapache.com/tmp, as follows:</p>
<pre>mount &#45;-bind /tmp /sites/askapache.com/tmp</pre>
<p>Now, if you look inside /sites/askapache.com/tmp, you&#8217;ll see your /tmp filesystem and all its files. And if you modify a file on your /tmp filesystem, you&#8217;ll see the modifications in /sites/askapache.com/tmp as well. This is because <strong>they are one and the same filesystem; the kernel is simply mapping the filesystem to two different mountpoints for us</strong>. </p>
<p>Note that when you mount a filesystem somewhere else, any filesystems that were mounted to mountpoints inside the bind-mounted filesystem will not be moved along. In other words, if you have /tmp/cache on a separate filesystem, the bind mount we performed above will leave /sites/askapache.com/tmp/cache empty. You&#8217;ll need an additional bind mount command to allow you to browse the contents of /tmp/cache at /sites/askapache.com/tmp/cache:</p>
<pre>mount &#45;-bind /tmp/cache /sites/askapache.com/tmp/cache</pre>
<h3>Bind mounting and /dev/shm</h3>
<p>glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for POSIX shared memory (shm_open, shm_unlink). Adding the following line to /etc/fstab should take care of this:</p>
<pre>tmpfs  /dev/shm  tmpfs  defaults  0 0</pre>
<p>Many systems by default have a tmpfs filesystem mounted at /dev/shm that defaults to a size of half of your physical RAM without swap.  Say you decide that you&#8217;d like to start using tmpfs for /tmp, which currently lives on your root filesystem. Rather than mounting a new tmpfs filesystem to /tmp (which is possible), you may decide that you&#8217;d like the new /tmp to share the currently mounted /dev/shm filesystem. However, while you could bind mount /dev/shm to /tmp and be done with it, your /dev/shm contains some directories that you don&#8217;t want to appear in /tmp. So, what do you do? How about this:</p>
<pre>mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount &#45;-bind /dev/shm/tmp /tmp</pre>
<p>In this example, we first create a /dev/shm/tmp directory and then give it 1777 perms, the proper permissions for /tmp. Now that our directory is ready, we can mount /dev/shm/tmp, and only /dev/shm/tmp to /tmp. So, while /tmp/foo would map to /dev/shm/tmp/foo, there&#8217;s no way for you to access the /dev/shm/bar file from /tmp.</p>
<p><br class="C" /></p>
<p><a id="default-tmpfs-workaround"></a></p>
<h2>/etc/default/tmpfs WorkAround</h2>
<pre>$ cat /etc/default/tmpfs
# SHM_SIZE sets the maximum size (in bytes) that the /dev/shm tmpfs can use.
# If this is not set then the size defaults to the value of TMPFS_SIZE
# if that is set; otherwise to the kernel&#039;s default.
#
# The size will be rounded down to a multiple of the page size, 4096 bytes.
SHM_SIZE=524288000
# TMPFS_SIZE sets the max size that /dev/shm can use.  By default, the
# kernel sets this upper limit to half of available memory.
TMPFS_SIZE=524288000</pre>
<p><a id="rsync-vs-cp"></a></p>
<h2>RSYNC vs. CP</h2>
<pre>rsync [options]  SRC DEST
rsync -av &#45;-delete &#45;-stats /home/wincom/public_html/wp-content/cache/ /backups/tmp-mnt/cache/
-a, &#45;-archive               archive mode; same as -rlptgoD (no -H)
-r, &#45;-recursive             recurse into directories
-l, &#45;-links                 copy symlinks as symlinks
-p, &#45;-perms                 preserve permissions
-t, &#45;-times                 preserve times
-g, &#45;-group                 preserve group
-o, &#45;-owner                 preserve owner (super-user only)
-D                          same as &#45;-devices &#45;-specials
    &#45;-devices               preserve device files (super-user only)
    &#45;-specials              preserve special files
 -h, &#45;-human-readable        output numbers in a human-readable format
     &#45;-progress              show progress during transfer</pre>
<p><a id="mount-options"></a></p>
<h2>Mount Options</h2>
<p>The following options apply to any file system that is being mounted (but not every file  system  actually honors them)</p>
<ul>
<li><code>async</code> All I/O to the file system should be done asynchronously.</li>
<li><code>atime</code> Update inode access time for each access. This is the default.</li>
<li><code>auto</code> Can be mounted with the -a option.</li>
<li><code>defaults</code> Use default options: rw, suid, dev, exec, auto, nouser, and async.</li>
<li><code>dev</code> Interpret character or block special devices on the file system.</li>
<li><code>exec</code> Permit execution of binaries.</li>
<li><code>group</code> Allow an ordinary (i.e., non-root) user to mount the file system if one of his groups matches the group of the device.  This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line group,dev,suid).</li>
<li><code>mand</code> Allow mandatory locks on this filesystem. See fcntl(2).</li>
<li><code>_netdev</code> The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).</li>
<li><code>noatime</code> Do not update inode access times on this file system (e.g, for faster access on the news spool to speed up news servers).</li>
<li><code>nodiratime</code> Do not update directory inode access times on this filesystem.</li>
<li><code>noauto</code> Can only be mounted explicitly (i.e., the -a option will not cause the file system to be mounted).</li>
<li><code>nodev</code> Do not interpret character or block special devices on the file system.</li>
<li><code>noexec</code> Do not allow direct execution of any binaries on the mounted file system.  (Until recently it was possible to run binaries anyway using a command like /lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.)</li>
<li><code>nomand</code> Do not allow mandatory locks on this filesystem.</li>
<li><code>nosuid</code> Do not allow set-user-identifier or set-group-identifier bits to take effect. (This seems safe, but is in fact rather unsafe if you have suidperl(1) installed.)</li>
<li><code>nouser</code> Forbid an ordinary (i.e., non-root) user to mount the file system.  This is the default.</li>
<li><code>owner</code> Allow an ordinary (i.e., non-root) user to mount the file system if he is the owner of the device.  This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line owner,dev,suid).</li>
<li><code>remount</code> Attempt to remount an already-mounted file system.  This is commonly used to change the mount flags for a file system, especially to make a readonly file system writeable. It does not change device or mount point.</li>
<li><code>ro</code> Mount the file system read-only.</li>
<li><code>_rnetdev</code> Like _netdev, except &#8220;fsck -a&#8221; checks this filesystem during rc.sysinit.</li>
<li><code>rw</code> Mount the file system read-write.</li>
<li><code>suid</code> Allow set-user-identifier or set-group-identifier bits to take effect.</li>
<li><code>sync</code> All I/O to the file system should be done synchronously. In case of media with limited number of write cycles (e.g. some flash drives) &#8220;sync&#8221; may cause life-cycle shortening.</li>
<li><code>dirsync</code> All directory updates within the file system should be done synchronously.  This affects the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod and rename.</li>
<li><code>user</code> Allow  an ordinary user to mount the file system.  The name of the mounting user is written to mtab so that he can unmount the file system again.  This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid).</li>
<li><code>users</code> Allow every user to mount and unmount the file system.  This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line users,exec,dev,suid).</li>
</ul>
<p><a id="filesystems"></a></p>
<h2>Filesystems</h2>
<p>You can find out what is filesystems are in place by using one of the following linux commands:</p>
<pre>cat /etc/fstab
cat /etc/mtab
cat /proc/mounts
df -a</pre>
<h2>/etc/fstab</h2>
<pre>       /etc/fstab        file system table
       /etc/mtab         table of mounted file systems
       /etc/mtab~        lock file
       /etc/mtab.tmp     temporary file
       /etc/filesystems  a list of filesystem types to try</pre>
<p>From /etc/mtab</p>
<pre>none /tmp tmpfs size=128m,mode=1777 0 0</pre>
<p>From /proc/mounts</p>
<pre>none /tmp tmpfs rw,nodev,relatime,size=131072k 0 0</pre>
<p><br class="C" /></p>
<p><a id="fstab"></a></p>
<h2>/etc/fstab</h2>
<p>It is possible that files /etc/mtab and /proc/mounts don’t match. The first file is based only on the mount command options, but the content of the second file also depends on the kernel and others settings (e.g.  remote NFS server. In particular case  the  mount  command  may reports unreliable information about a NFS mount point and the /proc/mounts file usually contains more reliable information.)</p>
<p>This file is used in three ways:</p>
<ol>
<li>The following command (usually given in a bootscript) causes all file systems mentioned in fstab (of the proper type and/or having or not having the proper options) to be mounted as indicated, except for those whose line contains the noauto keyword. Adding the -F option will  make  mount  fork,  so that the filesystems are mounted simultaneously.
<pre>mount -a [-t type] [-O optlist]</pre>
</li>
<li>When mounting a file system mentioned in fstab, it suffices to give only the device, or only the mount point.</li>
<li>Normally, only the superuser can mount file systems.  However, when fstab contains the user option on a line, anybody can mount the corresponding system.</li>
</ol>
<p>The programs mount and umount maintain a list of currently mounted file systems in the file /etc/mtab.</p>
<p>Only the user that mounted a filesystem can unmount it again.  If any user should be able to unmount, then use users instead of user in the fstab line.  The owner option is similar to the user option, with the restriction that the user must be the owner of the special file.  The group option is similar, with the restriction that the user must be member of the group of the special file.</p>
<p>The order of records in fstab is important because fsck(8), mount(8), and umount(8) sequentially iterate through fstab doing their thing.</p>
<h3>The first field, (fs_spec)</h3>
<p>Describes the block special device or remote filesystem to be mounted.  For ordinary mounts it will hold (a link to) a block special device node (as created by mknod(8)) for the device to be mounted, like ‘/dev/cdrom’ or ‘/dev/sdb7’.  For NFS mounts one will have <code><host>:<dir></code>, e.g., ‘knuth.aeb.nl:/’.  For procfs, use ‘proc’.</p>
<p>Instead of giving the device explicitly, one may indicate the (ext2 or xfs) filesystem that is to be mounted by its UUID or volume label (cf.  e2label(8) or xfs_admin(8)), writing LABEL=<label> or UUID=<uuid>, e.g., ‘LABEL=Boot’ or  ‘UUID=3e6be9de-8139-11d1-9106-a43f08d823a6’.  This will make the system more robust: adding or removing a SCSI disk changes the disk device name but not the filesystem volume label.</p>
<h3>The second field, (fs_file)</h3>
<p>Describes the mount point for the filesystem.  For swap partitions, this field should be specified as ‘none’. If the name of the mount point contains spaces these can be escaped as ‘\040’.</p>
<p>The  third  field,  (fs_vfstype),  describes the type of the filesystem.  Linux supports lots of filesystem types, such as adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, and possibly others. For more details, see mount(8).  <strong>For the filesystems currently supported by the running kernel, see /proc/filesystems</strong>.  An entry swap denotes  a  file  or  partition  to  be  used  for  swapping,  cf.  swapon(8).  An entry ignore causes the line to be ignored.  This is useful to show disk partitions which are currently unused.</p>
<h3>The fourth field, (fs_mntops)</h3>
<p>Describes the mount options associated with the filesystem.  It  is formatted as a comma separated list of options.  It contains at least the type of mount plus any additional options appropriate to the filesystem type.  For documentation on the available options for non-nfs file systems, see mount(8).  For documentation on all nfs-specific options have a look at nfs(5).</p>
<p>Common for all types of file system are the options:</p>
<ul>
<li><strong>noauto</strong>: (do not mount when &#8220;mount -a&#8221; is given, e.g., at boot time)</li>
<li><strong>user</strong>: (allow a user to mount)</li>
<li><strong>owner</strong>: (allow device owner to mount)</li>
<li><strong>pamconsole</strong>: (allow a user at the console to mount)</li>
<li><strong>comment</strong>: (e.g., for use by fstab-maintaining programs).</li>
</ul>
<h3>The fifth field, (fs_freq)</h3>
<p>Used for these filesystems by the dump(8) command to determine which filesystems need to be dumped.  If the fifth field is not present, a value of zero is returned and dump will assume that the filesystem does not need to be dumped.</p>
<h3>The  sixth  field,  (fs_passno)</h3>
<p>Used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time.  The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2.  Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware.  If the sixth field is not present or zero, a value of zero is returned and <strong>fsck will assume that the filesystem does not need to be checked</strong>.</p>
<h3>More Reading</h3>
<ul>
<li><a href="http://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux/" rel="nofollow" >Overview of RAMFS and TMPFS on Linux</a></li>
<li><a href='http://uploads.askapache.com/2009/09/ramfs-rootfs-initramfs.txt'>ramfs, rootfs and initramfs</a></li>
<li><a href='http://uploads.askapache.com/2009/09/tmpfs.txt'>Tmpfs is a file system which keeps all files in virtual memory</a></li>
<li><a href="http://www.ibm.com/developerworks/library/l-fs3.html" rel="nofollow" >IBM: Advanced filesystem implementor&#8217;s guide, Part 3</a></li>
<li><a href="http://en.wikipedia.org/wiki/TMPFS" rel="nofollow" >TMPFS Wikipedia Entry</a></li>
<li><a href="http://en.wikipedia.org/wiki/Shared_memory" rel="nofollow" >Shared Memory</a></li>
<li><a href="http://kevin.vanzonneveld.net/techblog/article/create_turbocharged_storage_using_tmpfs/" rel="nofollow" >Create turbocharged storage using tmpfs</a></li>
<li><a href="http://dev.mysql.com/doc/refman/4.1/en/temporary-files.html" rel="nofollow" >Where MySQL Stores Temporary Files</a></li>
<li><a href="http://www.linuxized.com/2009/05/speeding-up-firefox-with-tmpfs-and-automatic-rsync/" rel="nofollow" >speeding up firefox with tmpfs and automatic rsync</a> <a href="http://www.linuxized.com/wp-content/uploads/2009/05/speedfox" rel="nofollow" >(shell-script)</a> <a href="http://autoverse.net/blog/2009/apr/23/speed-firefox/" rel="nofollow" >Original</a></li>
<li><a href="http://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt" rel="nofollow" >kernel documentation for tmpfs</a></li>
<li><a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=386368" rel="nofollow" >initscripts: please don&#8217;t mount /dev/shm noexec</a></li>
<li><a href="http://forums.debian.net/viewtopic.php?t=16450" rel="nofollow" >HOWTO: Using tmpfs for /tmp, /var/{log,run,lock&#8230;}</a></li>
<li><a href="http://forums.gentoo.org/viewtopic-t-371889-highlight-tmpfs.html" rel="nofollow" >Gentoo Forums: Using tmpfs for /var/{log,lock,&#8230;}</a></li>
<li><a href="http://forums.gentoo.org/viewtopic-t-717117-highlight-tmpfs.html" rel="nofollow" >[TIP] Firefox and tmpfs: a surprising improvement</a></li>
</ul>
<blockquote cite="http://openquery.com/blog/experiment-mysql-tmpdir-on-tmpfs"><p>
<cite><a href="http://openquery.com/blog/experiment-mysql-tmpdir-on-tmpfs" rel="nofollow" >Experiment: MySQL tmpdir on tmpfs</a></cite></p>
<p>In MySQL, the tmpdir path is mainly used for disk-based sorts (if the sort_buffer_size is not enough) and disk-based temp tables. The latter cannot always be avoided even if you made tmp_table_size and max_heap_table_size quite large, since MEMORY tables don’t support TEXT/BLOB type columns, and also since you just really don’t want to run the risk of exceeding available memory by setting these things too large.</p>
</blockquote>
<p><br class="C" /></p>
<h2>Use tmpfs for MySQL</h2>
<pre>&#45;-tmpdir=path, -t path</pre>
<blockquote cite="http://dev.mysql.com/doc/refman/4.1/en/server-options.html#option_mysqld_tmpdir"><p>The path of the directory to use for creating temporary files. It might be useful if your default /tmp directory resides on a partition that is too small to hold temporary tables. Starting from MySQL 4.1.0, this option accepts several paths that are used in round-robin fashion. Paths should be separated by colon characters (“:”) on Unix and semicolon characters (“;”) on Windows, NetWare, and OS/2. If the MySQL server is acting as a replication slave, you should not set &#8211;tmpdir to point to a directory on a memory-based file system or to a directory that is cleared when the server host restarts. For more information about the storage location of temporary files, see Section A.1.4.4, “Where MySQL Stores Temporary Files”. A replication slave needs some of its temporary files to survive a machine restart so that it can replicate temporary tables or LOAD DATA INFILE operations. If files in the temporary file directory are lost when the server restarts, replication fails. </p></blockquote>
<blockquote cite="http://dev.mysql.com/doc/refman/4.1/en/temporary-files.html"><p>On Unix, MySQL uses the value of the TMPDIR  environment variable as the path name of the directory in which to store temporary files. If TMPDIR  is not set, MySQL uses the system default, which is usually /tmp, /var/tmp, or /usr/tmp. </p>
<p> If the file system containing your temporary file directory is too small, you can use the &#8211;tmpdir option to mysqld to specify a directory in a file system where you have enough space.</p>
<p>Starting from MySQL 4.1, the &#8211;tmpdir option can be set to a list of several paths that are used in round-robin fashion. Paths should be separated by colon characters (“:”) on Unix and semicolon characters (“;”) on Windows, NetWare, and OS/2.<br />
Note</p>
<p>To spread the load effectively, these paths should be located on different physical disks, not different partitions of the same disk.</p>
<p>If the MySQL server is acting as a replication slave, you should not set &#8211;tmpdir to point to a directory on a memory-based file system or to a directory that is cleared when the server host restarts. A replication slave needs some of its temporary files to survive a machine restart so that it can replicate temporary tables or LOAD DATA INFILE operations. If files in the temporary file directory are lost when the server restarts, replication fails.</p>
<p>MySQL creates all temporary files as hidden files. This ensures that the temporary files are removed if mysqld is terminated. The disadvantage of using hidden files is that you do not see a big temporary file that fills up the file system in which the temporary file directory is located.
</p></blockquote>
<p><br class="C" /></p>
<h2>Shell Script for Firefox tmpfs</h2>
<pre>#!/bin/bash
### Bind temporary directories to /dev/shm ###
# I do this instead of mounting tmpfs on the #
# directories, so less memory gets wasted.   #
##############################################
mkdir /dev/shm/{tmp,lock}
mount &#45;-bind /dev/shm/tmp /tmp
mount &#45;-bind /dev/shm/tmp /var/tmp
mount &#45;-bind /dev/shm/lock /var/lock
chmod 1777 /dev/shm/{tmp,lock}</pre>
<hr />
<p><strong>Hey!</strong> You made it!@ at least to the bottom of the page..  I still have to finish this article, so check back in a few months.</p>
<p><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html"></a><a href="http://www.askapache.com/web-hosting/super-speed-secrets.html">30x Faster WP-Super Cache Site Speed</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/web-hosting/super-speed-secrets.html/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PortaPutty Auto-Reconnecting SSH Tunnels on an Encrypted TrueCrypt Portable USB Key w GPG</title>
		<link>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html</link>
		<comments>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html#comments</comments>
		<pubDate>Tue, 23 Feb 2010 10:11:11 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Making Money]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Web Tools]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[401]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bash_profile]]></category>
		<category><![CDATA[Boot]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Defrag]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[GPG]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[ionice]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[PageDefrag]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Pipelining]]></category>
		<category><![CDATA[Plink]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[Putty]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[SOCKS]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSH Tunnels]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[TrueCrupt]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[USB Drives]]></category>

		<guid isPermaLink="false">http://askapache.com/?p=4001</guid>
		<description><![CDATA[<p><a class="IFL" id="id6" href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"></a>Ok I just came back up to write the intro.. I'm trying to keep it short to avoid getting bogged down by the coolness of each step.  Here is what goes on.   When I logon to my XP machine at work, I bring my usb key and plug it in first.  On logging a window pops up first and it's a password prompt to mount my encrypted drive leonardo.  It also checks a keyfile that is located on my usb key, but all I do now is type in my password.  That causes my encrypted folder to be accessible to me like a normal drive, and it autoruns a startup batch file. <br /><br />The batch file causes <strong>Portable</strong> versions of Firefox (<em>all my bookmarks, my settings</em>) to load, and launches <strong>Portable</strong> Mozilla Thunderbird (IMAP makes this work well), which is my favorite program (<em>great GPG features and open-source!</em>).  Also Some Adobe CS4 software is loaded from the hard drive, like DreamWeaver.  In the background, a service we created executes a PortaPuttY plink command to create forwarded tunnels from various remote servers and accounts, all using key-based encryption.  These tunnels are automatically reconnected if they are disconnected, meaning you can use a socks 5 if you want or even better!<br class="C" /></p>
<p><strong>Part 1 of 5</strong></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=4329073&#038;CatId=3786" rel="nofollow" id="id6" class="IFL"  title="This ones over $400 dollars! 128GB!"></a>Ok I just came back up to write the intro.. I&#8217;m trying to keep it short to avoid getting bogged down by the coolness of each step.  Here is what goes on.   When I logon to my XP machine at work, I bring my usb key and plug it in first.  On logging a window pops up first and it&#8217;s a password prompt to mount my encrypted drive leonardo.  It also checks a keyfile that is located on my usb key, but all I do now is type in my password.  That causes my encrypted folder to be accessible to me like a normal drive, and it autoruns a startup batch file.  The batch file causes <strong>Portable</strong> versions of Firefox (<em>all my bookmarks, my settings</em>) to load, and launches <strong>Portable</strong> Mozilla Thunderbird (IMAP makes this work well), which is my favorite program (<em>great GPG features and open-source!</em>).  Also Some Adobe CS4 software is loaded from the hard drive, like DreamWeaver.<br class="C" /></p>
<p>The batch file also runs PortaPuttY plink to create forwarded tunnels from various remote servers and accounts, all using key-based encryption.  This includes dynamic SOCKS 4/5 tunnels, VPN tun device tunnels, and of course the basic SSH port forwarding tunnels that are so powerful.  These tunnels are automatically reconnected if they are disconnected, using simple windows builtin command-line tools.  And believe me it was not easy to figure out how to make this all work using plink ( essentially the same as putty minus the gui ), I literally had to use almost all of my Windows kung fu to finally end up with this.</p>
<h2>Using MyEnTunnel</h2>
<p>Initially I was using the <a href="http://nemesis2.qx.net" rel="nofollow" >MyEnTunnel</a> program combined with a custom windows batch install script I wrote to handle the tunnels.</p>
<p>The tunnels are very important to making things easy while improving security.  It&#8217;s not easy to understand at first, but basically it means <strong>you can now connect to ANY IP address:port as if you were on that very machine connecting to localhost, like if you pinged yourself!</strong>.  The result is any traffic you want is now encrypted, and you can set up your servers to only accept connections from localhost, which could save you tons of memory, bandwidth, and security attack vectors to think about.   So I configure everything to use these tunnels as proxies, like Mozilla Thunderbird and Chrome, Firefox, Pidgeon, all portable versions and running from my encrypted usb drive.</p>
<p>This means you can walk into my house with that usb key, plug into any computer here, and surf the web/check your emails all across SSH&#8230; I know for a fact <strong>I wouldn&#8217;t be able to snoop that</strong> traffic!  There is a lot of exciting things going on around here, new servers and all.. Its going to take a couple more posts for me to finish this up, enjoy the article and comment.</p>
<h2>Buy a couple USB Mini Drives</h2>
<p>The first thing to do, is purchase a USB thumb drive..   My favorite store, <a href="http://www.tigerdirect.com/applications/category/category_slc.asp?Recs=30&#038;Nav=|c:379|lp:0.01:hp:24.99|&#038;Sort=4" rel="nofollow"  title="Highly recommended, this is not an affiliate link">TigerDirect.com</a>, has over 104 tiny usb drives for under $24.. I&#8217;ve used them since the late 90&#8242;s.</p>
<p>I bought some 4GB PNY&#8217;s the size of a fingernail at a gas station and they are amazing, way faster than say a dvd drive.  Just try to do some research of the differences between the 16GB vs the $4 1GB drives.. You want speed because the whole drive will be encrypted.   <em>If you can afford the super excellent and crazy fast ones, hey send me one!</em> Buying cheap means you can buy 3 or 4 so you can always have backups.  This device will make you Internationally mobile, untethered from a box, maybe getting some work done at a cafe in Florenze, or at a beach hotel in Miami.  Keep dreaming, but that is more possible with a better organized system.</p>
<h3>Backup the USB Drive</h3>
<p>You only need to know 1 way that works, there are several.  The way I do backups is to copy the entire disk image of the usb, that way I can always access it in case of usb key failure, which does happen.  Free software like <a href="http://clonezilla.org/" rel="nofollow" >CloneZilla live CD</a> with its crazy cluster computing power, or Self Image, which is free for both linux and Windows.  And you could never go wrong with <a href="http://www.symantec.com/norton/ghost" rel="nofollow" >GHOST</a>, one of the first to make mega bucks in the market.. it&#8217;s some seriously impressive software <em>but not open-source</em>.  Even easier for some is to just set a cron job for dd to pipe the entire drive image to a remote computer using netcat, or sshfs, or curlftpfs, or just <strong>simple ssh</strong> like below.  Once setup (without stupid, bulky, dangerous software), the files on your encrypted usb don&#8217;t change often, otherwise I would want to sync a backup to happen automatically every X number of logins or days (<em>test logfile time in bash_profile?</em>)..</p>
<h4>SSH Back-ups To Remote Server</h4>
<p>Files and data on your drives slow it down tremendously, meaning a web server storing backups locally is slower than one storing them externally.</p>
<p>Notice how much safer this command is by optimizing both the <a href="http://www.askapache.com/linux-unix/optimize-nice-ionice.html">CPU and DISK I/O</a>..  Though it&#8217;s much smarter to create a new separate ssh user, one with no shell and a passwordless safer key-based encryption.  Then in your /etc/security/limits.conf file or your initscript you can cause that user to have <code>nice -19</code> and <code>ionice -c2 -n7</code> priority set all the time automatically, since sshd, compression, and disk writing are this accounts only job.  turboslow is an alias defined in a ssh_config file so you don&#8217;t have to type the host, port, and settings each time.</p>
<pre>#
# much better ways to do this on google!!!!!!!
#
ionice -c2 -n7 nice -n 19 dd if=/dev/sdb2 bs=1k conv=sync,noerror | gzip -c | ssh turboslow &quot;dd of=sdb2.gz bs=1k&quot;</pre>
<p>Note that you may decide it would be better to configure the ssh connection to a less CPU intensive algorithm, perhaps even <em>protocol 1</em> and <em>DES</em>.  That&#8217;s perfectly alright, but the tradeoff is that the encryption can be broken much quicker, and so you would have to implement a cron job to create new keys on both ends of the tunnel every few hours.. It&#8217;s really not a big deal to setup, kind of sweet way to use key-based encryption.  Also, important files ( those containing passwords, any database ) are encrypted before transport using private GPG keys, which don&#8217;t need to be changed.  The other thing to think about too is only letting your main PC send/write on the backup host, so the backup host is only authorized to rx and can never login back to yours. </p>
<p>Hey! the Internet is a dangerous place you better believe it!  And it&#8217;s only going to get more interesting with cloud computing&#8217;s breakthrough&#8217;s&#8230; More people who know they&#8217;re way around&#8230; I can always use an extra server, I&#8217;d love to expand my network another node without having to pay for it (free cloud computing?), so make sure your servers are locked up strenuously.  Not super perfect, just a little unique or creative in your defense to avoid any coming super-worm&#8217;s that may be employing vast arsenals of the deadliest attack-engines like metasploit..  Scarry rumors.</p>
<h4>Compression Speeds: PBZip2, Rzip, Lzop, Gzip</h4>
<p>Probably the fastest is to use rsync over ssh, which is what I&#8217;m doing, since the algorithms used by rsync are much faster and safer.  <a href="http://www.askapache.com/security/mirror-using-rsync-ssh.html">Rsync also lets you specify a compression program</a>, so depending on your machine you will want pbzip2 (for multi processors) or rzip which are the 2 fastest I know of, though I have had some reliability issues with rzip for gigabyte transfers.  Pbzip2 is amazing, blew me away the first time being 8x faster (8 CPUs) then <strong>anything</strong>.  You can get it and compile a static binary for your thumb drive if want at <a href="http://compression.ca/pbzip2/" rel="nofollow" >Parallel BZIP2 (PBZIP2)</a>. Heavy code, re: this note by Jeff Gilchrist</p>
<p><quote><strong>NOTE</strong>: If you are looking for a parallel BZIP2 that works on cluster machines, you should check out <strong>MPIBZIP2</strong> <strong>which was designed for a distributed-memory message-passing architecture</strong>.</quote></p>
<pre>tar cpf &quot;$G&quot; &#45;-use-compress-prog=pbzip2 ./</pre>
<p><a href="http://uploads.askapache.com/2010/02/pbzip2.gif" rel="nofollow" ><img src="http://uploads.askapache.com/2010/02/pbzip2.gif" alt="Parallel BZIP2 (PBZIP2)" title="pbzip2" class="size-medium wp-image-4002" /></a></p>
<h4>Benchmarking for Performance</h4>
<p>Finally a couple tips, you should get an idea what the device can do, format it a few times for linux and test it on windows, and vice versa.. Some drives are too small or too old and can only support fat32 filesystems on winblows, you DO NOT want fat32 because this drive is going to be 100% encrypted and then 100% transparently decrypted as you use it, </p>
<pre># note this is 512MB
dd if=/dev/sda1 of=/dev/null bs=512 count=1000000
512000000 bytes (512 MB) copied, 5.16588 s, 99.1 MB/s</pre>
<h2>Part II:  Encrypted AutoRunning USB Key with TrueCrypt</h2>
<p>Now this section anyone can do, it&#8217;s so easy on Windows.   What I&#8217;m going to show you how to do is get setup the right way super-fast.  There are many ways to use TrueCrypt, it&#8217;s one of the nicest built software programs&#8217;s I&#8217;ve ever used&#8230; Sadly, it is not licensed open-source, and that is often a deal-breaker for security-conscious folks or anti-pirate anarchists.  From the very helpful TrueCrypt web site:</p>
<blockquote cite="">
<ul type="disc">
<li>Creates a <strong>virtual encrypted disk</strong> within a file and mounts  it as a real disk. </li>
<li>Encrypts an<strong> entire partition or storage device</strong> such as USB flash drive or hard drive.</li>
<li>Encrypts a <strong>partition or drive where Windows is installed</strong> (<a href="http://www.truecrypt.org/docs/?s=system-encryption" rel="nofollow" >pre-boot authentication</a>).</li>
<li>Encryption is <a href="http://www.truecrypt.org/docs/" rel="nofollow" ><strong>automatic</strong>, <strong>real-time</strong> (on-the-fly) and <strong>transparent</strong></a>.</li>
<li> <a href="http://www.truecrypt.org/docs/?s=parallelization" rel="nofollow" >Parallelization</a> and <a href="http://www.truecrypt.org/docs/?s=pipelining" rel="nofollow" >pipelining</a> allow data to be read and written as fast as if the drive was not encrypted.</li>
<li>Provides <strong><a href="http://www.truecrypt.org/docs/?s=plausible-deniability" rel="nofollow" >plausible deniability</a></strong>, in case an adversary  forces you to reveal the password: <strong><a href="http://www.truecrypt.org/hiddenvolume" rel="nofollow" >Hidden volume</a></strong> (steganography) and <strong><a href="http://www.truecrypt.org/docs/?s=hidden-operating-system" rel="nofollow" >hidden operating system</a></strong>.</li>
<li><a href="http://www.truecrypt.org/docs/?s=encryption-algorithms" rel="nofollow" >Encryption algorithms</a>: <a href="http://www.truecrypt.org/docs/?s=aes" rel="nofollow" >AES-256</a>, <a href="http://www.truecrypt.org/docs/?s=serpent" rel="nofollow" >Serpent</a>, and <a href="http://www.truecrypt.org/docs/?s=twofish" rel="nofollow" >Twofish</a>.  Mode of operation: <a href="http://www.truecrypt.org/docs/?s=modes-of-operation" rel="nofollow" >XTS</a>.</li>
</ul>
</blockquote>
<h2>Further Reading</h2>
<ul>
<li><a href="http://ultra.ap.krakow.pl/~bar/DOC/ssh_backup.html" rel="nofollow" >Network File Copy using SSH</a></li>
<li>Check out the trunk version of PuTTY:<code>~ svn co svn://svn.tartarus.org/sgt/putty</code>
</ul>
<hr class="C" />
<p>The real fun doesn&#8217;t start till all the automation starts, automating all of that from a couple batch files I wrote, one click setup.  Kind of like building your own knoppix for when you have to use Windows.  To begin this tutorial, setup a truecrypt traveller setup on your usb and also install the portaputty package onto the usb.  You do this by creating a 3GB or whatever file on the usb and then mounting that file like you would mount an iso file.   I will show the Windows Batch file I use and the tricks with Windows Volume names and how to consistently make it all work.   Then we will setup MyEnTunnel with a customized batch file that forces all puttys to use portaputty (<code>sweet hack stolen from sysinternals pagedefrag tool</code>).<strong>Stay Tuned!</strong></p>
<p><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"></a><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html">PortaPutty Auto-Reconnecting SSH Tunnels on an Encrypted TrueCrypt Portable USB Key w GPG</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>HTTP Status Codes and .htaccess ErrorDocuments</title>
		<link>http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html</link>
		<comments>http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#comments</comments>
		<pubDate>Mon, 04 Jan 2010 20:56:15 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[301 Redirect]]></category>
		<category><![CDATA[302 Redirect]]></category>
		<category><![CDATA[401]]></category>
		<category><![CDATA[403 Forbidden]]></category>
		<category><![CDATA[404 Not Found]]></category>
		<category><![CDATA[500]]></category>
		<category><![CDATA[503]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[Bandwidth]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[error log]]></category>
		<category><![CDATA[errordocument]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[HTTP Error]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[HTTP Status Codes]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[If-Modified-Since]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[phpBB]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Redirection]]></category>
		<category><![CDATA[Request Method]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Sniffing]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Wget]]></category>
		<category><![CDATA[Wireshark]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.askapache.com.com/htaccess/wow-i-served-a-page-for-every-single-http-status-code-and-saved-headers-and-content.html</guid>
		<description><![CDATA[<p>There are a total of <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#apache-response-codes-57">57 HTTP Status Codes</a> recognized by the Apache Web Server.  Wouldn't you like to see what all those headers and their output, ErrorDocuments look like?</p>]]></description>
			<content:encoded><![CDATA[<p><strong>I was trying to find an official, authoritative list of HTTP Status Codes</strong> but I kept finding lists that weren&#8217;t authoritative or complete. So I searched and found my answer in the Apache HTTP Server source code.  Once I had the exact HTTP Status Codes and resulting Error Documents sent by Apache, I researched deeper into HTTP Status Codes by reading as many related RFC&#8217;s as I could find, and several other software source codes were explored.  This is the most authoritative list I know of, if you can do better leave a comment and I&#8217;ll update it.  Another thing to keep in mind, the Status code number itself is what is used by software and hardware to make determinations, the phrase returned by the status code is for the human only and does not have any weight other than informing the user.. So &#8220;503 Service Unavailable&#8221;, &#8220;503 Service Temporarily Unavailable&#8221;, and &#8220;503 Get the heck outta here&#8221; are all completely valid.</p>
<p class="bnote"><strong>Update March 9, 2009</strong>: A lot of sites on the web have updated their HTTP status code lists to include the HTTP Status codes listed on this page, including Wikipedia, IANA, W3C, and others, so rest assured this info is accurate and complete.  If you&#8217;d like to see how to create custom error pages for all of these errors like mine  <a href="http://www.askapache.com/show-error-506">/show-error-506</a> , then check out  <a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html">this detailed tutorial</a>  I just posted.</p>
<h2>Contents</h2>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#apache-response-codes-57">List of All 57 HTTP Response Status Code</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#quick-start">Quick Start to triggering ErrorDocuments for each Status Code</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#automating-the-process">Automate the ErrorDocument Triggering</a>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#redirect-code-in-htaccess">The htaccess Code</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#php-header-grabber-script">PHP script that gets and outputs the Headers/Content</a> </li>
</ul>
</li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#headers-returned-content">Headers and Content Returned</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#apache-source-code">Apache Source Code</a>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#httpdh-h">httpd.h</a> </li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#http_protocol-c">http_protocol.c</a> </li>
</ul>
</li>
</ul>
<h2> <a href="#apache-response-codes-57" rel="nofollow"  name="apache-response-codes-57" id="apache-response-codes-57">57 APACHE HTTP STATUS RESPONSE CODES</a> </h2>
<p>Once I compiled the list of Apache recognized HTTP Status Codes, I was dying to see them all in action (<em>i.e. the corresponding <strong>ErrorDocument</strong></em>).  At first I thought I would have to create a php or perl script emulating each of the 57 HTTP Status Codes, a tedious undertaking I wasn&#8217;t about to do.  Instead I &#8220;asked Apache&#8221; by searching the  <a href="http://httpd.apache.org/docs/trunk/" rel="nofollow" >Apache HTTP Documentation</a>  for <em>ambiguity sending Status Codes and/or triggering ErrorDocuments</em> with an Apache Directive.<br /><strong>While reading</strong> up on  <a href="http://askapache.info/trunk/mod/mod_alias.html" rel="nofollow" >mod_alias</a>  and the  <a href="http://askapache.info/trunk/mod/mod_alias.html#redirect" rel="nofollow" >Redirect</a>  directive I found:</p>
<blockquote cite="http://httpd.apache.org/docs/trunk/mod/mod_alias.html#redirect"><p><cite>Apache Docs</cite></p>
<p>Syntax: <strong>Redirect [status] URL-path URL</strong> The status argument can be used to return <strong>other</strong> HTTP status codes. <strong>Other</strong> status codes can be returned by giving the numeric status code as the value of status.  If the status is between 300 and 399, the URL argument must be present, otherwise it must be omitted.</p>
</blockquote>
<dl>
<dt><a id="code-100" title="Continue">100 Continue</a> </dt>
<dd><a href="/e/100/" rel="nofollow" title="ErrorDocument 100" >ErrorDocument Continue</a>  |  <a href="#status-100" rel="nofollow"  title="Sample Continue">Sample 100 Continue</a> <br />This means that the server has received the request headers, and that the client should proceed to send the request body (in case of a request which   needs to be sent; for example, a POST request). If the request body is large, sending it to a server when a request has already been rejected based upon inappropriate headers is inefficient.   To have a server check if the request could be accepted based on the requests headers alone, a client must send Expect: 100-continue as a header in its initial request (see RFC 2616 14.20 Expect header) and check if a 100 Continue status code is received in response before continuing (or receive 417 Expectation Failed and not continue).</dd>
<dt><a id="code-101" title="Switching Protocols">101 Switching Protocols</a> </dt>
<dd><a href="/e/101/" rel="nofollow" title="ErrorDocument 101" >ErrorDocument Switching Protocols</a>  |  <a href="#status-101" rel="nofollow"  title="Sample Switching Protocols">Sample 101 Switching Protocols</a> <br />This means the requester has asked the server to switch protocols and the server is acknowledging that it will do so.[3]</dd>
<dt><a id="code-102" title="Processing">102 Processing</a> </dt>
<dd><a href="/e/102/" rel="nofollow" title="ErrorDocument 102" >ErrorDocument Processing</a>  |  <a href="#status-102" rel="nofollow"  title="Sample Processing">Sample 102 Processing</a> <br />(WebDAV) &#8211; (RFC 2518 )</dd>
<dt><a id="code-200" title="OK">200 OK</a> </dt>
<dd><a href="/e/200/" rel="nofollow" title="ErrorDocument 200" >ErrorDocument OK</a>  |  <a href="#status-200" rel="nofollow"  title="Sample OK">Sample 200 OK</a> <br />Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an   entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action.</dd>
<dt><a id="code-201" title="Created">201 Created</a> </dt>
<dd><a href="/e/201/" rel="nofollow" title="ErrorDocument 201" >ErrorDocument Created</a>  |  <a href="#status-201" rel="nofollow"  title="Sample Created">Sample 201 Created</a> <br />The request has been fulfilled and resulted in a new resource being created.</dd>
<dt><a id="code-202" title="Accepted">202 Accepted</a> </dt>
<dd><a href="/e/202/" rel="nofollow" title="ErrorDocument 202" >ErrorDocument Accepted</a>  |  <a href="#status-202" rel="nofollow"  title="Sample Accepted">Sample 202 Accepted</a> <br />The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it   might be disallowed when processing actually takes place.</dd>
<dt><a id="code-203" title="Non-Authoritative Information">203 Non-Authoritative Information</a> </dt>
<dd><a href="/e/203/" rel="nofollow" title="ErrorDocument 203" >ErrorDocument Non-Authoritative Information</a>  |  <a href="#status-203" rel="nofollow"  title="Sample Non-Authoritative Information">Sample 203 Non-Authoritative Information</a> <br />The server successfully processed the request, but is returning information that may be from another source.</dd>
<dt><a id="code-204" title="No Content">204 No Content</a> </dt>
<dd><a href="/e/204/" rel="nofollow" title="ErrorDocument 204" >ErrorDocument No Content</a>  |  <a href="#status-204" rel="nofollow"  title="Sample No Content">Sample 204 No Content</a> <br />The server successfully processed the request, but is not returning any content.</dd>
<dt><a id="code-205" title="Reset Content">205 Reset Content</a> </dt>
<dd><a href="/e/205/" rel="nofollow" title="ErrorDocument 205" >ErrorDocument Reset Content</a>  |  <a href="#status-205" rel="nofollow"  title="Sample Reset Content">Sample 205 Reset Content</a> <br />The server successfully processed the request, but is not returning any content. Unlike a 204 response, this response requires that the requester   reset the document view.</dd>
<dt><a id="code-206" title="Partial Content">206 Partial Content</a> </dt>
<dd><a href="/e/206/" rel="nofollow" title="ErrorDocument 206" >ErrorDocument Partial Content</a>  |  <a href="#status-206" rel="nofollow"  title="Sample Partial Content">Sample 206 Partial Content</a> <br />The server is delivering only part of the resource due to a range header sent by the client. This is used by tools like wget to enable resuming   of interrupted downloads, or split a download into multiple simultaneous streams.</dd>
<dt><a id="code-207" title="Multi-Status">207 Multi-Status</a> </dt>
<dd><a href="/e/207/" rel="nofollow" title="ErrorDocument 207" >ErrorDocument Multi-Status</a>  |  <a href="#status-207" rel="nofollow"  title="Sample Multi-Status">Sample 207 Multi-Status</a> <br />(WebDAV) &#8211; The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests   were made.</dd>
<dt><a id="code-226" title="IM Used">226 IM Used</a> </dt>
<dd><a href="/e/226/" rel="nofollow" title="ErrorDocument 226" >ErrorDocument IM Used</a>  |  <a href="#status-226" rel="nofollow"  title="Sample IM Used">Sample 226 IM Used</a> <br />The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations   applied to the current instance.  The actual current instance might not be available except by combining this response with other previous or future responses, as appropriate for the specific   instance-manipulation(s).</dd>
<dt><a id="code-300" title="Multiple Choices">300 Multiple Choices</a> </dt>
<dd><a href="/e/300/" rel="nofollow" title="ErrorDocument 300" >ErrorDocument Multiple Choices</a>  |  <a href="#status-300" rel="nofollow"  title="Sample Multiple Choices">Sample 300 Multiple Choices</a> <br />Indicates multiple options for the resource that the client may follow. It, for instance, could be used to present different format options for   video, list files with different extensions, or word sense disambiguation.</dd>
<dt><a id="code-301" title="Moved Permanently">301 Moved Permanently</a> </dt>
<dd><a href="/e/301/" rel="nofollow" title="ErrorDocument 301" >ErrorDocument Moved Permanently</a>  |  <a href="#status-301" rel="nofollow"  title="Sample Moved Permanently">Sample 301 Moved Permanently</a> <br />This and all future requests should be directed to the given URI.</dd>
<dt><a id="code-302" title="Found">302 Found</a> </dt>
<dd><a href="/e/302/" rel="nofollow" title="ErrorDocument 302" >ErrorDocument Found</a>  |  <a href="#status-302" rel="nofollow"  title="Sample Found">Sample 302 Found</a> <br />This is the most popular redirect code[citation needed], but also an example of industrial practice contradicting the standard. HTTP/1.0 specification   (RFC 1945 ) required the client to perform a temporary redirect (the original describing phrase was &#8220;Moved Temporarily&#8221;), but popular browsers implemented it as a 303 See Other. Therefore,   HTTP/1.1 added status codes 303 and 307 to disambiguate between the two behaviours. However, the majority of Web applications and frameworks still use the 302 status code as if it were the   303.</dd>
<dt><a id="code-303" title="See Other">303 See Other</a> </dt>
<dd><a href="/e/303/" rel="nofollow" title="ErrorDocument 303" >ErrorDocument See Other</a>  |  <a href="#status-303" rel="nofollow"  title="Sample See Other">Sample 303 See Other</a> <br />The response to the request can be found under another URI using a GET method. When received in response to a PUT, it should be assumed that the   server has received the data and the redirect should be issued with a separate GET message.</dd>
<dt><a id="code-304" title="Not Modified">304 Not Modified</a> </dt>
<dd><a href="/e/304/" rel="nofollow" title="ErrorDocument 304" >ErrorDocument Not Modified</a>  |  <a href="#status-304" rel="nofollow"  title="Sample Not Modified">Sample 304 Not Modified</a> <br />Indicates the resource has not been modified since last requested. Typically, the HTTP client provides a header like the If-Modified-Since header   to provide a time against which to compare. Utilizing this saves bandwidth and reprocessing on both the server and client, as only the header data must be sent and received in comparison to   the entirety of the page being re-processed by the server, then resent using more bandwidth of the server and client.</dd>
<dt><a id="code-305" title="Use Proxy">305 Use Proxy</a> </dt>
<dd><a href="/e/305/" rel="nofollow" title="ErrorDocument 305" >ErrorDocument Use Proxy</a>  |  <a href="#status-305" rel="nofollow"  title="Sample Use Proxy">Sample 305 Use Proxy</a> <br />Many HTTP clients (such as Mozilla[4] and Internet Explorer) do not correctly handle responses with this status code, primarily for security   reasons.</dd>
<dt><a id="code-306" title="Switch Proxy">306 Switch Proxy</a> </dt>
<dd><a href="/e/306/" rel="nofollow" title="ErrorDocument 306" >ErrorDocument Switch Proxy</a>  |  <a href="#status-306" rel="nofollow"  title="Sample Switch Proxy">Sample 306 Switch Proxy</a> <br />No longer used.</dd>
<dt><a id="code-307" title="Temporary Redirect">307 Temporary Redirect</a> </dt>
<dd><a href="/e/307/" rel="nofollow" title="ErrorDocument 307" >ErrorDocument Temporary Redirect</a>  |  <a href="#status-307" rel="nofollow"  title="Sample Temporary Redirect">Sample 307 Temporary Redirect</a> <br />In this occasion, the request should be repeated with another URI, but future requests can still use the original URI. In contrast to 303,   the request method should not be changed when reissuing the original request. For instance, a POST request must be repeated using another POST request.</dd>
<dt><a id="code-400" title="Bad Request">400 Bad Request</a> </dt>
<dd><a href="/e/400/" rel="nofollow" title="ErrorDocument 400" >ErrorDocument Bad Request</a>  |  <a href="#status-400" rel="nofollow"  title="Sample Bad Request">Sample 400 Bad Request</a> <br />The request contains bad syntax or cannot be fulfilled.</dd>
<dt><a id="code-401" title="Unauthorized">401 Unauthorized</a> </dt>
<dd><a href="/e/401/" rel="nofollow" title="ErrorDocument 401" >ErrorDocument Unauthorized</a>  |  <a href="#status-401" rel="nofollow"  title="Sample Unauthorized">Sample 401 Unauthorized</a> <br />Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. The response must   include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication.</dd>
<dt><a id="code-402" title="Payment Required">402 Payment Required</a> </dt>
<dd><a href="/e/402/" rel="nofollow" title="ErrorDocument 402" >ErrorDocument Payment Required</a>  |  <a href="#status-402" rel="nofollow"  title="Sample Payment Required">Sample 402 Payment Required</a> <br />The original intention was that this code might be used as part of some form of digital cash or micropayment scheme, but that has not happened,   and this code has never been used.</dd>
<dt><a id="code-403" title="Forbidden">403 Forbidden</a> </dt>
<dd><a href="/e/403/" rel="nofollow" title="ErrorDocument 403" >ErrorDocument Forbidden</a>  |  <a href="#status-403" rel="nofollow"  title="Sample Forbidden">Sample 403 Forbidden</a> <br />The request was a legal request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no   difference.</dd>
<dt><a id="code-404" title="Not Found">404 Not Found</a> </dt>
<dd><a href="/e/404/" rel="nofollow" title="ErrorDocument 404" >ErrorDocument Not Found</a>  |  <a href="#status-404" rel="nofollow"  title="Sample Not Found">Sample 404 Not Found</a> <br />The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.</dd>
<dt><a id="code-405" title="Method Not Allowed">405 Method Not Allowed</a> </dt>
<dd><a href="/e/405/" rel="nofollow" title="ErrorDocument 405" >ErrorDocument Method Not Allowed</a>  |  <a href="#status-405" rel="nofollow"  title="Sample Method Not Allowed">Sample 405 Method Not Allowed</a> <br />A request was made of a resource using a request method not supported by that resource; for example, using GET on a form which requires data   to be presented via POST, or using PUT on a read-only resource.</dd>
<dt><a id="code-406" title="Not Acceptable">406 Not Acceptable</a> </dt>
<dd><a href="/e/406/" rel="nofollow" title="ErrorDocument 406" >ErrorDocument Not Acceptable</a>  |  <a href="#status-406" rel="nofollow"  title="Sample Not Acceptable">Sample 406 Not Acceptable</a> <br />The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.</dd>
<dt><a id="code-407" title="Proxy Authentication Required">407 Proxy Authentication Required</a> </dt>
<dd><a href="/e/407/" rel="nofollow" title="ErrorDocument 407" >ErrorDocument Proxy Authentication Required</a>  |  <a href="#status-407" rel="nofollow"  title="Sample Proxy Authentication Required">Sample 407 Proxy Authentication Required</a> <br />Required</dd>
<dt><a id="code-408" title="Request Timeout">408 Request Timeout</a> </dt>
<dd><a href="/e/408/" rel="nofollow" title="ErrorDocument 408" >ErrorDocument Request Timeout</a>  |  <a href="#status-408" rel="nofollow"  title="Sample Request Timeout">Sample 408 Request Timeout</a> <br />The server timed out waiting for the request.</dd>
<dt><a id="code-409" title="Conflict">409 Conflict</a> </dt>
<dd><a href="/e/409/" rel="nofollow" title="ErrorDocument 409" >ErrorDocument Conflict</a>  |  <a href="#status-409" rel="nofollow"  title="Sample Conflict">Sample 409 Conflict</a> <br />Indicates that the request could not be processed because of conflict in the request, such as an edit conflict.</dd>
<dt><a id="code-410" title="Gone">410 Gone</a> </dt>
<dd><a href="/e/410/" rel="nofollow" title="ErrorDocument 410" >ErrorDocument Gone</a>  |  <a href="#status-410" rel="nofollow"  title="Sample Gone">Sample 410 Gone</a> <br />Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally   removed; however, it is not necessary to return this code and a 404 Not Found can be issued instead. Upon receiving a 410 status code, the client should not request the resource again in the   future. Clients such as search engines should remove the resource from their indexes.</dd>
<dt><a id="code-411" title="Length Required">411 Length Required</a> </dt>
<dd><a href="/e/411/" rel="nofollow" title="ErrorDocument 411" >ErrorDocument Length Required</a>  |  <a href="#status-411" rel="nofollow"  title="Sample Length Required">Sample 411 Length Required</a> <br />The request did not specify the length of its content, which is required by the requested resource.</dd>
<dt><a id="code-412" title="Precondition Failed">412 Precondition Failed</a> </dt>
<dd><a href="/e/412/" rel="nofollow" title="ErrorDocument 412" >ErrorDocument Precondition Failed</a>  |  <a href="#status-412" rel="nofollow"  title="Sample Precondition Failed">Sample 412 Precondition Failed</a> <br />The server does not meet one of the preconditions that the requester put on the request.</dd>
<dt><a id="code-413" title="Request Entity Too Large">413 Request Entity Too Large</a> </dt>
<dd><a href="/e/413/" rel="nofollow" title="ErrorDocument 413" >ErrorDocument Request Entity Too Large</a>  |  <a href="#status-413" rel="nofollow"  title="Sample Request Entity Too Large">Sample 413 Request Entity Too Large</a> <br />The request is larger than the server is willing or able to process.</dd>
<dt><a id="code-414" title="Request-URI Too Long">414 Request-URI Too Long</a> </dt>
<dd><a href="/e/414/" rel="nofollow" title="ErrorDocument 414" >ErrorDocument Request-URI Too Long</a>  |  <a href="#status-414" rel="nofollow"  title="Sample Request-URI Too Long">Sample 414 Request-URI Too Long</a> <br />The URI provided was too long for the server to process.</dd>
<dt><a id="code-415" title="Unsupported Media Type">415 Unsupported Media Type</a> </dt>
<dd><a href="/e/415/" rel="nofollow" title="ErrorDocument 415" >ErrorDocument Unsupported Media Type</a>  |  <a href="#status-415" rel="nofollow"  title="Sample Unsupported Media Type">Sample 415 Unsupported Media Type</a> <br />The request did not specify any media types that the server or resource supports. For example the client specified that an image resource   should be served as image/svg+xml, but the server cannot find a matching version of the image.</dd>
<dt><a id="code-416" title="Requested Range Not Satisfiable">416 Requested Range Not Satisfiable</a> </dt>
<dd><a href="/e/416/" rel="nofollow" title="ErrorDocument 416" >ErrorDocument Requested Range Not Satisfiable</a>  |  <a href="#status-416" rel="nofollow"  title="Sample Requested Range Not Satisfiable">Sample 416 Requested Range Not Satisfiable</a> <br />The client has asked for a portion of the file, but the server cannot supply that portion (for example, if the client asked for   a part of the file that lies beyond the end of the file).</dd>
<dt><a id="code-417" title="Expectation Failed">417 Expectation Failed</a> </dt>
<dd><a href="/e/417/" rel="nofollow" title="ErrorDocument 417" >ErrorDocument Expectation Failed</a>  |  <a href="#status-417" rel="nofollow"  title="Sample Expectation Failed">Sample 417 Expectation Failed</a> <br />The server cannot meet the requirements of the Expect request-header field.</dd>
<dt><a id="code-418" title="I'm a teapot">418 I&#8217;m a teapot</a> </dt>
<dd><a href="/e/418/" rel="nofollow" title="ErrorDocument 418" >ErrorDocument I&#8217;m a teapot</a>  |  <a href="#status-418" rel="nofollow"  title="Sample I'm a teapot">Sample 418 I&#8217;m a teapot</a> <br />The HTCPCP server is a teapot. The responding entity MAY be short and stout. Defined by the April Fools specification RFC 2324. See Hyper Text   Coffee Pot Control Protocol for more information.</dd>
<dt><a id="code-422" title="Unprocessable Entity">422 Unprocessable Entity</a> </dt>
<dd><a href="/e/422/" rel="nofollow" title="ErrorDocument 422" >ErrorDocument Unprocessable Entity</a>  |  <a href="#status-422" rel="nofollow"  title="Sample Unprocessable Entity">Sample 422 Unprocessable Entity</a> <br />(WebDAV) (RFC 4918 ) &#8211; The request was well-formed but was unable to be followed due to semantic errors.</dd>
<dt><a id="code-423" title="Locked">423 Locked</a> </dt>
<dd><a href="/e/423/" rel="nofollow" title="ErrorDocument 423" >ErrorDocument Locked</a>  |  <a href="#status-423" rel="nofollow"  title="Sample Locked">Sample 423 Locked</a> <br />(WebDAV) (RFC 4918 ) &#8211; The resource that is being accessed is locked</dd>
<dt><a id="code-424" title="Failed Dependency">424 Failed Dependency</a> </dt>
<dd><a href="/e/424/" rel="nofollow" title="ErrorDocument 424" >ErrorDocument Failed Dependency</a>  |  <a href="#status-424" rel="nofollow"  title="Sample Failed Dependency">Sample 424 Failed Dependency</a> <br />(WebDAV) (RFC 4918 ) &#8211; The request failed due to failure of a previous request (e.g. a PROPPATCH).</dd>
<dt><a id="code-425" title="Unordered Collection">425 Unordered Collection</a> </dt>
<dd><a href="/e/425/" rel="nofollow" title="ErrorDocument 425" >ErrorDocument Unordered Collection</a>  |  <a href="#status-425" rel="nofollow"  title="Sample Unordered Collection">Sample 425 Unordered Collection</a> <br />Defined in drafts of WebDav Advanced Collections, but not present in &#8220;Web Distributed Authoring and Versioning (WebDAV) Ordered Collections   Protocol&#8221; (RFC 3648).</dd>
<dt><a id="code-426" title="Upgrade Required">426 Upgrade Required</a> </dt>
<dd><a href="/e/426/" rel="nofollow" title="ErrorDocument 426" >ErrorDocument Upgrade Required</a>  |  <a href="#status-426" rel="nofollow"  title="Sample Upgrade Required">Sample 426 Upgrade Required</a> <br />(RFC 2817 ) &#8211; The client should switch to TLS/1.0.</dd>
<dt><a id="code-449" title="Retry With">449 Retry With</a> </dt>
<dd><a href="/e/449/" rel="nofollow" title="ErrorDocument 449" >ErrorDocument Retry With</a>  |  <a href="#status-449" rel="nofollow"  title="Sample Retry With">Sample 449 Retry With</a> <br />A Microsoft extension. The request should be retried after doing the appropriate action.</dd>
<dt><a id="code-500" title="Internal Server Error">500 Internal Server Error</a> </dt>
<dd><a href="/e/500/" rel="nofollow" title="ErrorDocument 500" >ErrorDocument Internal Server Error</a>  |  <a href="#status-500" rel="nofollow"  title="Sample Internal Server Error">Sample 500 Internal Server Error</a> <br />A generic error message, given when no more specific message is suitable.</dd>
<dt><a id="code-501" title="Not Implemented">501 Not Implemented</a> </dt>
<dd><a href="/e/501/" rel="nofollow" title="ErrorDocument 501" >ErrorDocument Not Implemented</a>  |  <a href="#status-501" rel="nofollow"  title="Sample Not Implemented">Sample 501 Not Implemented</a> <br />The server either does not recognise the request method, or it lacks the ability to fulfil the request.</dd>
<dt><a id="code-502" title="Bad Gateway">502 Bad Gateway</a> </dt>
<dd><a href="/e/502/" rel="nofollow" title="ErrorDocument 502" >ErrorDocument Bad Gateway</a>  |  <a href="#status-502" rel="nofollow"  title="Sample Bad Gateway">Sample 502 Bad Gateway</a> <br />The server was acting as a gateway or proxy and received an invalid response from the upstream server.</dd>
<dt><a id="code-503" title="Service Unavailable">503 Service Unavailable</a> </dt>
<dd><a href="/e/503/" rel="nofollow" title="ErrorDocument 503" >ErrorDocument Service Unavailable</a>  |  <a href="#status-503" rel="nofollow"  title="Sample Service Unavailable">Sample 503 Service Unavailable</a> <br />The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.</dd>
<dt><a id="code-504" title="Gateway Timeout">504 Gateway Timeout</a> </dt>
<dd><a href="/e/504/" rel="nofollow" title="ErrorDocument 504" >ErrorDocument Gateway Timeout</a>  |  <a href="#status-504" rel="nofollow"  title="Sample Gateway Timeout">Sample 504 Gateway Timeout</a> <br />The server was acting as a gateway or proxy and did not receive a timely request from the upstream server.</dd>
<dt><a id="code-505" title="HTTP Version Not Supported">505 HTTP Version Not Supported</a> </dt>
<dd><a href="/e/505/" rel="nofollow" title="ErrorDocument 505" >ErrorDocument HTTP Version Not Supported</a>  |  <a href="#status-505" rel="nofollow"  title="Sample HTTP Version Not Supported">Sample 505 HTTP Version Not Supported</a> <br />The server does not support the HTTP protocol version used in the request.</dd>
<dt><a id="code-506" title="Variant Also Negotiates">506 Variant Also Negotiates</a> </dt>
<dd><a href="/e/506/" rel="nofollow" title="ErrorDocument 506" >ErrorDocument Variant Also Negotiates</a>  |  <a href="#status-506" rel="nofollow"  title="Sample Variant Also Negotiates">Sample 506 Variant Also Negotiates</a> <br />(RFC 2295 ) &#8211; Transparent content negotiation for the request, results in a circular reference.</dd>
<dt><a id="code-507" title="Insufficient Storage">507 Insufficient Storage</a> </dt>
<dd><a href="/e/507/" rel="nofollow" title="ErrorDocument 507" >ErrorDocument Insufficient Storage</a>  |  <a href="#status-507" rel="nofollow"  title="Sample Insufficient Storage">Sample 507 Insufficient Storage</a> <br />(WebDAV) (RFC 4918 )</dd>
<dt><a id="code-509" title="Bandwidth Limit Exceeded">509 Bandwidth Limit Exceeded</a> </dt>
<dd><a href="/e/509/" rel="nofollow" title="ErrorDocument 509" >ErrorDocument Bandwidth Limit Exceeded</a>  |  <a href="#status-509" rel="nofollow"  title="Sample Bandwidth Limit Exceeded">Sample 509 Bandwidth Limit Exceeded</a> <br />(Apache bw/limited extension) &#8211; This status code, while used by many servers, is not specified in any RFCs.</dd>
<dt><a id="code-510" title="Not Extended">510 Not Extended</a> </dt>
<dd><a href="/e/510/" rel="nofollow" title="ErrorDocument 510" >ErrorDocument Not Extended</a>  |  <a href="#status-510" rel="nofollow"  title="Sample Not Extended">Sample 510 Not Extended</a> <br />(RFC 2774 ) &#8211; Further extensions to the request are required for the server to fulfil it.</dd>
</dl>
<h3>1xx Info / Informational</h3>
<p><code>HTTP_INFO</code> &#8211; <strong>Request received, continuing process</strong>. Indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.</p>
<ul>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#status-100" title="Continue">100</a>  <a href="/e/100/" rel="nofollow" title="ErrorDocument 100" >Continue</a>  &#8211; <code>HTTP_CONTINUE</code></li>
<li> <a href="#status-101" rel="nofollow"  title="Switching Protocols">101</a>  <a href="/e/101/" rel="nofollow" title="ErrorDocument 101" >Switching Protocols</a>  &#8211; <code>HTTP_SWITCHING_PROTOCOLS</code></li>
<li> <a href="#status-102" rel="nofollow"  title="Processing">102</a>  <a href="/e/102/" rel="nofollow" title="ErrorDocument 102" >Processing</a>  &#8211; <code>HTTP_PROCESSING</code></li>
</ul>
<h3>2xx Success / OK</h3>
<p><code>HTTP_SUCCESS</code> &#8211; <strong>The action was successfully received, understood, and accepted</strong>.  Indicates that the client&#8217;s request was successfully received, understood, and accepted.</p>
<ul>
<li> <a href="#status-200" rel="nofollow"  title="OK">200</a>  <a href="/e/200/" rel="nofollow" title="ErrorDocument 200" >OK</a>  &#8211; <code>HTTP_OK</code></li>
<li> <a href="#status-201" rel="nofollow"  title="Created">201</a>  <a href="/e/201/" rel="nofollow" title="ErrorDocument 201" >Created</a>  &#8211; <code>HTTP_CREATED</code></li>
<li> <a href="#status-202" rel="nofollow"  title="Accepted">202</a>  <a href="/e/202/" rel="nofollow" title="ErrorDocument 202" >Accepted</a>  &#8211; <code>HTTP_ACCEPTED</code></li>
<li> <a href="#status-203" rel="nofollow"  title="Non-Authoritative Information">203</a>  <a href="/e/203/" rel="nofollow" title="ErrorDocument 203" >Non-Authoritative Information</a>  &#8211; <code>HTTP_NON_AUTHORITATIVE</code></li>
<li> <a href="#status-204" rel="nofollow"  title="No Content">204</a>  <a href="/e/204/" rel="nofollow" title="ErrorDocument 204" >No Content</a>  &#8211; <code>HTTP_NO_CONTENT</code></li>
<li> <a href="#status-205" rel="nofollow"  title="Reset Content">205</a>  <a href="/e/205/" rel="nofollow" title="ErrorDocument 205" >Reset Content</a>  &#8211; <code>HTTP_RESET_CONTENT</code></li>
<li> <a href="#status-206" rel="nofollow"  title="Partial Content">206</a>  <a href="/e/206/" rel="nofollow" title="ErrorDocument 206" >Partial Content</a>  &#8211; <code>HTTP_PARTIAL_CONTENT</code></li>
<li> <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#status-207" title="Multi-Status">207</a>  <a href="/e/207/" rel="nofollow" title="ErrorDocument 207" >Multi-Status</a>  &#8211; <code>HTTP_MULTI_STATUS</code></li>
</ul>
<h3>3xx Redirect</h3>
<p><code>HTTP_REDIRECT</code> &#8211; <strong>The client must take additional action to complete the request</strong>.  Indicates that further action needs to be taken by the user-agent in order to fulfill the request. The action required may be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A user agent should not automatically <em>redirect a request more than 5 times</em>, since such redirections usually indicate an <strong>infinite loop</strong>.</p>
<ul>
<li> <a href="#status-300" rel="nofollow"  title="Multiple Choices">300</a>  <a href="/e/300/" rel="nofollow" title="ErrorDocument 300" >Multiple Choices</a>  &#8211; <code>HTTP_MULTIPLE_CHOICES</code></li>
<li> <a href="#status-301" rel="nofollow"  title="Moved Permanently">301</a>  <a href="/e/301/" rel="nofollow" title="ErrorDocument 301" >Moved Permanently</a>  &#8211; <code>HTTP_MOVED_PERMANENTLY</code></li>
<li> <a href="#status-302" rel="nofollow"  title="Found">302</a>  <a href="/e/302/" rel="nofollow" title="ErrorDocument 302" >Found</a>  &#8211; <code>HTTP_MOVED_TEMPORARILY</code></li>
<li> <a href="#status-303" rel="nofollow"  title="See Other">303</a>  <a href="/e/303/" rel="nofollow" title="ErrorDocument 303" >See Other</a>  &#8211; <code>HTTP_SEE_OTHER</code></li>
<li> <a href="#status-304" rel="nofollow"  title="Not Modified">304</a>  <a href="/e/304/" rel="nofollow" title="ErrorDocument 304" >Not Modified</a>  &#8211; <code>HTTP_NOT_MODIFIED</code></li>
<li> <a href="#status-305" rel="nofollow"  title="Use Proxy">305</a>  <a href="/e/305/" rel="nofollow" title="ErrorDocument 305" >Use Proxy</a>  &#8211; <code>HTTP_USE_PROXY</code></li>
<li> <a href="#status-306" rel="nofollow"  title="unused">306</a>  <a href="/e/306/" rel="nofollow" title="ErrorDocument 306" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-307" rel="nofollow"  title="Temporary Redirect">307</a>  <a href="/e/307/" rel="nofollow" title="ErrorDocument 307" >Temporary Redirect</a>  &#8211; <code>HTTP_TEMPORARY_REDIRECT</code></li>
</ul>
<h3>4xx Client Error</h3>
<p><code>HTTP_CLIENT_ERROR</code> &#8211; <strong>The request contains bad syntax or cannot be fulfilled</strong>.  Indicates case where client seems to have erred. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition.</p>
<ul>
<li> <a href="#status-400" rel="nofollow"  title="Bad Request">400</a>  <a href="/e/400/" rel="nofollow" title="ErrorDocument 400" >Bad Request</a>  &#8211; <code>HTTP_BAD_REQUEST</code></li>
<li> <a href="#status-401" rel="nofollow"  title="Authorization Required">401</a>  <a href="/e/401/" rel="nofollow" title="ErrorDocument 401" >Authorization Required</a>  &#8211; <code>HTTP_UNAUTHORIZED</code></li>
<li> <a href="#status-402" rel="nofollow"  title="Payment Required">402</a>  <a href="/e/402/" rel="nofollow" title="ErrorDocument 402" >Payment Required</a>  &#8211; <code>HTTP_PAYMENT_REQUIRED</code></li>
<li> <a href="#status-403" rel="nofollow"  title="Forbidden">403</a>  <a href="/e/403/" rel="nofollow" title="ErrorDocument 403" >Forbidden</a>  &#8211; <code>HTTP_FORBIDDEN</code></li>
<li> <a href="#status-404" rel="nofollow"  title="Not Found">404</a>  <a href="/e/404/" rel="nofollow" title="ErrorDocument 404" >Not Found</a>  &#8211; <code>HTTP_NOT_FOUND</code></li>
<li> <a href="#status-405" rel="nofollow"  title="Method Not Allowed">405</a>  <a href="/e/405/" rel="nofollow" title="ErrorDocument 405" >Method Not Allowed</a>  &#8211; <code>HTTP_METHOD_NOT_ALLOWED</code></li>
<li> <a href="#status-406" rel="nofollow"  title="Not Acceptable">406</a>  <a href="/e/406/" rel="nofollow" title="ErrorDocument 406" >Not Acceptable</a>  &#8211; <code>HTTP_NOT_ACCEPTABLE</code></li>
<li> <a href="#status-407" rel="nofollow"  title="Proxy Authentication Required">407</a>  <a href="/e/407/" rel="nofollow" title="ErrorDocument 407" >Proxy Authentication Required</a>  &#8211; <code>HTTP_PROXY_AUTHENTICATION_REQUIRED</code></li>
<li> <a href="#status-408" rel="nofollow"  title="Request Time-out">408</a>  <a href="/e/408/" rel="nofollow" title="ErrorDocument 408" >Request Time-out</a>  &#8211; <code>HTTP_REQUEST_TIME_OUT</code></li>
<li> <a href="#status-409" rel="nofollow"  title="Conflict">409</a>  <a href="/e/409/" rel="nofollow" title="ErrorDocument 409" >Conflict</a>  &#8211; <code>HTTP_CONFLICT</code></li>
<li> <a href="#status-410" rel="nofollow"  title="Gone">410</a>  <a href="/e/410/" rel="nofollow" title="ErrorDocument 410" >Gone</a>  &#8211; <code>HTTP_GONE</code></li>
<li> <a href="#status-411" rel="nofollow"  title="Length Required">411</a>  <a href="/e/411/" rel="nofollow" title="ErrorDocument 411" >Length Required</a>  &#8211; <code>HTTP_LENGTH_REQUIRED</code></li>
<li> <a href="#status-412" rel="nofollow"  title="Precondition Failed">412</a>  <a href="/e/412/" rel="nofollow" title="ErrorDocument 412" >Precondition Failed</a>  &#8211; <code>HTTP_PRECONDITION_FAILED</code></li>
<li> <a href="#status-413" rel="nofollow"  title="Request Entity Too Large">413</a>  <a href="/e/413/" rel="nofollow" title="ErrorDocument 413" >Request Entity Too Large</a>  &#8211; <code>HTTP_REQUEST_ENTITY_TOO_LARGE</code></li>
<li> <a href="#status-414" rel="nofollow"  title="Request-URI Too Large">414</a>  <a href="/e/414/" rel="nofollow" title="ErrorDocument 414" >Request-URI Too Large</a>  &#8211; <code>HTTP_REQUEST_URI_TOO_LARGE</code></li>
<li> <a href="#status-415" rel="nofollow"  title="Unsupported Media Type">415</a>  <a href="/e/415/" rel="nofollow" title="ErrorDocument 415" >Unsupported Media Type</a>  &#8211; <code>HTTP_UNSUPPORTED_MEDIA_TYPE</code></li>
<li> <a href="#status-416" rel="nofollow"  title="Requested Range Not Satisfiable">416</a>  <a href="/e/416/" rel="nofollow" title="ErrorDocument 416" >Requested Range Not Satisfiable</a>  &#8211; <code>HTTP_RANGE_NOT_SATISFIABLE</code></li>
<li> <a href="#status-417" rel="nofollow"  title="Expectation Failed">417</a>  <a href="/e/417/" rel="nofollow" title="ErrorDocument 417" >Expectation Failed</a>  &#8211; <code>HTTP_EXPECTATION_FAILED</code></li>
<li> <a href="#status-418" rel="nofollow"  title="Im a teapot">418</a>  <a href="/e/418/" rel="nofollow" title="ErrorDocument 418" >I&#8217;m a teapot</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-419" rel="nofollow"  title="unused">419</a>  <a href="/e/419/" rel="nofollow" title="ErrorDocument 419" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-420" rel="nofollow"  title="unused">420</a>  <a href="/e/420/" rel="nofollow" title="ErrorDocument 420" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-421" rel="nofollow"  title="unused">421</a>  <a href="/e/421/" rel="nofollow" title="ErrorDocument 421" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-422" rel="nofollow"  title="Unprocessable Entity">422</a>  <a href="/e/422/" rel="nofollow" title="ErrorDocument 422" >Unprocessable Entity</a>  &#8211; <code>HTTP_UNPROCESSABLE_ENTITY</code></li>
<li> <a href="#status-423" rel="nofollow"  title="Locked">423</a>  <a href="/e/423/" rel="nofollow" title="ErrorDocument 423" >Locked</a>  &#8211; <code>HTTP_LOCKED</code></li>
<li> <a href="#status-424" rel="nofollow"  title="Failed Dependency">424</a>  <a href="/e/424/" rel="nofollow" title="ErrorDocument 424" >Failed Dependency</a>  &#8211; <code>HTTP_FAILED_DEPENDENCY</code></li>
<li> <a href="#status-425" rel="nofollow"  title="No code">425</a>  <a href="/e/425/" rel="nofollow" title="ErrorDocument 425" >No code</a>  &#8211; <code>HTTP_NO_CODE</code></li>
<li> <a href="#status-426" rel="nofollow"  title="Upgrade Required">426</a>  <a href="/e/426/" rel="nofollow" title="ErrorDocument 426" >Upgrade Required</a>  &#8211; <code>HTTP_UPGRADE_REQUIRED</code></li>
</ul>
<h3>5xx Server Error</h3>
<p><code>HTTP_SERVER_ERROR</code> &#8211; <strong>The server failed to fulfill an apparently valid request</strong>.  Indicate cases in which the server is aware that it has erred or is incapable of performing the request. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. User agents should display any included entity to the user. These response codes are applicable to any request method.</p>
<ul>
<li> <a href="#status-500" rel="nofollow"  title="Internal Server Error">500</a>  <a href="/e/500/" rel="nofollow" title="ErrorDocument 500" >Internal Server Error</a>  &#8211; <code>HTTP_INTERNAL_SERVER_ERROR</code></li>
<li> <a href="#status-501" rel="nofollow"  title="Method Not Implemented">501</a>  <a href="/e/501/" rel="nofollow" title="ErrorDocument 501" >Method Not Implemented</a>  &#8211; <code>HTTP_NOT_IMPLEMENTED</code></li>
<li> <a href="#status-502" rel="nofollow"  title="Bad Gateway">502</a>  <a href="/e/502/" rel="nofollow" title="ErrorDocument 502" >Bad Gateway</a>  &#8211; <code>HTTP_BAD_GATEWAY</code></li>
<li> <a href="#status-503" rel="nofollow"  title="Service Temporarily Unavailable">503</a>  <a href="/e/503/" rel="nofollow" title="ErrorDocument 503" >Service Temporarily Unavailable</a>  &#8211; <code>HTTP_SERVICE_UNAVAILABLE</code></li>
<li> <a href="#status-504" rel="nofollow"  title="Gateway Time-out">504</a>  <a href="/e/504/" rel="nofollow" title="ErrorDocument 504" >Gateway Time-out</a>  &#8211; <code>HTTP_GATEWAY_TIME_OUT</code></li>
<li> <a href="#status-505" rel="nofollow"  title="HTTP Version Not Supported">505</a>  <a href="/e/505/" rel="nofollow" title="ErrorDocument 505" >HTTP Version Not Supported</a>  &#8211; <code>HTTP_VERSION_NOT_SUPPORTED</code></li>
<li> <a href="#status-506" rel="nofollow"  title="Variant Also Negotiates">506</a>  <a href="/e/506/" rel="nofollow" title="ErrorDocument 506" >Variant Also Negotiates</a>  &#8211; <code>HTTP_VARIANT_ALSO_VARIES</code></li>
<li> <a href="#status-507" rel="nofollow"  title="Insufficient Storage">507</a>  <a href="/e/507/" rel="nofollow" title="ErrorDocument 507" >Insufficient Storage</a>  &#8211; <code>HTTP_INSUFFICIENT_STORAGE</code></li>
<li> <a href="#status-508" rel="nofollow"  title="unused">508</a>  <a href="/e/508/" rel="nofollow" title="ErrorDocument 508" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-509" rel="nofollow"  title="unused">509</a>  <a href="/e/509/" rel="nofollow" title="ErrorDocument 509" >unused</a>  &#8211; <code>UNUSED</code></li>
<li> <a href="#status-510" rel="nofollow"  title="Not Extended">510</a>  <a href="/e/510/" rel="nofollow" title="ErrorDocument 510" >Not Extended</a>  &#8211; <code>HTTP_NOT_EXTENDED</code></li>
</ul>
<hr />
<h2> <a href="#quick-start" rel="nofollow"  name="quick-start" id="quick-start">Quick Start to triggering ErrorDocuments for each Status Code</a> </h2>
<p>Let start with a quick and easy example.  Add the following Redirect rules to your htaccess file, then open your browser and goto each url like <code>yoursite.com/e/400</code>. <em>Don&#8217;t create an /e/ directory or any files.</em></p>
<pre>Redirect 400 /e/400
Redirect 503 /e/503
Redirect 405 /e/405</pre>
<p> <a href="http://uploads.askapache.com/2007/03/error-400s.png" rel="nofollow"  title="Apache ErrorDocument Results" rel="lb"><img src="http://uploads.askapache.com/2007/03/error-400s.thumbnail.png" alt="Apache ErrorDocument Results" title="error 400s.thumbnail apache" /></a> <br /> <a href="http://uploads.askapache.com/2007/03/error-503.png" rel="nofollow"  title="error 503" rel="lb"><img src="http://uploads.askapache.com/2007/03/error-503.thumbnail.png" alt="error 503" title="error 503.thumbnail apache" /></a> </p>
<h2> <a href="#automating-the-process" rel="nofollow"  name="automating-the-process" id="automating-the-process">Automate the ErrorDocument Triggering</a> </h2>
<h3> <a href="#redirect-code-in-htaccess" rel="nofollow"  name="redirect-code-in-htaccess" id="redirect-code-in-htaccess">The htaccess Redirects</a> </h3>
<p>When a Status code is encountered, Apache outputs the Header and the ErrorDocument for that error code.  So you can view any Header and the default ErrorDocument, by causing that numerical error code, which is caused by the Status Code.</p>
<p>For instance, if you request a file that doesn&#8217;t exist, a <strong>404 Not Found</strong> Header is issued and the corresponding ErrorDocument is served with the <strong>404 Not Found</strong> Header.</p>
<pre>Redirect 100 /e/100
Redirect 101 /e/101
Redirect 102 /e/102
Redirect 200 /e/200
Redirect 201 /e/201
Redirect 202 /e/202
Redirect 203 /e/203
Redirect 204 /e/204
Redirect 205 /e/205
Redirect 206 /e/206
Redirect 207 /e/207
Redirect 300 /e/300 http://www.askapache.com/?s=300
Redirect 301 /e/301 http://www.askapache.com/?s=301
Redirect 302 /e/302 http://www.askapache.com/?s=302
Redirect 303 /e/303 http://www.askapache.com/?s=303
Redirect 304 /e/304 http://www.askapache.com/?s=304
Redirect 305 /e/305 http://www.askapache.com/?s=305
Redirect 306 /e/306 http://www.askapache.com/?s=306
Redirect 307 /e/307 http://www.askapache.com/?s=307
Redirect 400 /e/400
Redirect 401 /e/401
Redirect 402 /e/402
Redirect 403 /e/403
Redirect 404 /e/404
Redirect 405 /e/405
Redirect 406 /e/406
Redirect 407 /e/407
Redirect 408 /e/408
Redirect 409 /e/409
Redirect 410 /e/410
Redirect 411 /e/411
Redirect 412 /e/412
Redirect 413 /e/413
Redirect 414 /e/414
Redirect 415 /e/415
Redirect 416 /e/416
Redirect 417 /e/417
Redirect 418 /e/418
Redirect 419 /e/419
Redirect 420 /e/420
Redirect 421 /e/421
Redirect 422 /e/422
Redirect 423 /e/423
Redirect 424 /e/424
Redirect 425 /e/425
Redirect 426 /e/426
Redirect 500 /e/500
Redirect 501 /e/501
Redirect 502 /e/502
Redirect 503 /e/503
Redirect 504 /e/504
Redirect 505 /e/505
Redirect 506 /e/506
Redirect 507 /e/507
Redirect 508 /e/508
Redirect 509 /e/509
Redirect 510 /e/510</pre>
<h3> <a href="#php-header-grabber-script" rel="nofollow"  name="php-header-grabber-script" id="php-header-grabber-script">PHP script that gets and outputs the Headers/Content</a> </h3>
<p>Now all I have to do is add 57 Redirect Directives to my htaccess, and then request each of them 1 at a time from my browser to see the result, and use a packet sniffing program like  <a href="http://wireshark.askapache.com" rel="nofollow" >WireShark</a>  to see the Headers.  Uh, scratch that, that would take way too long!</p>
<p>Instead I hacked up a simple php script using  <a href="http://www.askapache.com/phpbb/sending-post-form-data-with-php-curl.html">cURL</a>  to automate sending GET Requests to each of the 57 Redirect URL-paths. A side benefit of using the php script is that it performs all 57 Requests concurrently and saves each Requests returned headers and content to an output buffer.  After all 57 have been queried, the output buffer is flushed to the browser.</p>
<pre>&lt;?php
$SITENAME=&#039;http://www.askapache.com&#039;;
&nbsp;
$CODES = array(array(&#039;100&#039;,&#039;101&#039;,&#039;102&#039;),
array(&#039;200&#039;,&#039;201&#039;,&#039;202&#039;,&#039;203&#039;,&#039;204&#039;,&#039;205&#039;,&#039;206&#039;,&#039;207&#039;),
array(&#039;300&#039;,&#039;301&#039;,&#039;302&#039;,&#039;303&#039;,&#039;304&#039;,&#039;305&#039;,&#039;306&#039;,&#039;307&#039;),
array(&#039;400&#039;,&#039;401&#039;,&#039;402&#039;,&#039;403&#039;,&#039;404&#039;,&#039;405&#039;,&#039;406&#039;,&#039;407&#039;,&#039;408&#039;,&#039;409&#039;,&#039;410&#039;,&#039;411&#039;,&#039;412&#039;,&#039;413&#039;,
&#039;414&#039;,&#039;415&#039;,&#039;416&#039;,&#039;417&#039;,&#039;418&#039;,&#039;419&#039;,&#039;420&#039;,&#039;421&#039;,&#039;422&#039;,&#039;423&#039;,&#039;424&#039;,&#039;425&#039;,&#039;426&#039;),
array(&#039;500&#039;,&#039;501&#039;,&#039;502&#039;,&#039;503&#039;,&#039;504&#039;,&#039;505&#039;,&#039;506&#039;,&#039;507&#039;,&#039;508&#039;,&#039;509&#039;,&#039;510&#039;));
&nbsp;
$TMPSAVETO=&#039;/tmp/&#039;.time().&#039;.txt&#039;;
&nbsp;
# if file exists then delete it
if(is_file($TMPSAVETO))unlink($TMPSAVETO);
&nbsp;
foreach($CODES as $keyd =&gt; $res)
{
foreach($res as $key)
{
$ch = curl_init(&quot;$SITENAME/e/$key&quot;);
$fp = fopen ($TMPSAVETO, &quot;a&quot;);
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt ($ch, CURLOPT_HEADER ,1);
curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
}
}
$OUT=&#039;&#039;;
ob_start();
header (&quot;Content-Type: text/plain;&quot;);
readfile($TMPSAVETO);
$OUT=ob_get_clean();
echo $OUT;
unlink($TMPSAVETO);
exit;
?&gt;</pre>
<h2> <a href="#headers-returned-content" rel="nofollow"  id="headers-returned-content">Headers and Content Returned</a> </h2>
<h3> <a href="#status-100" rel="nofollow"  name="status-100" id="status-100">100 Continue</a> </h3>
<pre>HTTP/1.1 100 Continue
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;100 Continue&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Continue&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-101" rel="nofollow"  name="status-101" id="status-101">101 Switching Protocols</a> </h3>
<pre>HTTP/1.1 101 Switching Protocols&lt;html&gt;
&lt;head&gt;
&lt;title&gt;101 Switching Protocols&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Switching Protocols&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-102" rel="nofollow"  name="status-102" id="status-102">102 Processing</a> </h3>
<pre>HTTP/1.1 102 Processing
X-Pad: avoid browser bug&lt;html&gt;
&lt;head&gt;
&lt;title&gt;102 Processing&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Processing&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-200" rel="nofollow"  name="status-200" id="status-200">200 OK</a> </h3>
<pre>HTTP/1.1 200 OK
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;200 OK&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;OK&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-201" rel="nofollow"  name="status-201" id="status-201">201 Created</a> </h3>
<pre>HTTP/1.1 201 Created
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;201 Created&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Created&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-202" rel="nofollow"  name="status-202" id="status-202">202 Accepted</a> </h3>
<pre>HTTP/1.1 202 Accepted
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;202 Accepted&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Accepted&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-203" rel="nofollow"  name="status-203" id="status-203">203 Non-Authoritative Information</a> </h3>
<pre>HTTP/1.1 203 Non-Authoritative Information
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;203 Non-Authoritative Information&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Non-Authoritative Information&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-204" rel="nofollow"  name="status-204" id="status-204">204 No Content</a> </h3>
<pre>HTTP/1.1 204 No Content
Content-Type: text/plain; charset=UTF-8
&nbsp;</pre>
<h3> <a href="#status-205" rel="nofollow"  name="status-205" id="status-205">205 Reset Content</a> </h3>
<pre>HTTP/1.1 205 Reset Content&lt;html&gt;
&lt;head&gt;
&lt;title&gt;205 Reset Content&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Reset Content&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-206" rel="nofollow"  name="status-206" id="status-206">206 Partial Content</a> </h3>
<pre>HTTP/1.1 206 Partial Content&lt;html&gt;
&lt;head&gt;
&lt;title&gt;206 Partial Content&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Partial Content&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-207" rel="nofollow"  name="status-207" id="status-207">207 Multi-Status</a> </h3>
<pre>HTTP/1.1 207 Multi-Status
X-Pad: avoid browser bug&lt;html&gt;
&lt;head&gt;
&lt;title&gt;207 Multi-Status&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Multi-Status&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-300" rel="nofollow"  name="status-300" id="status-300">300 Multiple Choices</a> </h3>
<pre>HTTP/1.1 300 Multiple Choices
Location: http://www.askapache.com/?s=300&lt;html&gt;
&lt;head&gt;
&lt;title&gt;300 Multiple Choices&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Multiple Choices&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-301" rel="nofollow"  name="status-301" id="status-301">301 Moved Permanently</a> </h3>
<pre>HTTP/1.1 301 Moved Permanently
Location: http://www.askapache.com/?s=301&lt;html&gt;
&lt;head&gt;
&lt;title&gt;301 Moved Permanently&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Moved Permanently&lt;/h1&gt;
&lt;p&gt;The document has moved  &lt;a href=&quot;http://www.askapache.com/?s=301&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-302" rel="nofollow"  name="status-302" id="status-302">302 Found</a> </h3>
<pre>HTTP/1.1 302 Found
Location: http://www.askapache.com/?s=302&lt;html&gt;
&lt;head&gt;
&lt;title&gt;302 Found&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Found&lt;/h1&gt;
&lt;p&gt;The document has moved  &lt;a href=&quot;http://www.askapache.com/?s=302&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-303" rel="nofollow"  name="status-303" id="status-303">303 See Other</a> </h3>
<pre>HTTP/1.1 303 See Other
Location: http://www.askapache.com/?s=303&lt;html&gt;
&lt;head&gt;
&lt;title&gt;303 See Other&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;See Other&lt;/h1&gt;
&lt;p&gt;The answer to your request is located  &lt;a href=&quot;http://www.askapache.com/?s=303&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-304" rel="nofollow"  name="status-304" id="status-304">304 Not Modified</a> </h3>
<pre>HTTP/1.1 304 Not Modified</pre>
<h3> <a href="#status-305" rel="nofollow"  name="status-305" id="status-305">305 Use Proxy</a> </h3>
<pre>HTTP/1.1 305 Use Proxy
Location: http://www.askapache.com/?s=305&lt;html&gt;
&lt;head&gt;
&lt;title&gt;305 Use Proxy&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Use Proxy&lt;/h1&gt;
&lt;p&gt;This resource is only accessible through the proxy
    http://www.askapache.com/?s=305&lt;br /&gt;You will need to configure your client to use that proxy.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-306" rel="nofollow"  name="status-306" id="status-306">306 unused</a> </h3>
<pre>HTTP/1.1 306 unused
Location: http://www.askapache.com/?s=306&lt;html&gt;
&lt;head&gt;
&lt;title&gt;306 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-307" rel="nofollow"  name="status-307" id="status-307">307 Temporary Redirect</a> </h3>
<pre>HTTP/1.1 307 Temporary Redirect
Location: http://www.askapache.com/?s=307&lt;html&gt;
&lt;head&gt;
&lt;title&gt;307 Temporary Redirect&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Temporary Redirect&lt;/h1&gt;
&lt;p&gt;The document has moved  &lt;a href=&quot;http://www.askapache.com/?s=307&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-400" rel="nofollow"  name="status-400" id="status-400">400 Bad Request</a> </h3>
<pre>HTTP/1.1 400 Bad Request
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;400 Bad Request&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Bad Request&lt;/h1&gt;
&lt;p&gt;Your browser sent a request that this server could not understand.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-401" rel="nofollow"  name="status-401" id="status-401">401 Authorization Required</a> </h3>
<pre>HTTP/1.1 401 Authorization Required&lt;html&gt;
&lt;head&gt;
&lt;title&gt;401 Authorization Required&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Authorization Required&lt;/h1&gt;
&lt;p&gt;This server could not verify that you
    are authorized to access the document
    requested.  Either you supplied the wrong
    credentials (e.g., bad password), or your
    browser doesn&#039;t understand how to supply
    the credentials required.&lt;/p&gt;
&lt;p&gt;Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-402" rel="nofollow"  name="status-402" id="status-402">402 Payment Required</a> </h3>
<pre>HTTP/1.1 402 Payment Required&lt;html&gt;
&lt;head&gt;
&lt;title&gt;402 Payment Required&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Payment Required&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-403" rel="nofollow"  name="status-403" id="status-403">403 Forbidden</a> </h3>
<pre>HTTP/1.1 403 Forbidden&lt;html&gt;
&lt;head&gt;
&lt;title&gt;403 Forbidden&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Forbidden&lt;/h1&gt;
&lt;p&gt;You don&#039;t have permission to access /e/403
    on this server.&lt;/p&gt;
&lt;p&gt;Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-404" rel="nofollow"  name="status-404" id="status-404">404 Not Found</a> </h3>
<pre>HTTP/1.1 404 Not Found&lt;html&gt;
&lt;head&gt;
&lt;title&gt;404 Not Found&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Not Found&lt;/h1&gt;
&lt;p&gt;The requested URL /e/404 was not found on this server.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p class="anote"><span>NOTE:</span><br />You will most definately want to check out and use the <a href="http://www.askapache.com/seo/404-google-wordpress-plugin.html" title="404 Error Page WordPress Plugin">Google 404 Error Page</a> if you run WordPress.</p>
<h3> <a href="#status-405" rel="nofollow"  name="status-405" id="status-405">405 Method Not Allowed</a> </h3>
<pre>HTTP/1.1 405 Method Not Allowed
Allow: TRACE
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;405 Method Not Allowed&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Method Not Allowed&lt;/h1&gt;
&lt;p&gt;The requested method GET is not allowed for the URL /e/405.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-406" rel="nofollow"  name="status-406" id="status-406">406 Not Acceptable</a> </h3>
<pre>HTTP/1.1 406 Not Acceptable
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;406 Not Acceptable&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Not Acceptable&lt;/h1&gt;
&lt;p&gt;An appropriate representation of the requested resource /e/406 could not be found on this server.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-407" rel="nofollow"  name="status-407" id="status-407">407 Proxy Authentication Required</a> </h3>
<pre>HTTP/1.1 407 Proxy Authentication Required&lt;html&gt;
&lt;head&gt;
&lt;title&gt;407 Proxy Authentication Required&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Proxy Authentication Required&lt;/h1&gt;
&lt;p&gt;This server could not verify that you
    are authorized to access the document
    requested.  Either you supplied the wrong
    credentials (e.g., bad password), or your
    browser doesn&#039;t understand how to supply
    the credentials required.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-408" rel="nofollow"  name="status-408" id="status-408">408 Request Time-out</a> </h3>
<pre>HTTP/1.1 408 Request Time-out
Connection: close
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;408 Request Time-out&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Request Time-out&lt;/h1&gt;
&lt;p&gt;Server timeout waiting for the HTTP request from the client.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-409" rel="nofollow"  name="status-409" id="status-409">409 Conflict</a> </h3>
<pre>HTTP/1.1 409 Conflict
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;409 Conflict&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Conflict&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-410" rel="nofollow"  name="status-410" id="status-410">410 Gone</a> </h3>
<pre>HTTP/1.1 410 Gone
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;410 Gone&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Gone&lt;/h1&gt;
&lt;p&gt;The requested resource&lt;br /&gt;/e/410&lt;br /&gt;is no longer available on this server and there is no forwarding address.
    Please remove all references to this resource.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-411" rel="nofollow"  name="status-411" id="status-411">411 Length Required</a> </h3>
<pre>HTTP/1.1 411 Length Required
Connection: close
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;411 Length Required&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Length Required&lt;/h1&gt;
&lt;p&gt;A request of the requested method GET requires a valid Content-length.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-412" rel="nofollow"  name="status-412" id="status-412">412 Precondition Failed</a> </h3>
<pre>HTTP/1.1 412 Precondition Failed
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;412 Precondition Failed&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Precondition Failed&lt;/h1&gt;
&lt;p&gt;The precondition on the request for the URL /e/412 evaluated to false.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-413" rel="nofollow"  name="status-413" id="status-413">413 Request Entity Too Large</a> </h3>
<pre>HTTP/1.1 413 Request Entity Too Large
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;413 Request Entity Too Large&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Request Entity Too Large&lt;/h1&gt;
The requested resource&lt;br /&gt;/e/413&lt;br /&gt;does not allow request data with GET requests, or the amount of data provided in
the request exceeds the capacity limit.
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-414" rel="nofollow"  name="status-414" id="status-414">414 Request-URI Too Large</a> </h3>
<pre>HTTP/1.1 414 Request-URI Too Large
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;414 Request-URI Too Large&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Request-URI Too Large&lt;/h1&gt;
&lt;p&gt;The requested URL&#039;s length exceeds the capacity
    limit for this server.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-415" rel="nofollow"  name="status-415" id="status-415">415 Unsupported Media Type</a> </h3>
<pre>HTTP/1.1 415 Unsupported Media Type&lt;html&gt;
&lt;head&gt;
&lt;title&gt;415 Unsupported Media Type&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Unsupported Media Type&lt;/h1&gt;
&lt;p&gt;The supplied request data is not in a format
    acceptable for processing by this resource.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-416" rel="nofollow"  name="status-416" id="status-416">416 Requested Range Not Satisfiable</a> </h3>
<pre>HTTP/1.1 416 Requested Range Not Satisfiable</pre>
<h3> <a href="#status-417" rel="nofollow"  name="status-417" id="status-417">417 Expectation Failed</a> </h3>
<pre>HTTP/1.1 417 Expectation Failed&lt;html&gt;
&lt;head&gt;
&lt;title&gt;417 Expectation Failed&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Expectation Failed&lt;/h1&gt;
&lt;p&gt;The expectation given in the Expect request-header
    field could not be met by this server.&lt;/p&gt;
&lt;p&gt;The client sent&lt;pre&gt;
    Expect: &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-418" rel="nofollow"  name="status-418" id="status-418">418 I&#8217;m a teapot</a> </h3>
<pre>HTTP/1.1 418 I&#039;m a teapot&lt;html&gt;
&lt;head&gt;
&lt;title&gt;418 I&#039;m a teapot&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;I&#039;m a teapot&lt;/h1&gt;
&lt;p&gt;Unfortunately this coffee machine is out of coffee.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-419" rel="nofollow"  name="status-419" id="status-419">419 unused</a> </h3>
<pre>HTTP/1.1 419 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;419 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-420" rel="nofollow"  name="status-420" id="status-420">420 unused</a> </h3>
<pre>HTTP/1.1 420 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;420 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-421" rel="nofollow"  name="status-421" id="status-421">421 unused</a> </h3>
<pre>HTTP/1.1 421 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;421 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-422" rel="nofollow"  name="status-422" id="status-422">422 Unprocessable Entity</a> </h3>
<pre>HTTP/1.1 422 Unprocessable Entity&lt;html&gt;
&lt;head&gt;
&lt;title&gt;422 Unprocessable Entity&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Unprocessable Entity&lt;/h1&gt;
&lt;p&gt;The server understands the media type of the
    request entity, but was unable to process the
    contained instructions.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-423" rel="nofollow"  name="status-423" id="status-423">423 Locked</a> </h3>
<pre>HTTP/1.1 423 Locked&lt;html&gt;
&lt;head&gt;
&lt;title&gt;423 Locked&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Locked&lt;/h1&gt;
&lt;p&gt;The requested resource is currently locked.
    The lock must be released or proper identification
    given before the method can be applied.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-424" rel="nofollow"  name="status-424" id="status-424">424 Failed Dependency</a> </h3>
<pre>HTTP/1.1 424 Failed Dependency&lt;html&gt;
&lt;head&gt;
&lt;title&gt;424 Failed Dependency&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Failed Dependency&lt;/h1&gt;
&lt;p&gt;The method could not be performed on the resource
    because the requested action depended on another
    action and that other action failed.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-425" rel="nofollow"  name="status-425" id="status-425">425 No code</a> </h3>
<pre>HTTP/1.1 425 No code&lt;html&gt;
&lt;head&gt;
&lt;title&gt;425 No code&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;No code&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-426" rel="nofollow"  name="status-426" id="status-426">426 Upgrade Required</a> </h3>
<pre>HTTP/1.1 426 Upgrade Required&lt;html&gt;
&lt;head&gt;
&lt;title&gt;426 Upgrade Required&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Upgrade Required&lt;/h1&gt;
&lt;p&gt;The requested resource can only be retrieved
    using SSL.  The server is willing to upgrade the current
    connection to SSL, but your client doesn&#039;t support it.
    Either upgrade your client, or try requesting the page
    using https:// &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-500" rel="nofollow"  name="status-500" id="status-500">500 Internal Server Error</a> </h3>
<pre>HTTP/1.1 500 Internal Server Error
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;500 Internal Server Error&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Internal Server Error&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;p&gt;Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-501" rel="nofollow"  name="status-501" id="status-501">501 Method Not Implemented</a> </h3>
<pre>HTTP/1.1 501 Method Not Implemented
Allow: TRACE
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;501 Method Not Implemented&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Method Not Implemented&lt;/h1&gt;
&lt;p&gt;GET to /e/501 not supported.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-502" rel="nofollow"  name="status-502" id="status-502">502 Bad Gateway</a> </h3>
<pre>HTTP/1.1 502 Bad Gateway
X-Pad: avoid browser bug&lt;html&gt;
&lt;head&gt;
&lt;title&gt;502 Bad Gateway&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Bad Gateway&lt;/h1&gt;
&lt;p&gt;The proxy server received an invalid
    response from an upstream server.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-503" rel="nofollow"  name="status-503" id="status-503">503 Service Temporarily Unavailable</a> </h3>
<pre>HTTP/1.1 503 Service Temporarily Unavailable
Connection: close&lt;html&gt;
&lt;head&gt;
&lt;title&gt;503 Service Temporarily Unavailable&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Service Temporarily Unavailable&lt;/h1&gt;
&lt;p&gt;The server is temporarily unable to service your
    request due to maintenance downtime or capacity
    problems. Please try again later.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-504" rel="nofollow"  name="status-504" id="status-504">504 Gateway Time-out</a> </h3>
<pre>HTTP/1.1 504 Gateway Time-out&lt;html&gt;
&lt;head&gt;
&lt;title&gt;504 Gateway Time-out&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Gateway Time-out&lt;/h1&gt;
&lt;p&gt;The proxy server did not receive a timely response
    from the upstream server.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-505" rel="nofollow"  name="status-505" id="status-505">505 HTTP Version Not Supported</a> </h3>
<pre>HTTP/1.1 505 HTTP Version Not Supported&lt;html&gt;
&lt;head&gt;
&lt;title&gt;505 HTTP Version Not Supported&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;HTTP Version Not Supported&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-506" rel="nofollow"  name="status-506" id="status-506">506 Variant Also Negotiates</a> </h3>
<pre>HTTP/1.1 506 Variant Also Negotiates&lt;html&gt;
&lt;head&gt;
&lt;title&gt;506 Variant Also Negotiates&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Variant Also Negotiates&lt;/h1&gt;
&lt;p&gt;A variant for the requested resource
    &lt;pre&gt;
    /e/506
    &lt;/pre&gt;
    is itself a negotiable resource. This indicates a configuration error.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-507" rel="nofollow"  name="status-507" id="status-507">507 Insufficient Storage</a> </h3>
<pre>HTTP/1.1 507 Insufficient Storage&lt;html&gt;
&lt;head&gt;
&lt;title&gt;507 Insufficient Storage&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Insufficient Storage&lt;/h1&gt;
&lt;p&gt;The method could not be performed on the resource
    because the server is unable to store the
    representation needed to successfully complete the
    request.  There is insufficient free space left in
    your storage allocation.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-508" rel="nofollow"  name="status-508" id="status-508">508 unused</a> </h3>
<pre>HTTP/1.1 508 unused&lt;html&gt;
&lt;head&gt;
&lt;title&gt;508 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-509" rel="nofollow"  name="status-509" id="status-509">509 unused</a> </h3>
<pre>HTTP/1.1 509 unused
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;509 unused&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;unused&lt;/h1&gt;
&lt;p&gt;The server encountered an internal error or misconfigurationand was unable to complete your request.&lt;/p&gt;
&lt;p&gt;Please contact the server administrator, a@s.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt;
&lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h3> <a href="#status-510" rel="nofollow"  name="status-510" id="status-510">510 Not Extended</a> </h3>
<pre>HTTP/1.1 510 Not Extended
X-Pad: avoid browser bug
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;510 Not Extended&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Not Extended&lt;/h1&gt;
&lt;p&gt;A mandatory extension policy in the request is not
    accepted by the server for this resource.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h2> <a href="#apache-source-code" rel="nofollow"  name="apache-source-code" id="apache-source-code">Apache Source Code</a> </h2>
<h3> <a href="#httpdh-h" rel="nofollow"  name="httpdh-h" id="httpdh-h">httpd.h</a> </h3>
<p>From <a href="http://uploads.askapache.com/2007/02/httpd.h" rel="nofollow"  title="httpd.h Apache">httpd.h</a> </p>
<pre>/**
* The size of the static array in http_protocol.c for storing
* all of the potential response status-lines (a sparse table).
* A future version should dynamically generate the apr_table_t at startup.
*/
#define RESPONSE_CODES 57
#define HTTP_CONTINUE            100
#define HTTP_SWITCHING_PROTOCOLS       101
#define HTTP_PROCESSING          102
#define HTTP_OK              200
#define HTTP_CREATED             201
#define HTTP_ACCEPTED            202
#define HTTP_NON_AUTHORITATIVE       203
#define HTTP_NO_CONTENT          204
#define HTTP_RESET_CONTENT         205
#define HTTP_PARTIAL_CONTENT         206
#define HTTP_MULTI_STATUS          207
#define HTTP_MULTIPLE_CHOICES        300
#define HTTP_MOVED_PERMANENTLY       301
&nbsp;
#define HTTP_MOVED_TEMPORARILY       302
#define HTTP_SEE_OTHER           303
#define HTTP_NOT_MODIFIED          304
#define HTTP_USE_PROXY           305
#define HTTP_TEMPORARY_REDIRECT      307
#define HTTP_BAD_REQUEST           400
#define HTTP_UNAUTHORIZED          401
#define HTTP_PAYMENT_REQUIRED        402
#define HTTP_FORBIDDEN           403
#define HTTP_NOT_FOUND           404
#define HTTP_METHOD_NOT_ALLOWED      405
#define HTTP_NOT_ACCEPTABLE        406
#define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
#define HTTP_REQUEST_TIME_OUT        408
#define HTTP_CONFLICT            409
#define HTTP_GONE              410
#define HTTP_LENGTH_REQUIRED         411
#define HTTP_PRECONDITION_FAILED       412
#define HTTP_REQUEST_ENTITY_TOO_LARGE    413
#define HTTP_REQUEST_URI_TOO_LARGE     414
#define HTTP_UNSUPPORTED_MEDIA_TYPE    415
#define HTTP_RANGE_NOT_SATISFIABLE     416
#define HTTP_EXPECTATION_FAILED      417
#define HTTP_UNPROCESSABLE_ENTITY      422
#define HTTP_LOCKED            423
#define HTTP_FAILED_DEPENDENCY       424
#define HTTP_UPGRADE_REQUIRED        426
#define HTTP_INTERNAL_SERVER_ERROR     500
#define HTTP_NOT_IMPLEMENTED         501
#define HTTP_BAD_GATEWAY           502
#define HTTP_SERVICE_UNAVAILABLE       503
#define HTTP_GATEWAY_TIME_OUT        504
#define HTTP_VERSION_NOT_SUPPORTED     505
#define HTTP_VARIANT_ALSO_VARIES       506
#define HTTP_INSUFFICIENT_STORAGE      507
#define HTTP_NOT_EXTENDED          510
&nbsp;
/** is the status code informational */
#define ap_is_HTTP_INFO(x)     (((x) &gt;= 100)&amp;&amp;((x) &lt; 200))
/** is the status code OK ?*/
#define ap_is_HTTP_SUCCESS(x)    (((x) &gt;= 200)&amp;&amp;((x) &lt; 300))
/** is the status code a redirect */
#define ap_is_HTTP_REDIRECT(x)   (((x) &gt;= 300)&amp;&amp;((x) &lt; 400))
/** is the status code a error (client or server) */
#define ap_is_HTTP_ERROR(x)    (((x) &gt;= 400)&amp;&amp;((x) &lt; 600))
/** is the status code a client error  */
#define ap_is_HTTP_CLIENT_ERROR(x) (((x) &gt;= 400)&amp;&amp;((x) &lt; 500))
/** is the status code a server error  */
#define ap_is_HTTP_SERVER_ERROR(x) (((x) &gt;= 500)&amp;&amp;((x) &lt; 600))
/** is the status code a (potentially) valid response code?  */
#define ap_is_HTTP_VALID_RESPONSE(x) (((x) &gt;= 100)&amp;&amp;((x) &lt; 600))
&nbsp;
/** should the status code drop the connection */
#define ap_status_drops_connection(x) \
(((x) == HTTP_BAD_REQUEST)       || \
((x) == HTTP_REQUEST_TIME_OUT)    || \
((x) == HTTP_LENGTH_REQUIRED)     || \
((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
((x) == HTTP_INTERNAL_SERVER_ERROR) || \
((x) == HTTP_SERVICE_UNAVAILABLE) || \
((x) == HTTP_NOT_IMPLEMENTED))</pre>
<h4>HTTP_INFO</h4>
<p><strong>Is the status code (x) informational?</strong></p>
<pre>x &gt;= 100 &amp;&amp; x &lt; 200</pre>
<h4>HTTP_SUCCESS</h4>
<p><strong>Is the status code (x) OK?</strong></p>
<pre>x &gt;= 200 &amp;&amp; x &lt; 300</pre>
<h4>HTTP_REDIRECT</h4>
<p><strong>Is the status code (x) a redirect?</strong></p>
<pre>x &gt;= 300 &amp;&amp; x &lt; 400</pre>
<h4>HTTP_ERROR</h4>
<p><strong>Is the status code (x) a error (client or server)?</strong></p>
<pre>x &gt;= 400 &amp;&amp; x &lt; 600</pre>
<h4>HTTP_CLIENT_ERROR</h4>
<p><strong>Is the status code (x) a client error?</strong></p>
<pre>x &gt;= 400 &amp;&amp; x &lt; 500</pre>
<h4>HTTP_SERVER_ERROR</h4>
<p><strong>Is the status code (x) a server error?</strong></p>
<pre>x &gt;= 500 &amp;&amp; x &lt; 600</pre>
<h4>HTTP_VALID_RESPONSE</h4>
<p><strong>Is the status code (x) a (potentially) valid response code?</strong></p>
<pre>x &gt;= 100 &amp;&amp; x &lt; 600</pre>
<h3> <a href="#http_protocol-c" rel="nofollow"  name="http_protocol-c" id="http_protocol-c">http_protocol.c</a> </h3>
<p>From <a href="http://uploads.askapache.com/2007/02/http_protocol.c" rel="nofollow"  title="http_protocol.c">http_protocol.c</a> </p>
<pre>static const char * status_lines[RESPONSE_CODES] =
static const char * const status_lines[RESPONSE_CODES] =
&quot;100 Continue&quot;,
&quot;101 Switching Protocols&quot;,
&quot;102 Processing&quot;,
&quot;200 OK&quot;,
&quot;201 Created&quot;,
&quot;202 Accepted&quot;,
&quot;203 Non-Authoritative Information&quot;,
&quot;204 No Content&quot;,
&quot;205 Reset Content&quot;,
&quot;206 Partial Content&quot;,
&quot;207 Multi-Status&quot;,
&quot;300 Multiple Choices&quot;,
&quot;301 Moved Permanently&quot;,
&quot;302 Found&quot;,
&quot;303 See Other&quot;,
&quot;304 Not Modified&quot;,
&quot;305 Use Proxy&quot;,
&quot;306 unused&quot;,
&quot;307 Temporary Redirect&quot;,
&quot;400 Bad Request&quot;,
&quot;401 Authorization Required&quot;,
&quot;402 Payment Required&quot;,
&quot;403 Forbidden&quot;,
&quot;404 Not Found&quot;,
&quot;405 Method Not Allowed&quot;,
&quot;406 Not Acceptable&quot;,
&quot;407 Proxy Authentication Required&quot;,
&quot;408 Request Time-out&quot;,
&quot;409 Conflict&quot;,
&quot;410 Gone&quot;,
&quot;411 Length Required&quot;,
&quot;412 Precondition Failed&quot;,
&quot;413 Request Entity Too Large&quot;,
&quot;414 Request-URI Too Large&quot;,
&quot;415 Unsupported Media Type&quot;,
&quot;416 Requested Range Not Satisfiable&quot;,
&quot;417 Expectation Failed&quot;,
&quot;418 unused&quot;,
&quot;419 unused&quot;,
&quot;420 unused&quot;,
&quot;421 unused&quot;,
&quot;422 Unprocessable Entity&quot;,
&quot;423 Locked&quot;,
&quot;424 Failed Dependency&quot;,
&quot;425 No code&quot;,
&quot;426 Upgrade Required&quot;,
&quot;500 Internal Server Error&quot;,
&quot;501 Method Not Implemented&quot;,
&quot;502 Bad Gateway&quot;,
&quot;503 Service Temporarily Unavailable&quot;,
&quot;504 Gateway Time-out&quot;,
&quot;505 HTTP Version Not Supported&quot;,
&quot;506 Variant Also Negotiates&quot;,
&quot;507 Insufficient Storage&quot;,
&quot;508 unused&quot;,
&quot;509 unused&quot;,
&quot;510 Not Extended&quot;</pre>
<h2>IANA HTTP Status Code Registry</h2>
<table cellpadding="3" cellspacing="0">
<thead>
<tr>
<th>Value</th>
<th>Description</th>
<th>Reference</th>
</tr>
</thead>
<tbody>
<tr>
<td>100</td>
<td>Continue</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.1.1" rel="nofollow" >Section 10.1.1</a> </td>
</tr>
<tr>
<td>101</td>
<td>Switching Protocols</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.1.2" rel="nofollow" >Section 10.1.2</a> </td>
</tr>
<tr>
<td>102</td>
<td>Processing</td>
<td> <a href="#RFC2518" rel="nofollow" ><cite title="HTTP Extensions for Distributed Authoring -- WEBDAV">[RFC2518]</cite></a> , <a href="http://rfc.askapache.com/rfc2518#section-10.1" rel="nofollow" >Section 10.1</a> </td>
</tr>
<tr>
<td>200</td>
<td>OK</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.1" rel="nofollow" >Section 10.2.1</a> </td>
</tr>
<tr>
<td>201</td>
<td>Created</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.2" rel="nofollow" >Section 10.2.2</a> </td>
</tr>
<tr>
<td>202</td>
<td>Accepted</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.3" rel="nofollow" >Section 10.2.3</a> </td>
</tr>
<tr>
<td>203</td>
<td>Non-Authoritative Information</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.4" rel="nofollow" >Section 10.2.4</a> </td>
</tr>
<tr>
<td>204</td>
<td>No Content</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.5" rel="nofollow" >Section 10.2.5</a> </td>
</tr>
<tr>
<td>205</td>
<td>Reset Content</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.6" rel="nofollow" >Section 10.2.6</a> </td>
</tr>
<tr>
<td>206</td>
<td>Partial Content</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.2.7" rel="nofollow" >Section 10.2.7</a> </td>
</tr>
<tr>
<td>207</td>
<td>Multi-Status</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.1" rel="nofollow" >Section 11.1</a> </td>
</tr>
<tr>
<td>226</td>
<td>IM Used</td>
<td> <a href="#RFC3229" rel="nofollow" ><cite title="Delta encoding in HTTP">[RFC3229]</cite></a> , <a href="http://rfc.askapache.com/rfc3229#section-10.4.1" rel="nofollow" >Section 10.4.1</a> </td>
</tr>
<tr>
<td>300</td>
<td>Multiple Choices</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.1" rel="nofollow" >Section 10.3.1</a> </td>
</tr>
<tr>
<td>301</td>
<td>Moved Permanently</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.2" rel="nofollow" >Section 10.3.2</a> </td>
</tr>
<tr>
<td>302</td>
<td>Found</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.3" rel="nofollow" >Section 10.3.3</a> </td>
</tr>
<tr>
<td>303</td>
<td>See Other</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.4" rel="nofollow" >Section 10.3.4</a> </td>
</tr>
<tr>
<td>304</td>
<td>Not Modified</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.5" rel="nofollow" >Section 10.3.5</a> </td>
</tr>
<tr>
<td>305</td>
<td>Use Proxy</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.6" rel="nofollow" >Section 10.3.6</a> </td>
</tr>
<tr>
<td>306</td>
<td>(Reserved)</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.7" rel="nofollow" >Section 10.3.7</a> </td>
</tr>
<tr>
<td>307</td>
<td>Temporary Redirect</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.3.8" rel="nofollow" >Section 10.3.8</a> </td>
</tr>
<tr>
<td>400</td>
<td>Bad Request</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.1" rel="nofollow" >Section 10.4.1</a> </td>
</tr>
<tr>
<td>401</td>
<td>Unauthorized</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.2" rel="nofollow" >Section 10.4.2</a> </td>
</tr>
<tr>
<td>402</td>
<td>Payment Required</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.3" rel="nofollow" >Section 10.4.3</a> </td>
</tr>
<tr>
<td>403</td>
<td>Forbidden</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.4" rel="nofollow" >Section 10.4.4</a> </td>
</tr>
<tr>
<td>404</td>
<td>Not Found</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.5" rel="nofollow" >Section 10.4.5</a> </td>
</tr>
<tr>
<td>405</td>
<td>Method Not Allowed</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.6" rel="nofollow" >Section 10.4.6</a> </td>
</tr>
<tr>
<td>406</td>
<td>Not Acceptable</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.7" rel="nofollow" >Section 10.4.7</a> </td>
</tr>
<tr>
<td>407</td>
<td>Proxy Authentication Required</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.8" rel="nofollow" >Section 10.4.8</a> </td>
</tr>
<tr>
<td>408</td>
<td>Request Timeout</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.9" rel="nofollow" >Section 10.4.9</a> </td>
</tr>
<tr>
<td>409</td>
<td>Conflict</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.10" rel="nofollow" >Section 10.4.10</a> </td>
</tr>
<tr>
<td>410</td>
<td>Gone</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.11" rel="nofollow" >Section 10.4.11</a> </td>
</tr>
<tr>
<td>411</td>
<td>Length Required</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.12" rel="nofollow" >Section 10.4.12</a> </td>
</tr>
<tr>
<td>412</td>
<td>Precondition Failed</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.13" rel="nofollow" >Section 10.4.13</a> </td>
</tr>
<tr>
<td>413</td>
<td>Request Entity Too Large</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.14" rel="nofollow" >Section 10.4.14</a> </td>
</tr>
<tr>
<td>414</td>
<td>Request-URI Too Long</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.15" rel="nofollow" >Section 10.4.15</a> </td>
</tr>
<tr>
<td>415</td>
<td>Unsupported Media Type</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.16" rel="nofollow" >Section 10.4.16</a> </td>
</tr>
<tr>
<td>416</td>
<td>Requested Range Not Satisfiable</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.17" rel="nofollow" >Section 10.4.17</a> </td>
</tr>
<tr>
<td>417</td>
<td>Expectation Failed</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.4.18" rel="nofollow" >Section 10.4.18</a> </td>
</tr>
<tr>
<td>422</td>
<td>Unprocessable Entity</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.2" rel="nofollow" >Section 11.2</a> </td>
</tr>
<tr>
<td>423</td>
<td>Locked</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.3" rel="nofollow" >Section 11.3</a> </td>
</tr>
<tr>
<td>424</td>
<td>Failed Dependency</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.4" rel="nofollow" >Section 11.4</a> </td>
</tr>
<tr>
<td>426</td>
<td>Upgrade Required</td>
<td> <a href="#RFC2817" rel="nofollow" ><cite title="Upgrading to TLS Within HTTP/1.1">[RFC2817]</cite></a> , <a href="http://rfc.askapache.com/rfc2817#section-6" rel="nofollow" >Section 6</a> </td>
</tr>
<tr>
<td>500</td>
<td>Internal Server Error</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.1" rel="nofollow" >Section 10.5.1</a> </td>
</tr>
<tr>
<td>501</td>
<td>Not Implemented</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.2" rel="nofollow" >Section 10.5.2</a> </td>
</tr>
<tr>
<td>502</td>
<td>Bad Gateway</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.3" rel="nofollow" >Section 10.5.3</a> </td>
</tr>
<tr>
<td>503</td>
<td>Service Unavailable</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.4" rel="nofollow" >Section 10.5.4</a> </td>
</tr>
<tr>
<td>504</td>
<td>Gateway Timeout</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.5" rel="nofollow" >Section 10.5.5</a> </td>
</tr>
<tr>
<td>505</td>
<td>HTTP Version Not Supported</td>
<td> <a href="#RFC2616" rel="nofollow" ><cite title="Hypertext Transfer Protocol -- HTTP/1.1">[RFC2616]</cite></a> , <a href="http://rfc.askapache.com/rfc2616#section-10.5.6" rel="nofollow" >Section 10.5.6</a> </td>
</tr>
<tr>
<td>506</td>
<td>Variant Also Negotiates</td>
<td> <a href="#RFC2295" rel="nofollow" ><cite title="Transparent Content Negotiation in HTTP">[RFC2295]</cite></a> , <a href="http://rfc.askapache.com/rfc2295#section-8.1" rel="nofollow" >Section 8.1</a> </td>
</tr>
<tr>
<td>507</td>
<td>Insufficient Storage</td>
<td> <a href="#RFC4918" rel="nofollow" ><cite title="HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)">[RFC4918]</cite></a> , <a href="http://rfc.askapache.com/rfc4918#section-11.5" rel="nofollow" >Section 11.5</a> </td>
</tr>
<tr>
<td>510</td>
<td>Not Extended</td>
<td> <a href="#RFC2774" rel="nofollow" ><cite title="An HTTP Extension Framework">[RFC2774]</cite></a> , <a href="http://rfc.askapache.com/rfc2774#section-7" rel="nofollow" >Section 7</a> </td>
</tr>
</tbody>
</table>
<h2>WordPress 2.8 Changes</h2>
<p>I just learned that <a href="https://core.trac.wordpress.org/ticket/9297" rel="nofollow" >my modification</a> to the WordPress core was <a href="https://core.trac.wordpress.org/changeset/10740" rel="nofollow" >accepted</a> and will be implemented for version 2.8!  This may mean WordPress is the only 100% HTTP/1.1 compliant software on the net!  Below is the new list (<em>I thought someone out there could use the php array</em>) and as you can see, unfortunately<strong>418 I&#8217;m a teapot</strong>didn&#8217;t make it ;)</p>
<pre>$wp_header_to_desc = array(
  100 =&gt; &#039;Continue&#039;,
  101 =&gt; &#039;Switching Protocols&#039;,
  102 =&gt; &#039;Processing&#039;,
&nbsp;
  200 =&gt; &#039;OK&#039;,
  201 =&gt; &#039;Created&#039;,
  202 =&gt; &#039;Accepted&#039;,
  203 =&gt; &#039;Non-Authoritative Information&#039;,
  204 =&gt; &#039;No Content&#039;,
  205 =&gt; &#039;Reset Content&#039;,
  206 =&gt; &#039;Partial Content&#039;,
  207 =&gt; &#039;Multi-Status&#039;,
  226 =&gt; &#039;IM Used&#039;,
&nbsp;
  300 =&gt; &#039;Multiple Choices&#039;,
  301 =&gt; &#039;Moved Permanently&#039;,
  302 =&gt; &#039;Found&#039;,
  303 =&gt; &#039;See Other&#039;,
  304 =&gt; &#039;Not Modified&#039;,
  305 =&gt; &#039;Use Proxy&#039;,
  306 =&gt; &#039;Reserved&#039;,
  307 =&gt; &#039;Temporary Redirect&#039;,
&nbsp;
  400 =&gt; &#039;Bad Request&#039;,
  401 =&gt; &#039;Unauthorized&#039;,
  402 =&gt; &#039;Payment Required&#039;,
  403 =&gt; &#039;Forbidden&#039;,
  404 =&gt; &#039;Not Found&#039;,
  405 =&gt; &#039;Method Not Allowed&#039;,
  406 =&gt; &#039;Not Acceptable&#039;,
  407 =&gt; &#039;Proxy Authentication Required&#039;,
  408 =&gt; &#039;Request Timeout&#039;,
  409 =&gt; &#039;Conflict&#039;,
  410 =&gt; &#039;Gone&#039;,
  411 =&gt; &#039;Length Required&#039;,
  412 =&gt; &#039;Precondition Failed&#039;,
  413 =&gt; &#039;Request Entity Too Large&#039;,
  414 =&gt; &#039;Request-URI Too Long&#039;,
  415 =&gt; &#039;Unsupported Media Type&#039;,
  416 =&gt; &#039;Requested Range Not Satisfiable&#039;,
  417 =&gt; &#039;Expectation Failed&#039;,
  422 =&gt; &#039;Unprocessable Entity&#039;,
  423 =&gt; &#039;Locked&#039;,
  424 =&gt; &#039;Failed Dependency&#039;,
  426 =&gt; &#039;Upgrade Required&#039;,
&nbsp;
  500 =&gt; &#039;Internal Server Error&#039;,
  501 =&gt; &#039;Not Implemented&#039;,
  502 =&gt; &#039;Bad Gateway&#039;,
  503 =&gt; &#039;Service Unavailable&#039;,
  504 =&gt; &#039;Gateway Timeout&#039;,
  505 =&gt; &#039;HTTP Version Not Supported&#039;,
  506 =&gt; &#039;Variant Also Negotiates&#039;,
  507 =&gt; &#039;Insufficient Storage&#039;,
  510 =&gt; &#039;Not Extended&#039;
);</pre>
<h2>RIPE WHOIS</h2>
<blockquote cite="http://labs.ripe.net/content/ripe-database-api-documentation">
<p><p>All the status codes are standard HTTP codes ( <a href="http://www.iana.org/assignments/http-status-codes" rel="nofollow" >http://www.iana.org/assignments/http-status-codes</a> ).</p>
</p>
<p>Clients should avoid any form of coupling with the the text/plain error message contained in response body since it may change between different releases of the API and is only intended as a starting point for indentifying the real causes of the exception event.</p>
<p>The following table gives a brief description of the mapping between standard Whois V.3 responses and the related REST services status codes. Consider this table as just an example of the error mapping strategy, it may change with future releases.</p>
</p>
</blockquote>
<table>
<tbody>
<tr>
<th>System Exception</th>
<th>Whois Error</th>
<th>HTTP Status Code</th>
</tr>
<tr>
<td>IllegalArgumentException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>IllegalStateException</td>
<td></td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>UnsupportedOperationException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>ObjectNotFoundException</td>
<td></td>
<td>Not Found (404)</td>
</tr>
<tr>
<td>IllegalStateException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>IOException</td>
<td></td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>SystemException</td>
<td></td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>TooManyResultsException</td>
<td></td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>No Entries Found (101)</td>
<td>Not Found (404)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Unknown Source (102)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Unknown Object Type (103)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Unknown Attribute in Query (104)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Attribute Is Not Inverse Searchable (105)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>No Search Key Specified (106)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Access Denied (201)</td>
<td>Forbidden (403)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Access Control Limit Reached (202)</td>
<td>Forbidden (403)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Address Passing Not Allowed (203)</td>
<td>Bad Request (400)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Maximum Referral Lines Exceeded (204)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Connection Has Been Closed(301)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Referral Timeout (302)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>No Referral Host (303)</td>
<td>Internal Server Error (500)</td>
</tr>
<tr>
<td>WhoisServerException</td>
<td>Referral Host Not Responding (304)</td>
<td>Internal Server Error (500)</td>
</tr>
</tbody>
</table>
<blockquote cite="http://labs.ripe.net/content/ripe-database-api-documentation">
<p><p>Clients will have to define error messages generic enough to represent the four main error conditions, that are Bad Request, Forbidden, Not Found and Internal Server Error.</p>
<p>For example a possible mapping for client side error messages may be:</p>
</p>
</blockquote>
<table>
<tbody>
<tr>
<th>HTTP Status Code</th>
<th>Error Message</th>
</tr>
<tr>
<td>Bad Request (400)</td>
<td>The service is unable to understand and process the query.</td>
</tr>
<tr>
<td>Forbidden (403)</td>
<td>Query limit exceeded.</td>
</tr>
<tr>
<td>Not Found (404)</td>
<td>No results were found for Your search &#8220;<tt>Search term</tt>&#8220;</td>
</tr>
<tr>
<td>Internal Server Error (500)</td>
<td>The server encountered an unexpected condition which prevented it from fulfilling the request.</td>
</tr>
</tbody>
</table>
<h2>Helpful HTTP Links</h2>
<ol>
<li> <a href="http://www.iana.org/assignments/http-status-codes" rel="nofollow" >IANA registry</a> </li>
<li> <a href="http://rfc.askapache.com/rfc2324" rel="nofollow" >Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)</a> </li>
<li> <a href="http://livedocs.adobe.com/fms/2/docs/00000338.html" rel="nofollow" >Adobe Flash status code definitions (ie 408)</a> </li>
<li> <a href="http://support.microsoft.com/?id=318380" rel="nofollow" >Microsoft Internet Information Server Status Codes and Sub-Codes</a> </li>
<li> <a href="http://zamez.org/httplint?url=http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">httplint</a> </li>
<li> <a href="http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html" rel="nofollow" >HTTP Headers, brief intro.</a> </li>
<li> <a href="http://www.w3.org/TR/cuap" rel="nofollow" >Common User-Agent Issues</a> </li>
<li>[RFC2295] <a href="mailto:koen@win.tue.nl" rel="nofollow"  title="Technische Universiteit Eindhoven">Holtman, K.</a> and <a href="mailto:mutz@hpl.hp.com" rel="nofollow"  title="Hewlett-Packard Company">A.H. Mutz</a> , &#8221; <a href="http://rfc.askapache.com/rfc2295" rel="nofollow" >Transparent Content Negotiation in HTTP</a> &#8220;, RFC 2295, March 1998.</li>
<li>[RFC2518] <a href="mailto:yarong@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Goland, Y.</a> , <a href="mailto:ejw@ics.uci.edu" rel="nofollow"  title="Dept. Of Information and Computer Science, University of California, Irvine">Whitehead, E.</a> , <a href="mailto:asad@netscape.com" rel="nofollow"  title="Netscape">Faizi, A.</a> , <a href="mailto:srcarter@novell.com" rel="nofollow"  title="Novell">Carter, S.R.</a> , and <a href="mailto:dcjensen@novell.com" rel="nofollow"  title="Novell">D. Jensen</a> , &#8221; <a href="http://rfc.askapache.com/rfc2518" rel="nofollow" >HTTP Extensions for Distributed Authoring &#8212; WEBDAV</a> &#8220;, RFC 2518, February 1999.</li>
<li>[RFC2616] <a href="mailto:fielding@ics.uci.edu" rel="nofollow"  title="University of California, Irvine">Fielding, R.</a> , <a href="mailto:jg@w3.org" rel="nofollow"  title="W3C">Gettys, J.</a> , <a href="mailto:mogul@wrl.dec.com" rel="nofollow"  title="Compaq Computer Corporation">Mogul, J.</a> , <a href="mailto:frystyk@w3.org" rel="nofollow"  title="MIT Laboratory for Computer Science">Frystyk, H.</a> , <a href="mailto:masinter@parc.xerox.com" rel="nofollow"  title="Xerox Corporation">Masinter, L.</a> , <a href="mailto:paulle@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Leach, P.</a> , and <a href="mailto:timbl@w3.org" rel="nofollow"  title="W3C">T. Berners-Lee</a> , &#8221; <a href="http://rfc.askapache.com/rfc2616" rel="nofollow" >Hypertext Transfer Protocol &#8212; HTTP/1.1</a> &#8220;, RFC 2616, June 1999.</li>
<li>[RFC2774] <a href="mailto:frystyk@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Nielsen, H.</a> , <a href="mailto:paulle@microsoft.com" rel="nofollow"  title="Microsoft Corporation">Leach, P.</a> , and <a href="mailto:lawrence@agranat.com" rel="nofollow"  title="Agranat Systems, Inc.">S. Lawrence</a> , &#8221; <a href="http://rfc.askapache.com/rfc2774" rel="nofollow" >An HTTP Extension Framework</a> &#8220;, RFC 2774, February 2000.</li>
<li>[RFC2817] Khare, R. and S. Lawrence, &#8221; <a href="http://rfc.askapache.com/rfc2817" rel="nofollow" >Upgrading to TLS Within HTTP/1.1</a> &#8220;, RFC 2817, May 2000.</li>
<li>[RFC3229] Mogul, J., Krishnamurthy, B., Douglis, F., Feldmann, A., Goland, Y., van Hoff, A., and D. Hellerstein, &#8221; <a href="http://rfc.askapache.com/rfc3229" rel="nofollow" >Delta encoding in HTTP</a> &#8220;, RFC 3229, January 2002.</li>
<li>[RFC4918] <a href="mailto:ldusseault@commerce.net" rel="nofollow"  title="CommerceNet">Dusseault, L., Ed.</a> , &#8221; <a href="http://rfc.askapache.com/rfc4918" rel="nofollow" >HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)</a> &#8220;, RFC 4918, June 2007.</li>
</ol>
<p><a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html"></a><a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">HTTP Status Codes and .htaccess ErrorDocuments</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Advanced Htaccess &#8211; SSI, ErrorDocuments, DirectoryIndexing SEO</title>
		<link>http://www.askapache.com/htaccess/advanced-htaccess-ssi.html</link>
		<comments>http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#comments</comments>
		<pubDate>Mon, 09 Mar 2009 08:02:02 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache Modules]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[403 Forbidden]]></category>
		<category><![CDATA[404 Not Found]]></category>
		<category><![CDATA[500]]></category>
		<category><![CDATA[503]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Apache Htaccess]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[AskApache Google 404]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[errordocument]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[htaccess files]]></category>
		<category><![CDATA[htaccess rewrite]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[HTTP-EQUIV]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mod_include]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Rewrite Tricks]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriterule]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Server Side Includes]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[SetEnvIf]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[SymLinks]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=2236</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-directory" title="Improved Directory Listings and SEO"><img src="http://uploads.askapache.com/2009/03/htaccess-directory-index-116x76.png" alt="htaccess directory indexing" title="Improved Directory Listings and SEO" width="116" height="76" /></a><a class="IFL" style="border-bottom:15px solid #FFF;" href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-error" title="Enhanced Error Pages"><img src="http://uploads.askapache.com/2009/03/example-errordocument-116x67.png" alt="ErrorDocument from .htaccess" title="Enhanced Error Pages" width="116" height="67" /></a>3-Part article covering practical implementation of 3 advanced .htaccess features.   Discover an easy way to <a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-directory">boost your SEO the <dfn title="Design your site for Humans">AskApache way</dfn></a> (<em>focus on visitors</em>), a tip you might keep and use for life. <a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-security">Get some cool security tricks</a> to use against spammers, crackers, and other nefarious sorts.  <a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-error">Take your site's error handling to the next level</a>, enhanced ErrorDocuments that go beyond 404's. <br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><acronym title="Server Side Includes">SSI</acronym>, Server Side Includes, can be very useful to webmasters and visitors alike.  They are easily set up in an .htaccess file and require little to no maintaining.. the term &#8220;Set it and Forget it&#8221; applies here.  Before we look at how to implement SSI, and dig into the Apache module that makes them possible, lets look at few uses for SSI so you can quickly determine if you would like to read further.</p>
<ol>
<li><a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-directory">Improved Directory Listings and SEO</a></li>
<li><a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-error">Enhanced Error Pages</a></li>
<li><a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html#htaccess-ssi-security">Dealing with Spam and Website Attacks</a></li>
</ol>
<hr class="C" />
<h2><a name="htaccess-ssi-directory" id="htaccess-ssi-directory"></a>Improved Directory Listings and SEO</h2>
<p><a href="http://uploads.askapache.com/2009/03/htaccess-directory-index.png" rel="nofollow" class="IFL"  title="htaccess directory indexing"><img src="http://uploads.askapache.com/2009/03/htaccess-directory-index-116x76.png" alt="htaccess directory indexing" title="htaccess directory indexing" /></a>One way that I use SSI is for improved Directory Listing.  Anyone here like SEO?  Check out my <a href="http://uploads.askapache.com/" rel="nofollow" >WordPress uploads directory</a> to get an idea.  Basically I can customize the header and footer of each directory..  Pretty sweet, thanks Apache!<br class="C" /></p>
<p>In your <code>/uploads/.htaccess</code></p>
<pre># turn on auto-indexing and turn off SSI&#039;s ability to exec
Options None
Options SymLinksIfOwnerMatch Indexes IncludesNOEXEC
&nbsp;
# we need to make sure files are displayed when requested, not executed or parsed
AddType text/plain .ini .sh .bsh .bash .csh .var .asc .md5 .sha .sha1 .cgi .pl .php .inc .asp .exe .bin
DefaultType text/plain
&nbsp;
# turn on auto-indexing, with askapache-optimized options
IndexOptions FancyIndexing SuppressColumnSorting SuppressHTMLPreamble IconHeight=22 IconWidth=20
IndexOptions IgnoreClient NameWidth=40 DescriptionWidth=* XHTML FoldersFirst
&nbsp;
# don&#039;t show these files and folders
IndexIgnore .htaccess .ht* *_notes *.log feed inc HEADER.html FOOTER.html feed*.gif
&nbsp;
# the SSI files used for the header and footer
HeaderName /ssi/HEADER.html
ReadmeName /ssi/FOOTER.html
&nbsp;
# used to determine the time and for SSI output
SetEnv TZ America/Indianapolis
SetEnv SERVER_ADMIN webmaster@askapache.com</pre>
<p>In your <code>/ssi/.htaccess</code></p>
<pre># makes files ending in .html be filtered through the INCLUDES filter before being sent to client
AddOutputFilter Includes html</pre>
<p>My <code>HEADER.html</code></p>
<pre>&lt;!&#45;-#set var=&quot;PAGETITLE&quot; value=&quot;&#45;- static.askapache.com&quot; &#45;-&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REQUEST_URI&quot; &#45;-&gt; &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;PAGETITLE&quot; &#45;-&gt;&lt;/title&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;http://static.askapache.com/c/error.css&quot; /&gt;
  &lt;link rev=&quot;made&quot; href=&quot;mailto:&lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;SERVER_ADMIN&quot; &#45;-&gt;&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;&lt;a href=&quot;http://www.askapache.com/&quot; title=&quot;AskApache Home&quot; accesskey=&quot;1&quot;&gt;
&lt;img src=&quot;http://www.askapache.com/nlogo.jpg&quot; height=&quot;75&quot; alt=&quot;AskApache&quot; /&gt;
&lt;/a&gt; &lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;REQUEST_URI&quot; &#45;-&gt; &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;PAGETITLE&quot; &#45;-&gt;&lt;/h1&gt;
&lt;hr /&gt;</pre>
<p>My <code>FOOTER.html</code></p>
<pre>&lt;p&gt;Find the information you are looking for on the &lt;a href=&quot;http://www.askapache.com/&quot;&gt;AskApache Home page&lt;/a&gt;
or the &lt;a href=&quot;http://www.askapache.com/search&lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;REQUEST_URI&quot; &#45;-&gt;&quot;&gt;
AskApache search page&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;address&gt;
  &lt;small&gt;$Id:&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;UNIQUE_ID&quot; &#45;-&gt; E:&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REDIRECT_STATUS&quot; &#45;-&gt;,v 1.30
&lt;!&#45;-#config timefmt=&quot;%c&quot; &#45;-&gt;&lt;!&#45;-#echo var=&quot;DATE_LOCAL&quot; &#45;-&gt;&lt;/small&gt;&lt;br /&gt;
  &lt;small&gt;&lt;!&#45;-#echo var=&quot;SERVER_SOFTWARE&quot; &#45;-&gt;&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;
  static.askapache.com &#45;- AskApache | &lt;a href=&quot;http://www.askapache.com/about/&quot;&gt;Webmaster&lt;/a&gt;
| Copyright &amp;copy; 2009 AskApache&lt;br /&gt;
&lt;/address&gt;
&lt;!&#45;-#if expr=&quot;$REMOTE_ADDR = 10.10.10.10&quot; &#45;-&gt;
&lt;pre &gt;&lt;!&#45;-#printenv &#45;-&gt;&lt;/ pre&gt;
&lt;!&#45;-#endif &#45;-&gt;
&lt;script src=&quot;http://static.askapache.com/j/apache-0780.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;var pageTracker = _gat._getTracker(&quot;UA-7&quot;+&quot;321&quot;+&quot;53-38&quot;);
pageTracker._initData();pageTracker._trackPageview();&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h2><a name="htaccess-ssi-error id="htaccess-ssi-error></a>Enhanced Error Pages</h2>
<p><a href="http://uploads.askapache.com/2009/03/example-errordocument.png" rel="nofollow" class="IFL"  title="htaccess-errordocument"><img src="http://uploads.askapache.com/2009/03/example-errordocument-116x67.png" alt="ErrorDocument from .htaccess" title="htaccess-errordocument" /></a>If you are using WordPress, I&#8217;m sure you are using my <a href="http://www.askapache.com/seo/404-google-wordpress-plugin.html">AskApache Google 404 Plugin</a>, but whatever your <a href="http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html">error pages</a> may be, using SSI you can make them better.  My 404 Error Page is handled by WordPress and PHP, but all of my other error pages (codes 4xx to 5xx) are handled using SSI.  You can check out any of them: <a href="http://www.askapache.com/show-error-400">/show-error-400</a>, <a href="http://www.askapache.com/show-error-400">/show-error-403</a>, <a href="http://www.askapache.com/show-error-500">/show-error-503</a>, etc..<br class="C" /></p>
<p>Notice the email note which has the subject prefilled?  Thats one of the main uses for SSI, you can add forms to your errordocuments and get notified of problems which mean you can fix them.</p>
<p>Add this to your <code>/.htaccess</code> for each <code>ErrorDocument</code> you make.</p>
<pre>ErrorDocument 503 /errordocs/503.html</pre>
<p>My <code>/errordocs/.htaccess</code></p>
<pre># turn on symlinks for rewrites and turn off SSI&#039;s ability to exec
Options None
Options SymLinksIfOwnerMatch IncludesNOEXEC
&nbsp;
# makes files ending in .html be filtered through the INCLUDES filter before being sent to client
AddOutputFilter Includes html
&nbsp;
# this internal apache variable prevents your errordocs from allowing keep-alive connections
SetEnv nokeepalive
&nbsp;
# used to determine the time and for SSI output
SetEnv TZ America/Indianapolis
SetEnv SERVER_ADMIN webmaster@askapache.com</pre>
<p>My <code>/errordocs/503.html</code></p>
<pre>&lt;!&#45;-#set var=&quot;TITLE&quot; value=&quot;Service Temporarily Unavailable&quot; &#45;-&gt;
&lt;!&#45;-#include virtual=&quot;/errordocs/TOP.html&quot; &#45;-&gt;
&lt;p&gt;The server is temporarily unable to service your
request due to &lt;strong&gt;maintenance downtime&lt;/strong&gt;
or super-crazy-extreme capacity problems. Please try
again later&#46;.. Or &lt;a href=&quot;mailto:&lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;SERVER_ADMIN&quot; &#45;-&gt;&quot;&gt;send me an email&lt;/a&gt; and let me know about it..&lt;/p&gt;
&lt;!&#45;-#include virtual=&quot;/errordocs/BOTTOM.html&quot; &#45;-&gt;</pre>
<p>My <code>/errordocs/TOP.html</code></p>
<pre>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REQUEST_URI&quot; &#45;-&gt; &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;TITLE&quot; &#45;-&gt;&lt;/title&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;http://static.askapache.com/c/error.css&quot; /&gt;
  &lt;link rev=&quot;made&quot; href=&quot;mailto:&lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;SERVER_ADMIN&quot; &#45;-&gt;&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;&lt;a href=&quot;http://www.askapache.com/&quot; title=&quot;AskApache Home&quot; accesskey=&quot;1&quot;&gt;&lt;img src=&quot;http://www.askapache.com/nlogo.jpg&quot; height=&quot;75&quot; alt=&quot;AskApache&quot; /&gt;
&lt;/a&gt; &lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;REQUEST_URI&quot; &#45;-&gt; &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;TITLE&quot; &#45;-&gt;&lt;/h1&gt;
&lt;hr /&gt;</pre>
<p>My <code>/errordocs/BOTTOM.html</code></p>
<pre>&lt;p&gt;If this should not be an error please &lt;a href=&quot;mailto:webmaster@askapache.com?subject=ID#&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;UNIQUE_ID&quot; &#45;-&gt;&quot;&gt;email&lt;/a&gt; me right away.&lt;/p&gt;
&lt;!&#45;-#if expr=&quot;$HTTP_REFERER&quot; &#45;-&gt;
&lt;p&gt;You came from &lt;!&#45;-#echo var=&quot;HTTP_REFERER&quot;&#45;-&gt;&lt;/p&gt;
&lt;!&#45;-#endif &#45;-&gt;
&lt;p&gt;If you still have a question, please try to find the information you are looking
for on the &lt;a href=&quot;http://www.askapache.com/&quot;&gt;AskApache Home page&lt;/a&gt; or
the &lt;a href=&quot;http://www.askapache.com/search/&quot;&gt;AskApache search page&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;address&gt;
  &lt;a href=&quot;http://www.askapache.com/about/&quot;&gt;Webmaster&lt;/a&gt;
  $Id:&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;UNIQUE_ID&quot; &#45;-&gt; Error-&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REDIRECT_STATUS&quot; &#45;-&gt;,v 1.30 &lt;!&#45;-#config timefmt=&quot;%c&quot; &#45;-&gt;&lt;!&#45;-#echo var=&quot;DATE_LOCAL&quot; &#45;-&gt;&lt;br /&gt;
  &lt;!&#45;-#echo var=&quot;SERVER_SOFTWARE&quot; &#45;-&gt;
&lt;/address&gt;
&lt;!&#45;-#if expr=&quot;$REMOTE_ADDR = 10.10.10.10&quot; &#45;-&gt;
&lt;pre &gt;&lt;!&#45;-#printenv &#45;-&gt;&lt;/ pre&gt;
&lt;!&#45;-#endif &#45;-&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h2><a name="htaccess-ssi-security" id="htaccess-ssi-security"></a>Dealing with Spam and Website Attacks</h2>
<p><a href="http://uploads.askapache.com/2009/03/htaccess-f-off.png" rel="nofollow" class="IFL"  title="htaccess f-off"><img src="http://uploads.askapache.com/2009/03/htaccess-f-off-350x273.png" alt="htaccess SSI to scare spammers and crackers" title="htaccess f-off" /></a>Say you are using some nice <a href="http://www.askapache.com/htaccess/htaccess-plugin-blocks-spam-hackers-and-password-protects-blog.html">.htaccess rewrite</a> rules to block offending bots, web scrapers, and other nefarious net characters.  Instead of just sending a 403 Denied, you could send them to be handled by an SSI document that could do any number of things.. From adding the offending bot&#8217;s IP address to the .htaccess Deny List (blacklisting), emailing you with an alert, emailing the IP Block Owner, executing a denial-of-service response ala <a href="http://www.xav.com/scripts/guardian/help/1013.html" rel="nofollow" >guardian</a> (<em>script will return an artificially high Content-Length, and will then spoon-feed content bytes back to the client at a rate of one byte per second, for single-threaded or fixed-threadpool clients, this will hang all of their requests and render the attack inoperable</em>), or just output a frightening looking message which usually does the trick if the bot is humanoid.<br class="C" /></p>
<pre>RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\=?(http|ftp|ssl|https):/.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\?.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(asp|ini|dll).*\ HTTP/ [NC]
RewriteRule .* - [F]
&nbsp;
ErrorDocument 403 /errordocs/f-off.html</pre>
<p>Example <code>/errordocs/f-off.html</code>  <a href="http://static.askapache.com/f-off" rel="nofollow" >View it Live</a> (<em>Not Responsible for mental or physical harm caused by fright</em>)</p>
<pre>&lt;html&gt;&lt;head&gt;&lt;title&gt;WARNING &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REMOTE_ADDR&quot; &#45;-&gt;
- SECURITY TEAM ALERTED&lt;/title&gt;&lt;/head&gt;&lt;body&gt;
&lt;h2&gt;ATTENTION &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REMOTE_ADDR&quot; &#45;-&gt;&lt;/h2&gt;
&lt;p&gt;You have been flagged by our system as a potential threat.&lt;/p&gt;
&lt;p&gt;This request has been logged and the Security Team has been notified.&lt;br&gt;
Repeated attempts from IP address &lt;strong&gt;&lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REMOTE_ADDR&quot; &#45;-&gt;&lt;/strong&gt; will result &lt;br&gt;
in the IP automatically being &lt;strong&gt;blacklisted&lt;/strong&gt; on this server&lt;br&gt;
and sent to blacklists around the world.  Additionally, the Security Team&lt;br&gt;
WILL alert the IP Address Block Owner and/or contact the authorities.&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&nbsp;
&lt;h3&gt;LOGGED INFORMATION FROM THIS REQUEST&lt;/h3&gt;
&lt; pre&gt;
REMOTE_ADDR   :  &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REMOTE_ADDR&quot; &#45;-&gt;
REMOTE_PORT   :  &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REMOTE_PORT&quot; &#45;-&gt;
REQUEST_METHOD:  &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;REQUEST_METHOD&quot; &#45;-&gt;&lt;!&#45;-#if expr=&quot;$HTTP_REFERER&quot;
&#45;-&gt;
REFERER       :  &lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;HTTP_REFERER&quot; &#45;-&gt;&lt;!&#45;-#endif
&#45;-&gt;
REQUEST_URI   :  &lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;REQUEST_URI&quot; &#45;-&gt;&lt;!&#45;-#if expr=&quot;$HTTP_USER_AGENT&quot;
&#45;-&gt;
USER_AGENT    :&lt;/ pre&gt;
&lt; pre style=&quot;white-space:normal;margin-left:150px;max-width:80%;&quot;&gt;  &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;HTTP_USER_AGENT&quot; &#45;-&gt;
&lt;/ pre&gt;
&lt; pre&gt;&lt;!&#45;-#endif
&#45;-&gt;&lt;!&#45;-#if expr=&quot;$HTTP_COOKIE&quot;
&#45;-&gt;
COOKIES       :&lt;/ pre&gt;
&lt; pre style=&quot;white-space:normal;margin-left:150px;max-width:80%;&quot;&gt;  &lt;!&#45;-#echo encoding=&quot;none&quot; var=&quot;HTTP_COOKIE&quot; &#45;-&gt;
&lt;/ pre&gt;
&lt; pre&gt;&lt;!&#45;-#endif
&#45;-&gt;&lt;!&#45;-#if expr=&quot;$QUERY_STRING&quot;
&#45;-&gt;
QUERY_STRING  :  &lt;!&#45;-#echo encoding=&quot;url&quot; var=&quot;QUERY_STRING&quot; &#45;-&gt;&lt;!&#45;-#endif
&#45;-&gt;
&lt;/ pre&gt;&lt;/body&gt;&lt;/html&gt;</pre>
<hr class="C" />
<h2>Server Side Includes Detailed Info</h2>
<p>Ok now that we have the real-world usage out of the way, lets dig in a bit to the actual module <a href="http://static.askapache.com/servers/mod_include.c.html" rel="nofollow" style="color:#222;" href='http://static.askapache.com/servers/mod_include.c'>mod_include</a>, which if you want you can <a >view the source code here</a>.</p>
<h3>Enabling Server-Side Includes</h3>
<p>Server Side Includes are implemented by the INCLUDES filter.  For backwards compatibility, the server-parsed handler also activates the INCLUDES filter. As well, Apache will activate the INCLUDES filter for any document with mime type text/x-server-parsed-html or text/x-server-parsed-html3 (and the resulting output will have the mime type text/html).  If documents containing server-side include directives are given the extension .shtml, the following directives will make Apache parse them and assign the resulting document the mime type of text/html:</p>
<pre>AddType text/html .shtml
AddOutputFilter INCLUDES .shtml</pre>
<p>The following directive must be given for the directories containing the shtml files (typically in a <directory> section, but this directive is also valid in <a href="http://www.askapache.com/htaccess/htaccess.html">.htaccess files</a> if AllowOverride Options is set):</p>
<pre>Options +Includes</pre>
<h3>Server-Side Include Directives</h3>
<p>These are the Directives allowed in .htaccess files that are handled by <a href="http://httpd.apache.org/docs/1.3/mod/mod_include.html" rel="nofollow" >mod_include</a>.  Note that other modules may add additional directives, for instance the <code>exec</code> SSI Directive is supplied by <a href="http://httpd.apache.org/docs/trunk/mod/mod_cgi.html" rel="nofollow" >mod_cgi</a>.  This is how mod_cgi registers with mod_include to provide processing of the <code>exec</code> directive.  This is the code required to handle the &#8220;exec&#8221; SSI directive.</p>
<pre>cgi_pfn_reg_with_ssi = APR_RETRIEVE_OPTIONAL_FN(ap_register_include_handler);
cgi_pfn_reg_with_ssi(&quot;exec&quot;, handle_exec);
static const char * const aszPre[] = { &quot;mod_include.c&quot;, NULL };</pre>
<dl>
<dt><code>config</code></dt>
<dd>Controls various aspects of the parsing.</p>
<pre>&lt;!&#45;-#config [timefmt=&quot;&#46;..&quot;] [sizefmt=&quot;&#46;..&quot;] [errmsg=&quot;&#46;..&quot;] &#45;-&gt;
&lt;!&#45;-#config [echomsg=&quot;&#46;..&quot;] &#45;-&gt;
&lt;!&#45;-#config errmsg=&quot;[It appears that you don&#039;t know how to use SSI]&quot; &#45;-&gt;</pre>
<dl>
<dt><code>echomsg</code></dt>
<dd>(<em>since 2.1</em>) The value is a message that is sent back to the client if the <code><a href="#element.echo" rel="nofollow" >echo</a></code> element attempts to echo an undefined variable. This overrides any <code class="directive"><a href="#ssiundefinedecho" rel="nofollow" >SSIUndefinedEcho</a></code> directives.</dd>
<dt><code>errmsg</code></dt>
<dd>The value is a message that is sent back to the client if an error occurs while parsing the document. This overrides any <code class="directive"><a href="#ssierrormsg" rel="nofollow" >SSIErrorMsg</a></code> directives.</dd>
<dt><code>sizefmt</code></dt>
<dd>The value sets the format to be used which displaying the size of a file. Valid values are <code>bytes</code> for a count in bytes, or <code>abbrev</code> for a count in Kb or Mb as appropriate, for example a size of 1024 bytes will be printed as &#8220;1K&#8221;.</dd>
<dt><code>timefmt</code></dt>
<dd>The value is a string to be used by the <code>strftime(3)</code> library routine when printing dates.</dd>
</dl>
</dd>
<dt><code>echo</code></dt>
<dd>Prints one of the include variables. If the variable is unset, the result is determined by the SSIUndefinedEcho directive.</p>
<pre class='a'>&lt;!&#45;-#echo [encoding=&quot;none|url|entity&quot;] var=&quot;&#46;..&quot; [encoding=&quot;none|url|entity&quot;] var=&quot;&#46;..&quot; &#46;.. &#45;-&gt;</pre>
<dl>
<dt><code>var</code></dt>
<dd>The value is the name of the variable to print.</dd>
<dt><code>encoding</code></dt>
<dd>
<p>Specifies how Apache should encode special characters contained in the variable before outputting them. If set to <code>none</code>, no encoding will be done. If set to <code>url</code>, then URL encoding (also known as %-encoding; this is appropriate for use within URLs in links, etc.) will be performed. The default is set to <code>entity</code>, resulting in entity encoding.</p>
</dd>
</dl>
</dd>
<dt><code>exec</code></dt>
<dd>Execute external programs</p>
<pre>&lt;!&#45;-#exec cgi=&quot;/cgi-bin/s.cgi&quot; &#45;-&gt;
&lt;!&#45;-#exec cmd=&quot;ls&quot; &#45;-&gt;
&lt;!&#45;-#include virtual=&quot;/cgi-bin/s.cgi?argument=value&quot; &#45;-&gt;
&lt;!&#45;-#exec cmd=&quot;perl /cgi-bin/s.pl args&quot; &#45;-&gt;</pre>
</dd>
<dt><code>include</code></dt>
<dd>Include a file</p>
<pre class='a'>&lt;!&#45;-#include virtual|file=&quot;&#46;..&quot; [virtual|file=&quot;&#46;..&quot;] &#46;.. &#45;-&gt;</pre>
</dd>
<dt><code>printenv</code></dt>
<dd>Print all available variables</p>
<pre>&lt;!&#45;-#printenv &#45;-&gt;</pre>
</dd>
<dt><code>set</code></dt>
<dd>Set a value of a variable.</p>
<pre class='a'>&lt;!&#45;-#set var=&quot;&#46;..&quot; value=&quot;&#46;..&quot; &#46;.. &#45;-&gt;
&lt;!&#45;-#set var=&quot;modified&quot; value=&quot;$LAST_MODIFIED&quot; &#45;-&gt;
&lt;!&#45;-#set var=&quot;name&quot; value=&quot;AskApache&quot; &#45;-&gt;
&lt;!&#45;-#set var=&quot;date&quot; value=&quot;${DATE_LOCAL}_${DATE_GMT}&quot; &#45;-&gt;</pre>
</dd>
<dt><code>flastmod</code></dt>
<dd>Prints the last modification date of the specified file, subject to the timefmt format specification.</p>
<pre>&lt;!&#45;-#flastmod virtual|file=&quot;&#46;..&quot; [virtual|file=&quot;&#46;..&quot;] &#46;.. &#45;-&gt;</pre>
</dd>
<dt><code>fsize</code></dt>
<dd>Prints the size of the specified file, subject to the sizefmt format specification.</p>
<pre class='a'>&lt;!&#45;-#fsize virtual|file=&quot;&#46;..&quot; [virtual|file=&quot;&#46;..&quot;] &#46;.. &#45;-&gt;</pre>
</dd>
<dt><code>if</code></dt>
<dd>The if element works like an if statement in a programming language. The test condition is evaluated and if the result is true, then the text until the next elif, else or endif element is included in the output stream.</p>
<pre>&lt;!&#45;-#if expr=&quot;&#46;..&quot; &#45;-&gt;
&lt;!&#45;-#if expr=&quot;${REMOTE_USER} &amp;&amp; ${HTTP_USER_AGENT}&quot; &#45;-&gt;</pre>
<pre>&lt;!&#45;-#if expr=&quot;test_condition&quot; &#45;-&gt;
&lt;!&#45;-#elif expr=&quot;test_condition&quot; &#45;-&gt;
&lt;!&#45;-#else &#45;-&gt;
&lt;!&#45;-#endif &#45;-&gt;</pre>
</dd>
<dt><code>elif</code></dt>
<dd>Used to put text into the output stream if the original test_condition was false. </p>
<pre class='a'>&lt;!&#45;-#elif expr=&quot;&#46;..&quot; &#45;-&gt;</pre>
</dd>
<dt><code>else</code></dt>
<dd>Used to put text into the output stream if the original test_condition was false.</p>
<pre>&lt;!&#45;-#else &#45;-&gt;</pre>
</dd>
<dt><code>endif</code></dt>
<dd>Ends the if element and is required.</p>
<pre class='a'>&lt;!&#45;-#endif &#45;-&gt;</pre>
</dd>
</dl>
<h3>.htaccess directives</h3>
<ol>
<li>XBitHack</li>
<li>SSIErrorMsg</li>
<li>SSITimeFormat</li>
<li>SSIStartTag</li>
<li>SSIEndTag</li>
<li>SSIUndefinedEcho</li>
<li>SSIAccessEnable</li>
</ol>
<h3>mod_include Default SSI Values</h3>
<dl>
<dt><code>START_SEQUENCE</code></dt>
<dd><code><!--#</code> - The starting tag for mod_include to recognize and parse as SSI.</code></dd>
<dt><code>END_SEQUENCE</code></dt>
<dd><code>--></code> &#8211; The ending tag for mod_include to recognize and parse as SSI.</dd>
<dt><code>ERROR_MSG</code></dt>
<dd><code>[an error occurred while processing this directive]</code> &#8211; On Errors parsing SSI.</dd>
<dt><code>TIME_FORMAT</code></dt>
<dd><code>%A, %d-%b-%Y %H:%M:%S %Z</code> &#8211; Default Time format for DATE</dd>
<dt><code>UNDEFINED_ECHO</code></dt>
<dd><code>(none)</code> &#8211; When echoing an undefined variable.</dd>
</dl>
<h3>SSI Variables</h3>
<pre>DATE_GMT=Sun Mar  8 22:58:56 2009
DATE_LOCAL=Sun Mar  8 15:58:56 2009
DOCUMENT_NAME=FOOTER.html
DOCUMENT_ROOT=/root-srv/protected/askapache.com/sec
DOCUMENT_URI=/includes/FOOTER.html
GATEWAY_INTERFACE=CGI/1.1
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_ACCEPT_ENCODING=gzip,deflate
HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5
HTTP_CACHE_CONTROL=max-age=0
HTTP_CONNECTION=keep-alive
HTTP_COOKIE=__qca=12298910-686528-46510;  __utmb=50625.1.0.11311
HTTP_HOST=www.askapache.com
HTTP_KEEP_ALIVE=300
HTTP_REFERER=http://www.askapache.com/htaccess/htaccess.html
HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)
LAST_MODIFIED=Sun Mar  8 14:53:50 2009
PATH=/bin:/usr/bin:/sbin:/usr/sbin
QUERY_STRING=
REMOTE_ADDR=24.123.215.60
REMOTE_PORT=4785
REQUEST_METHOD=GET
REQUEST_URI=/htaccess/
SCRIPT_FILENAME=/root-srv/protected/askapache.com/sec/includes/FOOTER.html
SCRIPT_NAME=/includes/FOOTER.html
SCRIPT_URI=http://www.askapache.com/htaccess/
SCRIPT_URL=/htaccess/
SERVER_ADDR=64.111.114.111
SERVER_ADMIN=webmaster@askapache.com
SERVER_NAME=www.askapache.com
SERVER_PORT=80
SERVER_PROTOCOL=INCLUDED
SERVER_SIGNATURE=
SERVER_SOFTWARE=Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.63 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2
UNIQUE_ID=dnbtH0Bvcm8A2ZHqcAAAAM
USER_NAME=</pre>
<h3>More SSI Information</h3>
<ol>
<li><a href="http://httpd.apache.org/docs/trunk/mod/mod_include.html" rel="nofollow" >mod_include</a></li>
<li><a href="http://httpd.apache.org/docs/trunk/filter.html" rel="nofollow" >Apache Filters</a></li>
<li><a href="http://httpd.apache.org/docs/trunk/howto/ssi.html" rel="nofollow" >Introduction to Server Side Includes</a></li>
<li><a href="http://httpd.apache.org/docs/trunk/handler.html" rel="nofollow" >Apache Handlers</a></li>
</ol>
<p><a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html"></a><a href="http://www.askapache.com/htaccess/advanced-htaccess-ssi.html">Advanced Htaccess &#8211; SSI, ErrorDocuments, DirectoryIndexing SEO</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/htaccess/advanced-htaccess-ssi.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom PHP.ini tips and tricks</title>
		<link>http://www.askapache.com/php/custom-phpini-tips-and-tricks.html</link>
		<comments>http://www.askapache.com/php/custom-phpini-tips-and-tricks.html#comments</comments>
		<pubDate>Mon, 05 Feb 2007 23:51:16 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[Linux Unix BSD]]></category>
		<category><![CDATA[Mod_Rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server Administration]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[WiredTree]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[askapache]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[CommandLine]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Dig]]></category>
		<category><![CDATA[DreamHost]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[error log]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[File Permissions]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[htaccess files]]></category>
		<category><![CDATA[HTTP Headers]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[HTTPS SSL]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Logs]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nice]]></category>
		<category><![CDATA[nsa]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[phpinfo]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Powweb]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[Redirection]]></category>
		<category><![CDATA[Rewrite Tricks]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriterule]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[server config]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[Sessions]]></category>
		<category><![CDATA[SetEnvIf]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Socket]]></category>
		<category><![CDATA[SPEED]]></category>
		<category><![CDATA[SSI]]></category>
		<category><![CDATA[stat]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[ultimate htaccess]]></category>
		<category><![CDATA[umask]]></category>
		<category><![CDATA[Username]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://www.askapache.com.com/php/custom-phpini-tips-and-tricks.html</guid>
		<description><![CDATA[Describes in exhaustive detail how to change configuration settings and implement a custom php.ini file for use with the Apache Web Server. View latest official php.ini Sections: When php run as Apache Module (mod_php) When php run as CGI When cgi?d php is run with wrapper (for FastCGI) .htaccess code from Ultimate htaccess file RUN PHP AS APACHE MODULE AddHandler application/x-httpd-php .php .htm RUN PHP AS CGI AddHandler php-cgi .php .htm CGI PHP WRAPPER FOR CUSTOM PHP.INI AddHandler phpini-cgi .php .htm Action phpini-cgi /cgi-bin/php5-custom-ini.cgi FAST-CGI SETUP WITH PHP-CGI WRAPPER FOR CUSTOM PHP.INI AddHandler fastcgi-script .fcgi AddHandler php-cgi .php .htm Action&#8230;]]></description>
			<content:encoded><![CDATA[<p>Describes in exhaustive detail how to <a href="http://php.net/manual/en/configuration.changes.php" rel="nofollow" >change configuration settings</a> and implement a custom php.ini file for use with the Apache Web Server.</p>
<p><a href="http://cvs.php.net/viewvc.cgi/php-src/php.ini-dist?view=co"rel="nofollow" >View latest official php.ini</a></p>
<hr />
<h2>Sections:</h2>
<ul>
<li>When php run as Apache Module (mod_php)</li>
<li>When php run as CGI</li>
<li>When cgi?d php is run with wrapper (for FastCGI)</li>
</ul>
<h2>.htaccess code from <a href="http://www.askapache.com/htaccess/ultimate-htaccess-file-sample.html">Ultimate htaccess file</a></h2>
<h3>RUN PHP AS APACHE MODULE</h3>
<pre>AddHandler application/x-httpd-php .php .htm</pre>
<h3>RUN PHP AS CGI</h3>
<pre>AddHandler php-cgi .php .htm</pre>
<h3>CGI PHP WRAPPER FOR CUSTOM PHP.INI</h3>
<pre>AddHandler phpini-cgi .php .htm
Action phpini-cgi /cgi-bin/php5-custom-ini.cgi</pre>
<h3>FAST-CGI SETUP WITH PHP-CGI WRAPPER FOR CUSTOM PHP.INI</h3>
<pre>AddHandler fastcgi-script .fcgi
AddHandler php-cgi .php .htm
Action php-cgi /cgi-bin/php5-wrapper.fcgi</pre>
<h3>CUSTOM PHP CGI BINARY SETUP</h3>
<pre>AddHandler php-cgi .php .htm
Action php-cgi /cgi-bin/php.cgi </pre>
<h2>When php run as Apache Module (mod_php)</h2>
<p>in root .htaccess</p>
<pre>SetEnv PHPRC /location/todir/containing/phpinifile</pre>
<h2>When php run as CGI</h2>
<p>Place your php.ini file in the dir of your cgi&#8217;d php, in this case /cgi-bin/</p>
<p>htaccess might look something like this</p>
<pre>AddHandler php-cgi .php .htm
Action php-cgi /cgi-bin/php5.cgi</pre>
<h2>When php is run as cgi</h2>
<p>Create a wrapper script called phpini.cgi to export the directory that contains the <strong>php.ini file</strong> as <strong>PHPRC</strong></p>
<pre>#!/bin/sh
export PHPRC=/home/site/askapache.com/inc
exec /user/public_html/cgi-bin/php5.cgi</pre>
<p>In your .htaccess or httpd.conf file</p>
<pre>AddHandler php-cgi .php
Action php-cgi /cgi-bin/phpini.cgi</pre>
<h2>When cgi&#8217;d php is run with wrapper (for FastCGI)</h2>
<p>NOTE: <a href="http://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost.html">Custom PHP.ini with FastCGI on DreamHost</a></p>
<p>You will have a shell wrapper script something like this:</p>
<pre>#!/bin/sh
export PHP_FCGI_CHILDREN=3
exec /user/public_html/cgi-bin/php5.cgi</pre>
<p>Change To</p>
<pre>#!/bin/sh
export PHP_FCGI_CHILDREN=3
exec /user/public_html/cgi-bin/php.cgi -c /home/user/php.ini</pre>
<p><strong>NOTES:</strong></p>
<ul>
<li>Since PHP 5.1.0, it is possible to refer to existing .ini variables from within .ini files. <code>open_basedir = ${open_basedir} ":/new/dir"</code></li>
<li>In order for PHP to read it, config file must be named php.ini</li>
<li>SetEnv PHPRC only works when using PHP as CGI, not when using php as an Apache Module</li>
</ul>
<h2>Default locations to look for php.ini</h2>
<p>PHP looks for custom php.ini in this order: </p>
<p>Src: <a href="http://php.net/en/configuration" rel="nofollow" >PHP Runtime Configuration</a></p>
<h3>In the Current working directory</h3>
<ol>
<li>Place your php.ini in the same directory as the php executable.</li>
<li>If php executable is here: /home/user1/public_html/cgi-bin/ </li>
<li>then place your php.ini file here: /home/user1/public_html/cgi-bin/php.ini</li>
</ol>
<h3>In the path specified by the environment variable <strong>PHPRC</strong></h3>
<ol>
<li>If you can use SetEnv in .htaccess files&#8211;> in the root .htaccess file specify the path to the <strong>directory</strong> containing php.ini <code>SetEnv PHPRC /home/user1</code></li>
<li>If you can&#8217;t use SetEnv and you are using a wrapper shell script place this in your wrapper shell script <code>export PHPRC=/home/user1</code></li>
</ol>
<h3>In the path that was defined at compile time with <strong>&#8211;with-config-file-path</strong></h3>
<ul>
<li>The path in which the php.ini file is looked for <strong>can be overridden using the -c argument</strong> in command line mode. (cgi) <code>/home/user1/public_html/cgi-bin/php.cgi -c /home/user1/php.ini</code></li>
<li>With this option one can either specify a directory where to look for php.ini or you can specify a custom INI file directly (which does <strong>not need to be named php.ini</strong>),<code>$ php -c /custom/directory/custom-file.ini my_script.php</code></li>
<li>Under Windows, the compile-time path is the Windows directory. Place php.ini in one of the directories, <code>C:\windows or C:\winnt</code></li>
</ul>
<h2>php.ini is searched for in these locations in this order</h2>
<p><strong>NOTE:</strong> The Apache web server changes the directory to root at startup causing PHP to attempt to read php.ini from the root filesystem if it exists. If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is e.g. php-cli.ini or php-apache.ini), it&#8217;s used instead of php.ini. SAPI name can be determined by php_sapi_name(). You can use also use the predefined PHP_SAPI constant instead of php_sapi_name()</p>
<p>Read this article: <a href="http://www.apachelounge.com/forum/viewtopic.php?t=570" rel="nofollow" >If your server is running Windows</a></p>
<ol>
<li>SAPI module specific location
<ul>
<li><strong>PHPIniDir</strong> directive in Apache 2</li>
<li><strong>-c</strong> command line option in CGI and CLI</li>
<li><strong>php_ini</strong> parameter in NSAPI</li>
<li><strong>PHP_INI_PATH</strong> environment variable in THTTPD</li>
</ul>
</li>
<li>The <strong>PHPRC</strong> environment variable <em>(Before PHP 5.2.0 this was checked after the registry key mentioned below.)</em></li>
<li>HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath <em>(Windows Registry location)</em></li>
<li>Current working directory <em>(for CLI)</em></li>
<li>The web server&#8217;s directory <em>(for SAPI modules)</em></li>
<li>Directory of PHP <em>(If Windows)</em></li>
<li>Windows directory <em>(C:\windows or C:\winnt)</em></li>
<li><strong>&#8211;with-config-file-path</strong> compile time option</li>
</ol>
<h2>Directions for custom php.ini for Powweb Customers</h2>
<p>Specific to Powweb, but can be used elsewhere.</p>
<pre>SetEnv PHPRC /home/users/web/bEXAMPLE/pow.EXAMPLE</pre>
<ol>
<li>In the folder above the htdocs (your ROOT) for the domain you want a custom php.ini file for, create an htaccess file with the above content:</li>
<li>Then create a blank php.ini also in your ROOT directory (/home/users/web/bEXAMPLE/pow.EXAMPLE). Next copy the powweb php.ini text to your php.ini file and customize it.</li>
<li>You can test to make sure you are using the new php.ini by running phpinfo(); If you want multiple php.ini files, then use .htaccess files to set the PHPRC variable to the directory that the php.ini file you want to use is in.</li>
</ol>
<h3>File structure from ROOT directory</h3>
<pre>.
|&#45;- site1.com
|   `&#45;- htdocs
|   |   |&#45;- cgi-bin
|   |   |   `&#45;- dl.cgi
|   |   `&#45;- index.html
|   |&#45;- phpsessions
|   |&#45;- php.ini
|   `&#45;- .htaccess
|&#45;- site2.org
|   `&#45;- htdocs
|   |   |&#45;- cgi-bin
|   |   |   `&#45;- dl.cgi
|   |   `&#45;- index.html
|   |&#45;- phpsessions
|   |&#45;- php.ini
|   `&#45;- .htaccess
`&#45;- site3.net
`&#45;- htdocs
|   |&#45;- cgi-bin
|   |   `&#45;- dl.cgi
|   `&#45;- index.html
|&#45;- phpsession
|&#45;- php.ini
`&#45;- .htaccess</pre>
<h3>Powweb File Permissions</h3>
<p><strong>Remember</strong> to chmod 640 all .htaccess files, chmod 600 your php.ini files, chmod 600 your php flies, and chmod 705 your cgi scripts.. if you don&#8217;t want ftp users to be able to change the file than chmod 400.</p>
<h2>PHP-CGI vs. MOD_PHP</h2>
<p><q><strong>What&#8217;s the difference between PHP-CGI and PHP as an Apache module?</strong></q></p>
<h3>Benefits of PHP-CGI</h3>
<ul>
<li>php-cgi is more secure. The PHP runs as your user rather than dhapache. That means you can put your database passwords in a file readable only by you and your php scripts can still access it!</li>
<li>php-cgi is more flexible. Because of security concerns when running PHP as an Apache module, we disabled commands with the non-CGI PHP. This will cause install problems with certain popular PHP scripts if you run PHP not as a CGI!</li>
<li>php-cgi is just as fast as running PHP as an Apache module, and we include more default libraries. </li>
</ul>
<h3>Caveats of PHP-CGI</h3>
<p>If one of these is a show-stopper for you, you can easily switch to running PHP as an Apache module and not CGI, but be prepared for a bunch of potential security and ease-of-use issues! If you don&#8217;t know what any of these drawbacks mean, you&#8217;re fine just using the default setting of PHP-CGI and not worrying about anything!</p>
<ul>
<li>Variables in the URL which are not regular <code>?foo=bar</code> variables won&#8217;t work without using (<a href="http://httpd.apache.org/docs/mod/mod_rewrite.html" rel="nofollow" >mod_rewrite</a>)</li>
<li>Custom php directives in .htaccess files <code>(php_include_dir /home/user;/home/user/example_dir)</code> won&#8217;t work.</li>
<li>The <code>$_SERVER['SCRIPT_NAME']</code> variable will return the php.cgi binary rather than the name of your script</li>
<li>Persistant database connections will not work. PHP&#8217;s <code>mysql_pconnect()</code> function will just open a new connection because it can&#8217;t find a persistant one.</li>
</ul>
<h2>PHP&#8217;s configuration file</a></h2>
<p><a href="http://php.net/manual/en/configuration.php" rel="nofollow" >The configuration file</a> (called <code>php3.ini</code> in PHP 3, and simply <code>php.ini</code> as of PHP 4) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started. <strong>Note:</strong> For the CGI and CLI version, php.ini is read on every invocation.</p>
<h2>Running PHP as Apache module (mod_php)</h2>
<p>When using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. <code>httpd.conf</code>) and <code>.htaccess</code> files. You will need one of these privileges:</p>
<pre>AllowOverride Options
AllowOverride All</pre>
<p>With PHP 4 and PHP 5, there are several Apache directives that allow you to change the PHP configuration from within the Apache configuration files.</p>
<p><strong>NOTE:</strong> With PHP 3, there are Apache directives that correspond to each configuration setting in the php3.ini name, except the name is prefixed by &#8220;php3_&#8221;.</p>
<dl>
<dt><strong><code>php_value name value</code></strong></dt>
<dd>Sets the value of the specified directive. Can be used only with <code>PHP_INI_ALL</code> and <code>PHP_INI_PERDIR</code> type directives. To clear a previously set value use <code>none</code> as the value.</dd>
<dt><strong><code>php_flag name on|off</code></strong></dt>
<dd>Used to set a boolean configuration directive. Can be used only with <code>PHP_INI_ALL</code> and <code>PHP_INI_PERDIR</code> type directives.</dd>
<dt><strong><code>php_admin_value name value</code></strong></dt>
<dd>Sets the value of the specified directive. This can not be used in .htaccess files. Any directive type set with php_admin_value can not be overridden by .htaccess or virtualhost directives. To clear a previously set value use none as the value.</dd>
<dt><strong><code>php_admin_flag name on|off</code></strong></dt>
<dd>Used to set a boolean configuration directive. This can not be used in .htaccess files. Any directive type set with php_admin_flag can not be overridden by .htaccess or virtualhost directives.</dd>
</dl>
<p><strong>NOTE:</strong> Don&#8217;t use php_value to set boolean values. use php_flag instead.</p>
<h2>Change php settings in .htaccess or httpd.conf</h2>
<h3>mod_php .htaccess example</h3>
<p>add settings to a .htaccess file with &#8216;php_flag&#8217; like this:</p>
<pre>php_flag register_globals off
php_flag magic_quotes_gpc on</pre>
<p><strong>In .htaccess, only true/false on/off flags can be set using php_flag. To set other values you need to use php_value, like this:</strong></p>
<pre>php_value upload_max_filesize 20M</pre>
<p><strong>PHP_INI_SYSTEM can be configured per-directory by placing it inside a per-directory block in httpd.conf</strong></p>
<pre># Selectively enable APC for wildly popular directories
# apc.enabled is Off in php.ini to reduce memory use
&lt;Directory /usr/local/apache2/public_html/forum&gt;
php_flag apc.enabled On
&lt;/Directory&gt;</pre>
<p><strong>NOTE:</strong> In order for these settings to work in your htaccess file, you will need to add &#8220;Options&#8221; to your AllowOverride specifications for the directory/webserver if it&#8217;s not already allowed.</p>
<p>Src: <a href="http://php.net/manual/en/configuration.changes.php" rel="nofollow" >How to change configuration settings</a></p>
<pre>&lt;IfModule mod_php5.c&gt;
php_value include_path &quot;.:/home/askapache/lib/php&quot;
php_admin_flag safe_mode on
&lt;/IfModule&gt;
&lt;IfModule mod_php4.c&gt;
php_value include_path &quot;.:/home/askapache/lib/php&quot;
php_admin_flag safe_mode on
&lt;/IfModule&gt;
&lt;IfModule mod_php3.c&gt;
php3_include_path &quot;.:/home/askapache/lib/php&quot;
php3_safe_mode on
&lt;/IfModule&gt;</pre>
<h2>Modify PHP configuration via Windows Registry</h2>
<p>When running PHP on Windows, the configuration values can be modified on a per-directory basis using the Windows registry. The configuration values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory Values, in the sub-keys corresponding to the path names. For example, configuration values for the directory c:\inetpub\wwwroot would be stored in the key HKLM\SOFTWARE\PHP\Per Directory Values\c\inetpub\wwwroot. The settings for the directory would be active for any script running from this directory or any subdirectory of it. The values under the key should have the name of the PHP configuration directive and the string value. PHP constants in the values are<br />
not parsed. However, only configuration values changeable in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.</p>
<h2>Methods to modify PHP configuration</h2>
<p>Regardless of how you run PHP, you can change certain values at runtime of your scripts through <a href="http://php.net/manual/en/function.ini-set.php" rel="nofollow" >ini_set()</a>.</p>
<p>If you are interested in a complete list of configuration settings on your system with their current values, you can execute the <a href="http://php.net/manual/en/function.phpinfo.php" rel="nofollow" >phpinfo()</a> function, and review the resulting page. You can also access the values of individual configuration directives at runtime using <a href="http://php.net/manual/en/function.ini-get.php" rel="nofollow" >ini_get()</a> or <a href="http://php.net/manual/en/function.get-cfg-var.php" rel="nofollow" >get_cfg_var()</a>.</p>
<h2>No input file specified</h2>
<p>One of the most common reasons why you get</p>
<blockquote><pre>No input file specified</pre>
</blockquote>
<p>(AKA &#8216;the second most useful error message in the world&#8217;) is that you have set <code>doc_root</code> (in php.ini) to a value which is to the <code>DocumentRoot</code> defined in the apache configuration.</p>
<p>This is the same for other webservers. For example, on lighttpd, make sure the <code>server.document-root</code> value is the same as what is defined as <code>doc_root</code> in php.ini.</p>
<h3>PHP.ini file Downloads</h3>
<ul>
<li><a href="http://uploads.askapache.com/2007/01/dreamhost-php-ini.txt" rel="nofollow" id="p63"  title="/etc/php/cgi/php.ini">DreamHost non-cgi php.ini</a></li>
<li><a href="http://uploads.askapache.com/2007/01/latest-php-ini.txt" rel="nofollow" id="p62" >Development php.ini from php CVS</a></li>
<li><a href="http://uploads.askapache.com/2007/01/powweb-php-ini.txt" rel="nofollow" id="p61" >Default PowWeb php.ini file for PHP 5.1.5</a></li>
</ul>
<h3>External Links</h3>
<ul>
<li><a href="http://httpd.apache.org/docs/2.2/mod/mod_env.html" rel="nofollow" >Apache module mod_env</a></li>
<li><a href="http://php.net/manual/en/features.commandline.php" rel="nofollow" >PHP: Using PHP from the command line</a></li>
<li><a href="http://php.net/manual/en/install.unix.apache2.php" rel="nofollow" >PHP: Apache 2.0 on Unix systems</a></li>
<li><a href="http://www.maven.pl/?p=10" rel="nofollow" >Maven Apache Mod Fastcgi PHP</a></li>
<li><a href="http://www.phpbuilder.com/columns/darrell20000319.php3" rel="nofollow" >Using PHP As A Shell Scripting Language</a></li>
</ul>
<h3>User-Contributed Notes</h3>
<p>There are a couple of errors in the mod_rewrite directives given. I found that the following works:</p>
<pre>RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteRule ^cgi-bin/php.cgi - [F]</pre>
<hr />
<p>I have noticed that some people have noted that running PHP as a CGI program can run slowly compared with a compiled in module. Some have noted that they want to use FastCGI but are hesitant. I found that using the Apache 2&#8242;s CGID module was a great way to speed up performance almost to the same level as an &#8220;so&#8221;-installed PHP module but you get the added benefit of running each virtual host under it&#8217;s own user and group. </p>
<p>In my testing I got 44 pages per second using PHP as a module and I got roughly the same performance (within 5%) running PHP as a CGI program through CGID. CGID is also really easy to set up. Just add &#8211;enable-cgid to your Apache configure command and you&#8217;re good to go. Just set up PHP as a CGI normally. I&#8217;m sure that there&#8217;s extra RAM used for this method but RAM is as cheap as borscht anyways so it shouldn&#8217;t be a major factor when trying to speed up PHP CGI. </p>
<hr />
<p>Here are my two cents of knowledge about php-cgi when running CGI script from prompt: If you get the &#8220;No input file specified.&#8221; error, create the environment variable &#8220;SCRIPT_FILENAME=C:\files\test.php&#8221;. If you get &#8220;Security Alert!&#8221; error and it tells you to create the REDIRECT_STATUS environment variable, it is because you have the SERVER_NAME variable set but not the REDIRECT_STATUS variable. Hence, if you have SERVER_NAME, you also need REDIRECT_STATUS, but not otherwise. And you pretty much should have SCRIPT_FILENAME at all time. </p>
<hr />
<p><code>--enable-force-cgi-redirect</code> won&#8217;t work in FastCGI mode as of 4.3.10, it is only supported in CGI mode. However, you can achieve the same result with mod_rewrite under Apache.</p>
<hr />
<pre>RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} !=200
RewriteRule /cgi-bin/path/to/php - [F]</pre>
<p>This will only allow internal redirection, thus forbidding direct HTTP access to php interpreter.</p>
<hr />
<p>PHP CGI with VirtualHosts. This is what I found out while trying to get php to work as CGI with Apache VirtualHosts.</p>
<p>By enabling &#8216;force-cgi-redirects&#8217;, you must:</p>
<ol>
<li>set &#8216;cgi.fix_pathinfo=1&#8242; in php.ini or the apache logs will show &#8216;unexpected T_STRING&#8217; in the php binary.</li>
<li>leave doc_root commented out (php.ini also) or you&#8217;ll only see &#8216;No input file specified.&#8217;, instead of the expected output.</li>
</ol>
<p>You can then turn on the php support for a particular vhost by defining an action/handler inside the corresponding <code><br />
<VirtualHost><br />
</code></p>
<pre>Action php-script /cgi-bin/php</pre>
<hr />
<p>PHP works with Apache and suEXEC like this: (Assuming that suEXEC ist allready installed and working)</p>
<hr />
<p>Install PHP as CGI binary (e.g. in /usr/local/bin/php) (compile with &#8211;enable-force-cgi-redirect) and create a Link inside cgi-bin directory to make php-cgi accessable:</p>
<p><kbd>cd /usr/local/apache/cgi-bin</kbd><br />
<kbd>ln /usr/local/bin/php php</kbd></p>
<hr />
<p>Edit your httpd.conf file:</p>
<pre>AddHandler php4-script .php
Action php4-script /cgi-bin/php
&nbsp;
&lt;VirtualHost 123.456.789.0:80&gt;
User exampleuser
Group examplegroup &#46;..
&lt;/VirtualHost&gt; </pre>
<p>Restart Apache and PHP-scripts are now called under the user-id of exampleuser and group-id of examplegroup.</p>
<hr />
<p>A replacement for suexec is suphp (http://www.suphp.org).</p>
<blockquote cite="http://www.suphp.org/">
<p>suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter.</p>
</blockquote>
<hr />
<p>A tip for Windows-users: PHP first seem to look in the php-directory for php.ini, and if that file does not exist, it looks in the Windows directory. I renamed the file php.ini-dist to php.ini and copied it to my Windows directory, and then I modified the infamous &#8220;cgi.force_redirect = 0&#8243; in the php.ini file located in the Windows directory, to make it work. But it did not because it reads from the &#8220;original&#8221; php.ini &#8211; So when I deleted this php.ini things started working again </p>
<hr />
<p>If you are using php per cgi and have additionally mod_gzip enabled you have to disable mod_gzip for the php cgi binary to use &#8211;enable-cgi-redirect. mod_gzip sets the REDIRECT_STATUS always to 200 which makes it impossible for the php binary to know when it was called directly or when it was called by a redirect.</p>
<hr />
<p>To use php-cgi with suexec it will be nice that each virtual host has ist&#8217;s own php.ini. This goes with :</p>
<pre>SetEnv PHPRC /var/www/server/www.test.com/conf</pre>
<p>But suexec will kill this environment cause It don&#8217;t know that it is &#8220;save&#8221; so you must edit the suexec.c for compiling</p>
<hr />
<p>When using php in cgi mode, it&#8217;s often a good idea to take a look at the apache <a href="http://httpd.apache.org/docs/suexec.html" rel="nofollow" >suexec</a> feature in addition to the &#8211;force-cgi-redirect option.</p>
<hr />
<p>If you do virutal hosting, you can turn safe mode on and off for different Apache Virutal Hosts using the php_admin_value directive. This also allows you to have customised maximum execution times, disabled functions, etc; anything which is set in php.ini. Note that by placing a base_dir for each virutal host, this means PHP CANNOT access files below this heirachy; strongly recomended for customer hosting.</p>
<p>Example (httpd.conf):
</p>
<pre>&lt;VirtualHost 127.0.0.1:80&gt;
DocumentRoot /var/www/html/safephphost/
ServerName safephp
php_admin_value safe_mode 1
php_admin_value open_base_dir /var/www/html/safephphost/
php_admin_value sendmail_from user.mail.net
&lt;/VirtualHost&gt;</pre>
<hr />
<p>If you care about security, you are better of setting: register_globals = off, enable_track_vars = on.</p>
<hr />
<p>If you want to use suexec and reference your php interpreter via #!/usr/local/bin/php, be sure to compile php WITHOUT &#8211;enable-force-cgi-redirect.</p>
<hr />
<p>suEXEC require CGI mode, and slow down the scripts.</p>
<ol>
<li>Install php as DSO mode. (for max speed and low secure)</li>
<li>Make a seperate CGI install with &#8211;enable-force-cgi-redirect, place php to cgi-bin</li>
<li>For more secure with suEXEC, choose one of the following method:
<ol>
<li>Place a .htaccess file containing this to override main config to protect All php files in subdirectory:
<pre>AddType application/x-httpd-wphp php
Action application/x-httpd-wphp /cgi-bin/php</pre>
</li>
<li>add following in httpd.conf and rename sensitive files with the ext .sphp
<pre>AddType application/x-httpd-wphp sphp
Action application/x-httpd-wphp /cgi-bin/php</pre>
</li>
<li>Add &#8220;php_value doc_root /home/user/html_docs&#8221; to each virtual host directive in httpd.conf</li>
</ol>
</li>
</ol>
<h4>Notes on User Notes</h4>
<p><strong>cgi.fix_pathinfo</strong> Provides real PATH_INFO/PATH_TRANSLATED support for CGI. PHP&#8217;s previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting this to 1 will cause PHP CGI to fix it&#8217;s paths to conform to the spec. A setting of zero causes PHP to behave as before. Default is zero. You should fix your scripts to use SCRIPT_FILENAME rather than PATH_TRANSLATED.</p>
<p><strong>cgi.force_redirect</strong> gi.force_redirect is necessary to provide security running PHP as a CGI under most web servers. Left undefined, PHP turns this on by default. You can turn it off at your own risk.</p>
<p><strong>cgi.redirect_status_env</strong> If cgi.force_redirect is turned on, and you are not running under Apache or Netscape (iPlanet) web servers, you may need to set an environment variable name that PHP will look for to know it is OK to continue execution.</p>
<p><strong>NOTE:</strong> Setting this variable may cause security issues, know what you are doing first.</p>
<p><strong>fastcgi.impersonate</strong> FastCGI under IIS (on WINNT based OS) supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under. mod_fastcgi under Apache does not currently support this feature (03/17/2002) Set to 1 if running under IIS. Default is zero.</p>
<p><a href="http://www.askapache.com/php/custom-phpini-tips-and-tricks.html"></a><a href="http://www.askapache.com/php/custom-phpini-tips-and-tricks.html">Custom PHP.ini tips and tricks</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/php/custom-phpini-tips-and-tricks.html/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
