<?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>ServerAdmins.NET</title>
	<atom:link href="http://serveradmins.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://serveradmins.net</link>
	<description>Stuff for Server Admins...</description>
	<lastBuildDate>Fri, 09 Jul 2010 16:46:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>XCache 1.3.0 install &#8211; with cPanel and CentOS</title>
		<link>http://serveradmins.net/xcache-1-3-0-install-with-cpanel-and-centos/</link>
		<comments>http://serveradmins.net/xcache-1-3-0-install-with-cpanel-and-centos/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 04:57:58 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Daemons]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[opcode]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[xcache]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=79</guid>
		<description><![CDATA[XCache PHP Opcode Cacher installation on CentOS and cPanel]]></description>
			<content:encoded><![CDATA[<p>Hey there!</p>
<p>I figure it&#8217;s been a little bit, so I&#8217;ve gone ahead and decided to update the XCache installer for version 1.3.0, and my favorite control panel, cPanel. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This is incredibly easy to do and should get a basic/barebones XCache installation up and going fairly quickly on your CentOS  + cPanel machine.</p>
<p>First, let&#8217;s grab our XCache sources&#8230;<br />
<code><br />
cd /usr/src/<br />
wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz<br />
</code></p>
<p>Now, go ahead and unarchive the source, and change into the XCache build dir&#8230;<br />
<code>tar -xzvf xcache-1.3.0.tar.gz<br />
cd xcache-1.3.0<br />
</code></p>
<p>Let&#8217;s prep our sources for the current PHP ecosystem&#8230;<br />
<code><br />
root@SERVER [/usr/src/xcache-1.3.0]# phpize<br />
Configuring for:<br />
PHP Api Version:         20041225<br />
Zend Module Api No:      20060613<br />
Zend Extension Api No:   220060519<br />
</code></p>
<p>Now that should have gotten everything sorted with our sources so the XCache install is ready for our PHP version and environment, Let&#8217;s go ahead and kick off the build!  Keep in mind, this build should be fairly fast and lightweight.</p>
<p><code><br />
./configure &#038;&#038; make &#038;&#038; make install<br />
</code><br />
The above line basically says &#8220;Run configure, if that is successful w/o errors, run a make, and if that finishes w/o error, run the install&#8221;.  Once this is complete, you should see a line that says something like the following&#8230;<br />
<code><br />
Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20060613/<br />
</code><br />
This is going to be where our xcache.so file is located, however when cPanel builds your php.ini file, it&#8217;s going to have that set already.  So getting the base module loaded is as simple as running the following command.<br />
<code><br />
echo "extension=xcache.so" >> /usr/local/lib/php.ini<br />
</code><br />
After that, you should be able to do a quick check of the PHP CLI and verify that it loaded properly with the &#8216;php -v&#8217; command&#8230;<br />
<code><br />
root@SERVER [/usr/src/xcache-1.3.0]# php -v<br />
PHP 5.2.13 (cli) (built: Jun 16 2010 09:27:33)<br />
Copyright (c) 1997-2010 The PHP Group<br />
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies<br />
    with XCache v1.3.0, Copyright (c) 2005-2009, by mOo<br />
</code></p>
<p>And there you go, you can safely restart Apache now and you should be serving cached content.  Please keep in mind, you&#8217;ll need to configure your XCache setup to ensure everything is working properly, all we&#8217;ve done here is install the base module.</p>
<p>I&#8217;d suggest taking a look at our other article regarding the tuning of XCache for a bit more information on this. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="http://serveradmins.net/tuning-xcache-for-fun-and-profit/"></p>
<p>That does it for now!</p>
<p></a></p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/xcache-1-3-0-install-with-cpanel-and-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto show the current runlevel in linux&#8230;</title>
		<link>http://serveradmins.net/howto-show-the-current-runlevel-in-linux/</link>
		<comments>http://serveradmins.net/howto-show-the-current-runlevel-in-linux/#comments</comments>
		<pubDate>Fri, 28 May 2010 12:51:17 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[init.d]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rc3.d]]></category>
		<category><![CDATA[runlevel]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=76</guid>
		<description><![CDATA[How to detect and change the current runlevel in Linux]]></description>
			<content:encoded><![CDATA[<p>Quick one here, mostly for my own notes than anything else. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>An easy way to see the existing runlevel is with the &#8216;who -r&#8217; command.</p>
<p><code><br />
root@server:~ # who -r<br />
         run-level 3  May 22 03:54                   last=S<br />
</code></p>
<p>Here we show the last boot and current runlevel (3).   In order to modify this, you can open up /etc/inittab and look for the following line.</p>
<p><code><br />
id:3:initdefault:<br />
</code></p>
<p>This shows that runlevel 3 is the default one kicked off by init on a bootup.</p>
<p>For what it&#8217;s worth, this refers to the directories in /etc/rc.d/rcX.d/, where X is  #.  The number correlates to the runlevel of your machine, and all of the scripts stored in that directory are executed when that runlevel is enabled.</p>
<p>TMYK!</p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/howto-show-the-current-runlevel-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto enable CGI in the builtin OSX webserver</title>
		<link>http://serveradmins.net/howto-enable-cgi-in-the-builtin-osx-webserver/</link>
		<comments>http://serveradmins.net/howto-enable-cgi-in-the-builtin-osx-webserver/#comments</comments>
		<pubDate>Sat, 15 May 2010 00:24:13 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Daemons]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[enable]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=74</guid>
		<description><![CDATA[How to setup and enable the builtin Apache webserver in OSX to handle CGI and Perl Applications]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve caught myself writing more code on my Macbook and for the first time in&#8230; YEARS, not needing an internet connection to actually be productive.  To be quite honest, it&#8217;s a bit weird. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, the first thing I wanted was the ability to run/exec CGI via a webserver.   At first, I was thinking I&#8217;d go about a source build of Apache, and then I remembered OSX comes with one built in.    Huzzah!</p>
<p>So, first let&#8217;s enable the builtin webserver.</p>
<p>System Preferences -> Sharing, and then click on &#8220;Web Sharing&#8221;.   Go ahead and close out the window now, you&#8217;ve just fired off Apache.  (hooray!).  You should now be able to open your browser of choice and go to http://127.0.0.1/~<username /.   Since I login as 'chrismm', I go to http://127.0.0.1/~chrismm/ .   Here you should see the nifty default page.</p>
<p>Now, the document root is going to be off of your user account in /sites/.   My user is chrismm on my machine, so /Users/chrismm/Sites/ is my public HTML.   Any web content you want to view with the above URL needs to go off of this directory.  Go ahead and add the obligatory "Helloworld.html", I'll wait. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now that that's done and functioning, I needed to get some hawt hawt Perl/CGI action going on.   This, was incredibly easy.</p>
<p>OSX's main httpd.conf does a per-user http include in /private/etc/apache2/users/<username>.conf, so once again for me, it was /private/etc/apache2/users/chrismm.conf.   This file contains just a super basic Directory configuration for apache to parse and we only need to make one quick change here&#8230;</p>
<p>First and foremost, we need to be the root user, so go ahead and open up Terminal (Finder->Applications->Utilities -> Terminal), and type &#8216;sudo su -&#8217; .   Here, you&#8217;ll be prompted to enter your password.</p>
<p>Keep in mind as soon as you do this, you are the root user on your machine, ***BE VERY CAREFUL AS IF YOU ARE NOT YOU CAN END UP WITH A WORTHLESS WORKSTATION ***.</p>
<p>Now, go ahead and open up the include for your user, at /private/etc/apache2/users/</username><username>.conf, and make the following changes.</p>
<p>Original:<br />
<code><br />
maynard:beta root# cat /private/etc/apache2/users/chrismm.conf<br />
<directory "/Users/chrismm/Sites/"><br />
    Options Indexes MultiViews<br />
    AllowOverride None<br />
    Order allow,deny<br />
    Allow from all<br />
</directory><br />
</code><code></p>
<p>Needs to be changed to....</p>
<p></code><code><br />
maynard:beta root# cat /private/etc/apache2/users/chrismm.conf<br />
<directory "/Users/chrismm/Sites/"><br />
    Options Indexes MultiViews ExecCGI<br />
    AllowOverride None<br />
    Order allow,deny<br />
    Allow from all<br />
</directory><br />
</code></p>
<p>See that?  All I added was &#8220;ExecCGI&#8221; at the end of that Options statement.   We&#8217;re halfway done now!  </p>
<p>One more change&#8230;</p>
<p>Go ahead and open up &#8216;/private/etc/apache2/original/httpd.conf&#8217; in your text editor of choice, and search for &#8221;    #AddHandler cgi-script .cgi&#8221;</p>
<p>Go ahead and remove the &#8216;#&#8217; mark, save and exit.</p>
<p>Now, let&#8217;s restart the webserver&#8230; </p>
<p><code><br />
killall -HUP httpd<br />
</code></p>
<p>Done!</p>
<p>And now, you can use your CGI and be happy. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p></username></p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/howto-enable-cgi-in-the-builtin-osx-webserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cPanel TCP and UDP ports&#8230;</title>
		<link>http://serveradmins.net/cpanel-tcp-and-udp-ports/</link>
		<comments>http://serveradmins.net/cpanel-tcp-and-udp-ports/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 03:26:40 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[passive]]></category>
		<category><![CDATA[pop3]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[udp]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=69</guid>
		<description><![CDATA[The ports necessary for creating a useful and successful firewall for a cPanel hosting machine.  This includes the UDP, TCP and Passive Port port ranges.]]></description>
			<content:encoded><![CDATA[<p>A little post here, more for reference than anything&#8230;   Here&#8217;s a list of the common ports used by cPanel for your firewall building pleasure&#8230;</p>
<p>TCP<br />
21 FTP<br />
22 SSH<br />
25 SMTP<br />
26 SMTP (Alternative port, configurable via WHM)<br />
80 HTTP<br />
110 POP3<br />
143 IMAP<br />
443 HTTPS<br />
465 SMTPS<br />
993 IMAP4<br />
995 POP3<br />
2082 cPanel (NON Encrypted)<br />
2083 cPanel (HTTPS)<br />
2086 WHM (NON Encrypted)<br />
2087 WHM (Encrypted)<br />
2095 Webmail (NON Encrypted)<br />
2096 Webmail (Encrypted)<br />
3306 MySQL (Only if allowing Remote Connections)</p>
<p>&#8211;UDP<br />
53 DNS </p>
<p>It should be noted that if you&#8217;re firewalling off your server, you should open up a portrange for the FTP PassivePort Rolloff.  Typically these are higher up ports and a wide range, such as 30000-50000.  You&#8217;ll also need to modify your FTPd configuration to use this portrange as well.  If you don&#8217;t, you&#8217;ll see issues with FTP connections dropping, successful logins, but a hang, pause or delay when dong an ls or beginning a transfer that results in a dropped connection.  Typically this will affect ftp clients that are behind a firewall/router doing NAT translations.</p>
<p>Anyway, that&#8217;s it, quick and simple. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />    Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/cpanel-tcp-and-udp-ports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Basic IPFW firewall HowTo for FreeBSD&#8230;</title>
		<link>http://serveradmins.net/a-basic-ipfw-firewall-howto-for-freebsd/</link>
		<comments>http://serveradmins.net/a-basic-ipfw-firewall-howto-for-freebsd/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 01:42:27 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[allow]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[ipfw]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=65</guid>
		<description><![CDATA[How to setup and configure a basic firewall for FreeBSD using ipfw.]]></description>
			<content:encoded><![CDATA[<p>Of all the different OS&#8217;s and the multitude of firewall implementations for each, my favorite has to be FreeBSD&#8217;s IPFW ruleset.  It&#8217;s powerful, super efficient, and most of all, *EASY* to read! </p>
<p>So I&#8217;m just going to paste a sample firewall below, notate it heavily for you, and show you how to get it enabled.   </p>
<p>For newer FreeBSD builds, it&#8217;s enough to add <code>firewall_enable="YES"</code> to your /etc/rc.conf file and reboot.  This will load all the necessary kernel modules, and get you in shape.   You should know that by default FreeBSD defaults to a &#8216;default deny&#8217; policy.  This is *VERY* important to know.   What it means is that by default, your server isn&#8217;t going to open up any ports. You *WILL* be locked out if you do not have a firewall in place.  Don&#8217;t say I didn&#8217;t warn you!</p>
<p>So, with that being said, let&#8217;s get our firewall in built and in place, and then we&#8217;ll go about adding in the necessary options to ensure it comes up properly on boot.  It should noted here that you can build in a &#8220;Default to accept&#8221; option into the kernel or &#8220;firewall_type=&#8221;open&#8221; to the /etc/rc.conf to start up wide open.  This is the suggested practice as the chances are, you&#8217;re not close enough to your server to console it. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Let&#8217;s get our basic firewall going.   We&#8217;re going to open up 22 for SSH, 80 for web traffic, 25 for SMTP and 110/143 for POP3/IMAP mail.   The syntax is simple enough you should be able to customize it for your own needs, but always make sure your SSH port is accessible.  Also if you run SSH on an alternative port, you should modify that here.  You don&#8217;t want to lock yourself out now, do you?</p>
<p>So go ahead, login as root to your server, open up your text editor of choice.  For the purpose of this post, I&#8217;m going to assume you&#8217;re creating the file /etc/firewall.sh.  If not, modify where appropriate. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   You should also make sure this file is executable by root, otherwise it won&#8217;t fire off properly on reboot.</p>
<p><code><br />
#!/bin/sh</p>
<p>set -e</p>
<p>#First, let's clear out any chance of conflicting with other FreeBSD firewall configurations<br />
# and make sure we're starting from a fresh slate.</p>
<p>/sbin/sysctl net.inet.ip.forwarding=0 >/dev/null<br />
/sbin/ipfw -q list >/dev/null 2>&#038;1 || /sbin/kldload ipfw<br />
(/sbin/ipf -D) >/dev/null 2>&#038;1 || true<br />
(/sbin/kldunload ipl) >/dev/null 2>&#038;1 || true<br />
(/sbin/pfctl -d) >/dev/null 2>&#038;1 || true<br />
(/sbin/kldunload pf) >/dev/null 2>&#038;1 || true<br />
/sbin/ipfw -q /dev/stdin < < EOF<br />
flush<br />
delete set 31</p>
<p>#Open up our Loopback device.  There's almost never any reason to filter this.<br />
add allow ip from any to any via lo0</p>
<p>#Allow checking/maintenance of stateful rulesets<br />
add check-state</p>
<p>#Kill off any active/open sessions, pre-fw init.  We do this<br />
#to ensure that any connection to unauthorized ports is dealt with<br />
#and that all connections adhere to the policy...</p>
<p>add reset tcp from any to any established</p>
<p>    ##########################<br />
## Add Inbound Service Allowances ##<br />
    ##########################<br />
#Port 80: www<br />
add allow tcp from any to me 80 setup in<br />
#Port 22: SSH - Stateful connection (it's going to maintain a connection, not come and go)<br />
add allow tcp from any to me 22 setup in keep-state</p>
<p>#Port 21, and 30000-50000, FTP and Passive port rolloff.<br />
add allow tcp from any to me 21 setup in<br />
add allow tcp from any to me 30000-50000 setup in keep-state</p>
<p>#Port 53: DNS<br />
add allow udp from any to me 53 in </p>
<p>#Port 25, 110, 143.  SMTP, POP3 and IMAP<br />
add allow tcp from any to me 25 in<br />
add allow tcp from any to me 110 in<br />
add allow tcp from any to me 143 in</p>
<p>#ICMP/ping requests should be allowed through, fun stuff happens<br />
#if you don't allow this.  (see ptmu)<br />
add icmp from any to me icmptypes 8 in</p>
<p> #################################<br />
## Lets Deny some Packets. WOOOT ##<br />
 #################################</p>
<p>#These rules denies everything else, not explicitly listed above<br />
add deny tcp from any to me setup in<br />
add deny ip from any to me in</p>
<p> ##################<br />
## Outbound Ahoy! ##<br />
 ##################</p>
<p>#Wide open outbound filtering.  You could modify this section to default to deny<br />
#And then allow specific ports out.  I'm not going to do that here, but you should<br />
#be able to figure it out. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>add allow tcp from me to any setup out keep-state<br />
add allow ip from me to any out keep-state</p>
<p> ###########################<br />
## Last chain to make sure ##<br />
 ###########################</p>
<p>#One more time, just to be positive...<br />
add deny tcp from any to any setup<br />
add deny ip from any to any<br />
enable firewall<br />
EOF</p>
<p>#I set this because the default FreeBSD behavior is to keep a table open<br />
#for a session for 1 hour.  That's a LONG time on a production server.  We<br />
#Go for 10 mins here, but could be lowered drastically.</p>
<p>#Set TTL on Dynamic Rules to 10 Mins.  Formerly 1 hour.<br />
/sbin/sysctl net.inet.ip.fw.dyn_ack_lifetime=600 >/dev/null</p>
<p></code></p>
<p>Done!</p>
<p>Save your /etc/firewall.sh file, then make sure permissions are right on it&#8230;</p>
<p><code><br />
chmod 755 /etc/firewall.sh &#038;&#038; chown root:wheel /etc/firewall.sh<br />
</code></p>
<p>Open up your handy text editor again, and add the following lines to /etc/rc.conf at the bottom.</p>
<p><code><br />
firewall_enable="YES"<br />
firewal_script="/etc/firewall.sh"<br />
</code></p>
<p>Done!   </p>
<p>Please keep in mind that if you set &#8220;firewall_type=open&#8221; above, it may overrule this firewall_script variable, so it should be removed.</p>
<p>Congrats, reboot and enjoy your new firewall. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If this is something you&#8217;re interested in, leave a comment and let me know how and I can write a few more articles on more complex configurations quite easily. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/a-basic-ipfw-firewall-howto-for-freebsd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>cPanel backup and restore for disaster recovery purposes</title>
		<link>http://serveradmins.net/cpanel-backup-and-restore-for-disaster-recovery-purposes/</link>
		<comments>http://serveradmins.net/cpanel-backup-and-restore-for-disaster-recovery-purposes/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 03:18:22 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Utility]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[cpbackup]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[restoration]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=57</guid>
		<description><![CDATA[cPanel backups made fast and easy with rsync and NFS, shave hours off your backup and restoration times!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve run my share of Hosting operations as a Sr. Admin before and one thing that always *killed* me&#8230;  Server failures and restorations.</p>
<p>Every shop I&#8217;ve been in has primarily been a cPanel shop.   It&#8217;s what the market demanded, so it&#8217;s what we sold.  Not only was it simply &#8220;what the masses wanted&#8221;, it offered an entire suite of scripts, apps and A+ quality support and upgrades that almost brought a tear to my eye. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>However, the one thing it did not provide, was a quick n&#8217; dirty backup and restore system, let me explain.</p>
<p>cPanels backup system is based around the single user ideology.  When you backup a server, it does this on a per cpuser account basis.   Now this has it&#8217;s pros and it&#8217;s cons.   It&#8217;s nice in the fact that restoring/migrating/tinkering with a single account is easy and *very* fast when you need to do it.  The downfall is that when you have to restore 1500+ accounts all at one shot, it&#8217;s *slow*.   For every single account, it copies over the user data, rebuilds certain configs, clears out the package, brings the domain up and then moves onto the next account.</p>
<p>Now, from an customer support standpoint, this is somewhat nice when restoring a server as you can say &#8220;we&#8217;re restoring accounts that begin with A now, your account will go live as soon as it&#8217;s restored.&#8221;   The bad side of this is that as soon as those domains start to go live, your server starts to go under load.   As you restore more accounts, your configuration files get longer (taking longer to modify/update), Apache starts serving requests, mail is being processed, additional load is placed on the server.    </p>
<p>This, gets very slow, very quickly.</p>
<p>Now back in the day, we had a set of servers that housed upwards of 8000+ accounts per machine.   They were super lighweight, averaging 25-50M of data and *no* webtraffic, however with a standard pkgacct/restorepkg procedure, at 30-45 seconds per account, we were looking at somewhere in the neighborhood of 2-3 days to fully restore a server.    From a customer support standpoint, this *SUCKS*  You&#8217;ve got thousands of users down for multiple days while pkgacct sits there and does it&#8217;s thing&#8230;  Not pretty, in fact, just plain unacceptable.</p>
<p>Necessity being the mother of invention, myself and another admin set out to find the &#8220;better way&#8221; of doing this.   These accounts were only using around 10 or so G of disk space in total on the machine, it was fast hardware, there *HAD* to be a better way to do this and keep everything in cPanel happy.   One highly tuned NFS mount later (jumbo frames on a private network are your friend here, trust me. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ), and we had our methods in place.</p>
<p>If you open up /scripts/cpbackup on any cPanel machine (checked on 11.25 for this instance) and go to line 240, you&#8217;ll see two arrays.  @FILES and @DIRS.   These are the core files that cPanel needs to do it&#8217;s thing.</p>
<p><code><br />
my @FILES = qw(<br />
  /etc/exim.conf<br />
  /etc/exim.conf.local<br />
  /etc/exim.conf.localopts<br />
  /etc/namedb/named.conf<br />
  /etc/rc.conf<br />
  /etc/named.conf<br />
  /etc/proftpd.conf<br />
  /etc/localdomains<br />
  /etc/httpd/conf/httpd.conf<br />
  /usr/local/apache/conf/httpd.conf<br />
  /etc/group<br />
  /etc/shadow<br />
  /etc/master.passwd<br />
  /etc/passwd<br />
  /etc/fstab<br />
  /root/.my.cnf<br />
  /etc/ips<br />
  /etc/ips.remotemail<br />
  /etc/ips.remotedns<br />
  /etc/reservedips<br />
  /etc/reservedipreasons<br />
  /etc/quota.conf<br />
  /etc/wwwacct.conf<br />
  /etc/remotedomains<br />
  /etc/rndc.conf<br />
  /etc/secondarymx<br />
  /etc/my.cnf<br />
  /usr/local/cpanel/3rdparty/interchange/interchange.cfg<br />
);</p>
<p>my @DIRS = qw(<br />
  /etc/namedb<br />
  /var/lib/rpm<br />
  /var/lib/named/chroot/var/named/master<br />
  /etc/valiases<br />
  /etc/proftpd<br />
  /var/named<br />
  /etc/vfilters<br />
  /var/cpanel<br />
  /var/spool/cron<br />
  /var/cron/tabs<br />
  /var/spool/fcron<br />
  /usr/local/frontpage<br />
  /var/log/bandwidth<br />
  /etc/vdomainaliases<br />
  /usr/share/ssl<br />
  /etc/ssl<br />
  /var/ssl<br />
  /usr/local/cpanel/3rdparty/mailman<br />
);<br />
</code></p>
<p>You&#8217;ll also need to get /home/ (or wherever your user accounts are stored) and your MySQL DBs as well.</p>
<p>So, rsync these files and directories to your backup server, do a &#8216;mysqldump -A&#8217; for the global databases (careful with remove mysql servers, this can get ugly) and rsync on over /home/ to your NFS mount and voila!  You&#8217;ve got EVERYTHING necessary to do a super fast backup (line speed and disk speed being your limitations here) of your cPanel server.  Now subsequent backups using rsync will only update files that change, not the entire home directory, so they should be fairly lightweight and fast as well.  You can also get jiggy with &#8211;link-dest options in Rsync to create multiple nightly snapshots in a differential format as well.</p>
<p>Now, if the proverbial poo hits the cooling device, you perform a fresh install of your OS of choice, grab your cPanel installer and run it, and then just reverse rsync from your backup mount (make sure to use &#8211;delete!).  After that, one /scripts/upcp &#8211;force and your server is fully live!</p>
<p>In the case I mentioned above, this cut a server restoration down from days, to about an hour.  It allowed us to make 150+ cPanel servers perform nightly backups (a huge selling point to this day) and all with the tools built into a standard CentOS + cPanel setup.</p>
<p>If there&#8217;s any desire for a script to handle this, just go ahead and post in the comments below and I&#8217;ll whip something up nice and fast for you.  It&#8217;s fairly trivial and you can have this rolling in your operation in no time at all.</p>
<p>One item of note, you lose the ability to do single account restores from backup with this method.  It *is* an all or nothing, disaster recovery shot.  You can always copy over individual files and directories, but you lose the elegance of the cPanel native granular backups.</p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/cpanel-backup-and-restore-for-disaster-recovery-purposes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Port to PID mappings, or What process is using that port?</title>
		<link>http://serveradmins.net/port-to-pid-mappings-or-what-process-is-using-that-port/</link>
		<comments>http://serveradmins.net/port-to-pid-mappings-or-what-process-is-using-that-port/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 00:59:37 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[fuser]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[udp]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=54</guid>
		<description><![CDATA[fuser is awesome for port to pid mappings or what process is using a specific port.]]></description>
			<content:encoded><![CDATA[<p>Okay, I&#8217;m lazy.  I fully admit it.   Want proof?  Instead of writing up a huge long post articulating something with awesome analogies, I&#8217;m only going to talk about one command today. </p>
<p>Fuser.</p>
<p>Why? </p>
<p>fuser is awesome.  Not awesome in a &#8220;run it and it fixes everything&#8221; way, but awesome in a &#8220;What in the hell is binding to this port??&#8221; kind of way.   Two classic scenarios where this is handy&#8230;</p>
<p>1.  Apache won&#8217;t start, &#8220;Can&#8217;t bind to port ::80&#8243; or &#8220;Can&#8217;t bind to port ::443&#8243;, etc.  This typically means something else is already tied to that port, and won&#8217;t relinquish it&#8230; </p>
<p>2.  A security scan of your machine shows something funny running on port 6667&#8230; You didn&#8217;t start this or know what it is.  </p>
<p>What to do now? Well you can sift through netstat output, but that&#8217;s, well, boring and slightly annoying.</p>
<p>netstat output<br />
<code><br />
[root@vps ~]# netstat -anp |grep 80<br />
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3266/httpd<br />
tcp        0      0 127.0.0.1:58725             127.0.0.1:80                TIME_WAIT   -<br />
tcp        0      0 10.10.10.10:2078          192.168.1.23:63024          ESTABLISHED 18088/cpdavd - acce<br />
unix  3      [ ]         STREAM     CONNECTED     49222880 11574/dovecot-auth  /var/run/dovecot/login/default<br />
unix  2      [ ]         DGRAM                    6804658 14078/named<br />
</code></p>
<p>Okay now we see that 3266/httpd is running on 80.  Then we do this to find the process..</p>
<p><code><br />
[root@vps ~]# ps auxwww |grep 3266<br />
nobody    3266  0.0  0.3  65704  3516 ?        S    17:05   0:00 /usr/local/apache/bin/httpd -k start -DSSL<br />
root     21665  0.0  0.0   6024   640 pts/2    S+   18:51   0:00 grep 3266<br />
[root@vps ~]#<br />
</code></p>
<p>Okay there we go&#8230; </p>
<p>Now for hacked systems, this could (and probably) is fully forged for a lot of remote shells.  Going back to my previous post at http://serveradmins.net/ssh-on-nonstandard-ports-how-to-not-do-it/ which talks about priveleged ports, you could in theory have trojaned &#8216;ps&#8217;, top, etc masking that real process.  It may *look* like httpd, but bound to a port like 23425&#8230;     So dont&#8217;t trust that too much, but a bit on that in a second. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The fuser approach&#8230;</p>
<p><code><br />
[root@vps ~]# fuser -n tcp 80<br />
80/tcp:               3266  3267  3268  3269  3271 16078 18274<br />
[root@vps ~]#<br />
</code></p>
<p>Oh look at that a list of all pids bound to that port.  Nice, clean, to the point and easily parsable.    fuser rocks. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now a bit more about the masked processes&#8230; To run those down, here&#8217;s a quick tip.  Forget ps/top and your other normal utilities, /proc/ is your friend here&#8230;</p>
<p>Proc looks like this on a linux box&#8230;<br />
<code><br />
[root@vps ~]# cd /proc/<br />
[root@vps proc]# ls -al<br />
total 1<br />
dr-xr-xr-x 78 root     root        0 Jan 26 09:58 .<br />
drwxr-xr-x 24 chrismm  chrismm  1024 Feb  4 22:06 ..<br />
dr-xr-xr-x  4 root     root        0 Feb  5 05:05 1<br />
dr-xr-xr-x  4 root     root        0 Feb  5 05:05 11573<br />
dr-xr-xr-x  4 root     root        0 Feb  5 05:05 11574<br />
dr-xr-xr-x  4 dovecot  dovecot     0 Feb  5 05:05 11575<br />
dr-xr-xr-x  4 dovecot  dovecot     0 Feb  5 05:05 11576<br />
...<br />
...<br />
</code></p>
<p>These directories match the pids of the running process&#8230;   So if you have something advertising itself as &#8216;httpd&#8217; on port 234234 and you know it&#8217;s pid 3266, you&#8217;d just do the following&#8230;</p>
<p><code><br />
[root@vps proc]# cd /proc/3266<br />
[root@vps 3266]# ls -al<br />
total 0<br />
dr-xr-xr-x  4 nobody nobody 0 Feb  5 17:08 .<br />
dr-xr-xr-x 78 root   root   0 Jan 26 09:58 ..<br />
-r--------  1 root   root   0 Feb  5 18:56 auxv<br />
-r--r--r--  1 root   root   0 Feb  5 17:08 cmdline<br />
-rw-r--r--  1 root   root   0 Feb  5 18:56 coredump_filter<br />
-r--r--r--  1 root   root   0 Feb  5 18:56 cpuset<br />
lrwxrwxrwx  1 root   root   0 Feb  5 18:54 cwd -> /<br />
-r--------  1 root   root   0 Feb  5 18:56 environ<br />
lrwxrwxrwx  1 root   root   0 Feb  5 17:10 exe -> /usr/local/apache/bin/httpd<br />
dr-x------  2 root   root   0 Feb  5 18:49 fd<br />
?r--r--r--  1 root   root   0 Feb  5 18:56 io<br />
-r--------  1 root   root   0 Feb  5 18:56 limits<br />
-rw-r--r--  1 root   root   0 Feb  5 18:56 loginuid<br />
-r--r--r--  1 root   root   0 Feb  5 18:54 maps<br />
-rw-------  1 root   root   0 Feb  5 18:56 mem<br />
-r--r--r--  1 root   root   0 Feb  5 18:56 mounts<br />
-r--------  1 root   root   0 Feb  5 18:56 mountstats<br />
-r--r--r--  1 root   root   0 Feb  5 18:56 numa_maps<br />
-rw-r--r--  1 root   root   0 Feb  5 18:56 oom_adj<br />
-r--r--r--  1 root   root   0 Feb  5 18:56 oom_score<br />
lrwxrwxrwx  1 root   root   0 Feb  5 18:54 root -> /<br />
-r--r--r--  1 root   root   0 Feb  5 18:56 schedstat<br />
-r--------  1 root   root   0 Feb  5 18:56 smaps<br />
-r--r--r--  1 root   root   0 Feb  5 17:08 stat<br />
-r--r--r--  1 root   root   0 Feb  5 17:10 statm<br />
-r--r--r--  1 root   root   0 Feb  5 17:08 status<br />
dr-xr-xr-x  3 nobody nobody 0 Feb  5 18:56 task<br />
-r--r--r--  1 root   root   0 Feb  5 18:56 wchan<br />
[root@vps 3266]#<br />
</code></p>
<p>Bam, there you go.  cwd and exe are the things you&#8217;re looking for  It shows you the dir it was spawned from (typically a users homedirectory on a shared hosting machine) and the full path/binary actually being executed (usually lame perl/php listeners)&#8230;   Also the ./fd/ folder is kind of neat as it shows you all the open file handles tied up by that pid as well.</p>
<p>Anyway, /proc/ examination too, is for another day, I just wanted to ramble on about one of my favorite, neat little single use utilities that no one else seems to know about. fuser.  Enjoy. =)</p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/port-to-pid-mappings-or-what-process-is-using-that-port/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating the FreeBSD Ports tree, easily&#8230;</title>
		<link>http://serveradmins.net/updating-the-freebsd-ports-tree-easily/</link>
		<comments>http://serveradmins.net/updating-the-freebsd-ports-tree-easily/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 01:18:00 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Utility]]></category>
		<category><![CDATA[fastest_cvsup]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[how]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[portsnap]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[tree]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=52</guid>
		<description><![CDATA[How to get your FreeBDS ports tree updated and current, one way or another... =)

]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m feeling a bit lazy tonight, and wanted to get an update here, so for a bit I&#8217;ll show you a handy little tool to update your ports tree on FreeBSD.  After that, I&#8217;ll show you the ugly, old method.</p>
<p>Quick and easy&#8230;</p>
<p>Newer versions of FreeBSD come equipped with the &#8216;portsnap&#8217; utility.  This, makes it *VERY* simple to update your ports tree.  </p>
<p>For your first run, do this&#8230;<br />
<code><br />
portsnap fetch &#038;&#038; portsnap extract<br />
</code></p>
<p>This is going to grab a snapshot of the current ports tree, and simply extract it over your new tree, replacing *everything* as it goes.  You should only run the &#8216;extract&#8217; command the first time you run portsnap.</p>
<p>After that, you&#8217;ll want to run the following for any further updates&#8230;</p>
<p><code><br />
portsnap fetch &#038;&#038; portsnap update<br />
</code></p>
<p>Not only is this much quicker, it doesn&#8217;t overwrite everything. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you want to use this in a cron&#8217;d task, you should use the &#8216;portsnap cron 1&#8242; command.   It should be noted the number appended to the end of this is the number in seconds that portsnap will randomize the start of the app from.  For example, if you say &#8216;cron 2000&#8242;, portsnap will kick off *sometime* in the next 2000 seconds.  The reasoning for this is for larger serverfarms.  If you&#8217;re running that in cron on all of them and give portsnap a large window, it will keep them all from starting at the same time, loading the BSD servers and abusing your bandwidth.   I used 1 in the command above as I wasn&#8217;t really looking to use that. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Keep in mind this will only fetch the updates, you still need to update the tree afterwords&#8230;</p>
<p>A cron entry for this would look something like the following&#8230;</p>
<p><code><br />
0 3 * * * root /usr/sbin/portsnap cron &#038;&#038; /usr/sbin/portsnap update<br />
</code></p>
<p>So for normal, day to day operation once you&#8217;ve initialized your ports tree the following is what you&#8217;ll want to use and update.</p>
<p><code><br />
/usr/sbin/portsnap fetch &#038;&#038; /usr/sbin/portsnap update<br />
</code></p>
<p>Now, if you don&#8217;t have portsnap, you should use the following method to update your ports tree.  We&#8217;re going to go oldschool with cvsup here.</p>
<p>Edit:  From reader Bazzoola points out that this is outdated and antiquated and well, he&#8217;s 100% right.   Any current installations of FreeBSD should have the portsnap utility installed so this shouldn&#8217;t be necessary.  Consider it here for the sake of memories. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>First of all, let&#8217;s find our fastest cvsup mirror&#8230;</p>
<p><code><br />
[root@R34 ~]# cd /usr/ports/sysutils/fastest_cvsup/<br />
[root@R34 /usr/ports/sysutils/fastest_cvsup]# make &#038;&#038; make install<br />
</code></p>
<p>This is going to install the &#8216;fastest_cvsup&#8217; port&#8230;  Afterwords, for the US locale, you can run the following to find your fastest cvsup mirror&#8230;</p>
<p><code><br />
[root@R34 /usr/ports/sysutils/fastest_cvsup]# fastest_cvsup  -c us<br />
>>  Querying servers in countries: us<br />
--> Connecting to cvsup.us.freebsd.org [72.233.193.64]...<br />
    - server replied: ! Access limit exceeded; try again later<br />
    - time taken: 69.51 ms<br />
--> Connecting to cvsup2.us.freebsd.org [130.94.149.166]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 27.19 ms<br />
--> Connecting to cvsup3.us.freebsd.org [128.31.0.28]...<br />
    - server replied: ! Access denied<br />
    - time taken: 31.65 ms<br />
--> Connecting to cvsup4.us.freebsd.org [149.20.64.73]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 55.77 ms<br />
--> Connecting to cvsup5.us.freebsd.org [208.83.20.166]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 36.99 ms<br />
--> Connecting to cvsup6.us.freebsd.org [64.202.113.190]...<br />
    * error: connect: Invalid argument<br />
--> Connecting to cvsup7.us.freebsd.org [64.215.216.140]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.64 ms<br />
--> Connecting to cvsup8.us.freebsd.org [216.165.129.134]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 6.23 ms<br />
--> Connecting to cvsup9.us.freebsd.org [128.205.32.21]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.28 ms<br />
--> Connecting to cvsup10.us.freebsd.org [69.147.83.48]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 54.01 ms<br />
--> Connecting to cvsup11.us.freebsd.org [63.87.62.77]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 35.11 ms<br />
--> Connecting to cvsup12.us.freebsd.org [128.205.32.24]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.86 ms<br />
--> Connecting to cvsup13.us.freebsd.org [128.205.32.24]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 26.54 ms<br />
--> Connecting to cvsup14.us.freebsd.org [216.87.78.137]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 34.63 ms<br />
--> Connecting to cvsup15.us.freebsd.org [35.9.37.225]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 23.49 ms<br />
--> Connecting to cvsup16.us.freebsd.org [128.143.108.35]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 23.47 ms<br />
--> Connecting to cvsup17.us.freebsd.org [65.212.71.21]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 35.93 ms<br />
--> Connecting to cvsup18.us.freebsd.org [128.205.32.84]...<br />
    - server replied: OK 17 0 SNAP_16_1h CVSup server ready<br />
    - time taken: 3026.06 ms</p>
<p>>>  Speed Daemons:<br />
    - 1st: cvsup8.us.freebsd.org    6.23 ms<br />
    - 2st: cvsup16.us.freebsd.org   23.47 ms<br />
    - 3st: cvsup15.us.freebsd.org   23.49 ms<br />
[root@R34 /usr/ports/sysutils/fastest_cvsup]#<br />
</code></p>
<p>Cvsup8 it is!</p>
<p>So now, let&#8217;s get our ports-supfile in place&#8230;</p>
<p><code><br />
cp /usr/share/examples/cvsup/ports-supfile /root/<br />
</code></p>
<p>Now edit /root/ports-supfile and look for the following line&#8230;</p>
<p><code>*default host=CHANGE_THIS.FreeBSD.org</code></p>
<p>And modify it to read&#8230;<br />
<code>*default host=csup8.freebsd.org</code></p>
<p>Now, run the following to get *everything* up to date&#8230;</p>
<p><code><br />
cvsup -g -L 2 /root/ports-supfile<br />
</code></p>
<p>Voila, you have an updated ports tree. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/updating-the-freebsd-ports-tree-easily/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Systems Administration with Perl and SSH</title>
		<link>http://serveradmins.net/systems-administration-with-perl-and-ssh/</link>
		<comments>http://serveradmins.net/systems-administration-with-perl-and-ssh/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:54:10 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[Net::SSH::Perl]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[systems]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=45</guid>
		<description><![CDATA[ How to write a basic connection script using Perl's Net::SSH::Perl module.]]></description>
			<content:encoded><![CDATA[<p>Hey there!</p>
<p>Today I wanted to focus on something that&#8217;s helping me do my job in a more efficient fashion.  At a former workplace, I was responsible for ~200 high capacity webhosting machines, and a host of supporting machines.   Back then, I was a huge fan of a management system mostly comprised of SSH Keys and a ton of bash scripts.   It worked, quite well for the time, but if I could do it again, I&#8217;d go with a slightly more refined approach, which is what we&#8217;ll discuss today.</p>
<p>So, let&#8217;s get started.   The first thing you&#8217;ll need is a working perl installation, a few devel libs and a handful of perl modules.  </p>
<p><code> yum install gmp-devel</code><br />
<code>perl -MCPAN -e 'install Crypt::DH , Math::GMP,  Net::SSH::Perl'</code></p>
<p>This is going to install the GMP math development libraries necessary for Math::GMP to compile.   Math::GMP and Crypt::DH are prereqs for Net::SSH::Perl.</p>
<p>So once this is done, we can proceed. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code><br />
#!/usr/local/bin/perl -w</p>
<p>use strict;<br />
use warnings;<br />
require Net::SSH::Perl;</p>
<p>#declare our login vars...</p>
<p>my $user = "root";<br />
my $password = "SEKUREPASSWORD";<br />
my $server = "localhost";</p>
<p>#Setup our SSH Connection...<br />
my $ssh = Net::SSH::Perl->new($server,port=>22,use_pty=>1);</p>
<p>#Initiate out conneciton to the server...<br />
$ssh->login($user, $password);</p>
<p># Declare our variable for the request...<br />
my $uptime;</p>
<p># Run our SSH Command and retrieve the output...<br />
($uptime) = $ssh->cmd("/usr/bin/uptime");</p>
<p>print "\n$uptime\n";</p>
<p>exit 0; </p>
<p></code></p>
<p>That&#8217;s a very basic/barebones SSH Connection script&#8230;   If you have any questions or problems, please don&#8217;t hesitate to post in the comments. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   </p>
<p>Next up, we&#8217;ll go over a more complex variant of this script using subroutines and a few other nifty tricks. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/systems-administration-with-perl-and-ssh/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Perl module installation made easy. :)</title>
		<link>http://serveradmins.net/perl-module-installation-made-easy/</link>
		<comments>http://serveradmins.net/perl-module-installation-made-easy/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 00:43:03 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[redhat]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=46</guid>
		<description><![CDATA[A basic primer on installing perl modules.]]></description>
			<content:encoded><![CDATA[<p>Hey there!</p>
<p>I&#8217;m going to show you a few different ways to install Perl modules in a quick and easy way.  </p>
<p>First up, the one liner. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code>perl -MCPAN -e 'install HTML::Template'<br />
CPAN: CPAN::SQLite loaded ok (v0.199)<br />
CPAN: LWP::UserAgent loaded ok (v5.834)<br />
CPAN: Time::HiRes loaded ok (v1.9719)<br />
Fetching with LWP:</p>
<p>http://www.stathy.com/CPAN/authors/01mailrc.txt.gz</p>
<p>CPAN: YAML loaded ok (v0.71)<br />
Fetching with LWP:</p>
<p>http://www.stathy.com/CPAN/modules/02packages.details.txt.gz</p>
<p>Fetching with LWP:</p>
<p>http://www.stathy.com/CPAN/modules/03modlist.data.gz</p>
<p>Database was generated on Thu, 21 Jan 2010 20:40:30 GMT<br />
Updating database file ...</p>
<p>Gathering information from index files ...<br />
Obtaining current state of database ...<br />
Populating database tables ...<br />
....  snipped for brevity....<br />
Running make install<br />
Prepending /home/.cpan/build/HTML-Template-2.9-bALXdn/blib/arch /home/.cpan/build/HTML-Template-2.9-bALXdn/blib/lib to PERL5LIB for 'install'<br />
Installing /usr/local/lib/perl5/site_perl/5.8.8/HTML/Template.pm<br />
Appending installation info to /usr/local/lib/perl5/5.8.8/x86_64-linux/perllocal.pod<br />
  SAMTREGAR/HTML-Template-2.9.tar.gz<br />
  /usr/bin/make install UNINST=1 OTHERLDFLAGS=-L/usr/lib64 LDFLAGS=-L/usr/lib64 EXTRALIBDIR=/usr/lib64 -- OK<br />
[root@vps ~]#<br />
</code></p>
<p>And there you go, quick and easy.   </p>
<p>Now a lot of Perl modules are going to require other modules to be built, in which case, you&#8217;ll see something like this&#8230;<br />
<code><br />
Writing Makefile for Net::SSH::Perl<br />
---- Unsatisfied dependencies detected during ----<br />
----     TURNSTEP/Net-SSH-Perl-1.34.tar.gz    ----<br />
    Crypt::DSA [requires]<br />
    Convert::PEM [requires]<br />
    Crypt::RSA [requires]<br />
    Math::Pari [requires]<br />
    Crypt::IDEA [requires]<br />
    Digest::BubbleBabble [requires]<br />
    Crypt::DH [requires]<br />
    Math::GMP [requires]<br />
Shall I follow them and prepend them to the queue<br />
of modules we are processing right now? [yes]<br />
</code></p>
<p>Just go ahead and answer &#8220;yes&#8221; here, and let it continue&#8230;  cpan *should* be smart enough to grab all of the required sources and build what you need, but sometimes, not so much. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />    Perl modules are basically subroutines packaged into nice containers, ready to use.  Now some of these require specific programs, libraries or even other perl modules to do what they do best.  When a module has a large chain of dependencies and one of those fails, it can bring the whole show to a screeching halt.  </p>
<p>For an example here, I&#8217;ll use Net::SSH::Perl, which happens to be what I use for a host of different things.</p>
<p>If you use the above listed one-liner to install it, i.e., </p>
<p><code>perl -MCPAN -e 'install HTML::Template'</code></p>
<p>You&#8217;re going to end up seeing this&#8230;</p>
<p><code><br />
Files=12, Tests=106,  1 wallclock secs ( 0.07 usr  0.04 sys +  0.40 cusr  0.14 csys =  0.65 CPU)<br />
Result: PASS<br />
  TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
Tests succeeded but 2 dependencies missing (Crypt::DH,Math::GMP)<br />
  TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
  [dependencies] -- NA<br />
Running make install<br />
  make test had returned bad status, won't install without force<br />
</code></p>
<p>So, we have a dependency of Net::SSH::Perl that simply isn&#8217;t present.  So let&#8217;s go ahead and get it installed&#8230;</p>
<p>On a RH Based system (CentOS/Trustix/RedHat Enterprise Linux), you can do the following&#8230;</p>
<p><code><br />
yum install gmp-devel<br />
</code></p>
<p>On a Debian based distribution (Debian/Ubuntu, etc)<br />
<code><br />
apt-get install libgmp-ocaml<br />
</code></p>
<p>On FreeBSD, I prefer prots builds personally, so let&#8217;s do the following&#8230;<br />
<code><br />
cd /usr/ports/math/libgmp4<br />
make &#038;&#038; make install<br />
</code></p>
<p>So, now that you&#8217;ve got that taken care of, let&#8217;s proceed. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code><br />
 perl -MCPAN -e 'install Net::SSH::Perl'<br />
...<br />
...<br />
Tests succeeded but one dependency not OK (Crypt::DH)<br />
  TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
  [dependencies] -- NA<br />
Running make install<br />
  make test had returned bad status, won't install without force<br />
</code></p>
<p>So, we need to build Crypt::DH&#8230; Apparently dependency handling isn&#8217;t too bright in this case. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />    I&#8217;ll save you the trouble of the blow-by-blow here.  We need to install Crypt::DH which depends on Math::BigInt::GMP.   So, use your handy oneline skills, and get Math::BigInt::GMP installed, then do the same for Crypt::DH.   You should now have a working Net::SSH::Perl installation. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can specify multiple packages in the following way&#8230;</p>
<p><code><br />
perl -MCPAN -e 'install Net::SSH, Term::ReadLine'<br />
</code></p>
<p>The other option, should cpan fail, is to just grab the module package yourself, which is typically a .tar.gz file, and perform the following.</p>
<p><code><br />
wget http://search.cpan.org/CPAN/authors/id/T/TU/TURNSTEP/Net-SSH-Perl-1.34.tar.gz<br />
tar -xzvf Net-SSH-Perl-1.34.tar.gz<br />
cd ./Net-SSH-Perl-1.34<br />
perl Makefile.PL<br />
make &#038;&#038; make install<br />
</code></p>
<p>That&#8217;s more or less what cpan is doing, except it will try to sort out requirements and dependencies for you (when it can).</p>
<p>So I hope you&#8217;ve learned a bit of something about getting Perl modules installed and running. If you have any questions, feel free to leave a comment. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/perl-module-installation-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->