Changing the Default Interface in cPanel

November 6th, 2009 by Tony Rogers

One issue that we ran into dealing with cPanel installations was if the main interface of one of our servers happened to be configured as something other than “eth0″.  Sometimes they will be configured as “eth1″.  This can be an issue in cPanel because the default interface in cPanel is always set as  “eth0″.

This causes issues when binding new IP addresses through the control panel and adding multiple IP addresses to the interface using cPanel’s ipaliases service.

To get around this, we will need to find one of cPanel’s configuration files.  For this setting, we need to edit the “/etc/wwwacct.conf” file.  Open this file in your favorite text editor and file the line:

ETHDEV eth0

This is pretty self explanatory, but we will need to change the “eth0″ to the name of our interface.  So in my previous example I would set this to:

ETHDEV eth1

Save the file and you are all set.  If you already added additional IPs through the control panel, you can run the following command to bind those IPs correctly:

/etc/init.d/ipaliases restart

This should get you up and running and on to getting your websites setup.

Just for Fun: The Story of an Accidental Revolutionary

October 15th, 2009 by Rob Magnanti

I recently re-read the autobiography of Linus Torvalds: Just for Fun: The Story of an Accidental Revolutionary. For the uninitiated, Linus Torvalds is best known as the creator and now project coordinator of the Linux kernel. Being that slhost.com literally runs on Linux, this blog seemed like a good place to share a quick review of the book.

Just for Fun was written by Linus Torvalds with David Diamond serving as the co-writer. The biography follows the life of Linus Torvalds with a number of essays by the famous programmer mixed in. Torvalds himself provides a majority of the narrative. Co-writer David Diamond provides a number of chapters as well, detailing his experiences with Torvalds and his family throughout the production of the book.

The biography begins with Torvalds childhood, who from the first words of the book proclaims “I was an ugly child”. After his adolescence, the story moves on to the development of Linux. Started as nothing more than a terminal emulation program, Torvalds’ objective was to replace the default application which came with MINIX (the hobbyists operating system Linus was using on his newly purchased 386.)

From there we gain insight into the growth of Linux from an operating system developed by a self-proclaimed “geek” in his early 20’s, to the largest community driven, open source software project the world has ever seen. Torvalds discusses balancing his new marriage, move to the United States and birth of his children with becoming the poster boy of the open source movement. We learn of his first meeting with Steve Jobs and the first time he realizes he is a “paper millionaire.”

After discussing the growth of Linux, the last section of the book features a number of essays by Torvalds. While still interesting, the last quarter of the book seems to drag a bit compared to the rest. We get chapters on Linus’ thoughts on intellectual property, open source, dealing with fame along with his take on the meaning of life.

All in all, Just for Fun was a great, quick read. The fact that a “nerd” just out of his teens can create a revolution by locking himself in his bedroom trying to create a better terminal emulation program inspiration. While certain parts of the biography can get pretty technical (like when Linux is explaining his infamous flame war with Andrew Tanenbaum over monolithic vs. micro kernels), this would be a good book for anyone at all interested in technology, open source or software development.

Useful features of Bash

October 6th, 2009 by Rob Magnanti

Spend a lot of your day looking at a Bash command line? I do. Because of this, I try to be as efficient as possible when using Bash. In this article I will describe some of the bash features I commonly use to help me save time.

Repeat the last argument of your last command:
mkdir /path/to/exampledir
cd !$

Run your last command again:
!!

Reversed History Search
CTRL-R (start typing a command that would be in your Bash history)

Execute last command starting with…
!COMMAND (Example: !vim)

Print the last command that contained…
!string:p (Example:!ssh:p may return ssh root@192.168.1.1)

Execute last command that contained…
!?string (Example:!?passwd may expand to cat /etc/passwd)

Previous command substitution:
!command:s/search/replace/ (Example:!vim:s/passwd/shadow/ would replace vim /etc/passwd with vim /etc/shadow)

Return the exit status of your last command:
$?

Run a numbered command from your history
!NUMBER

Last but not least….Brace Expansion. This is best explained with some examples:

echo {five,six,seven,eight}
five six seven eight

echo happy{" birthday"," anniversary"}
happy birthday happy anniversary

echo {Mac,Cent}OS
MacOS CentOS

Are you asking yourself, “how is that useful?”. Here’s how:

cp /etc/httpd/conf/httpd.conf{,.bak}
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak

rm -f /var/log/mail.log.{3,5,7,9}
rm -f /var/log/mail.log.3 /var/log/mail.log.5 /var/log/mail.log.7 /var/log/mail.log.9

Have any other useful Bash tricks? Post them up as comments!

Using curl as a command line SOAP client

September 28th, 2009 by Rob Magnanti

We use Bash scripting at slhost.com pretty heavily for automating tasks. Lately we’ve had the need to tap into some of our systems SOAP API’s more frequently. In the past, when we needed to use SOAP we would do so from PHP or Ruby. Recently we’ve started using command line curl as a SOAP client more and more often. Having curl make SOAP requests is actually a very easy thing to do. Let’s say for example we wanted to create a SOAP request that used our mail server’s API to add a new domain to the server. After examining the WSDL, we find that the request needs to look like the following:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<AddDomainEx xmlns="http://tempuri.org/">
<AuthUserName>username</AuthUserName>
<AuthPassword>password</AuthPassword>
<DomainName>mydomainname.com</DomainName>
</AddDomainEx>
</soap12:Body>
</soap12:Envelope>

To post this data using curl, we would take the XML anove and dump it into a file. In this case, let’s call it soap.xml. Once we have the file, the next step is to post it using curl.

curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction: AddDomainEx" -d @soap.xml http://www.mymailserver.com/Services/svcDomain.asmx?op=AddDomainEx

Being able to make SOAP requests from the command line and within Bash scripts can be very useful.

Modifying the AP_DOC_ROOT in suEXEC on CentOS

August 18th, 2009 by Rob Magnanti

suEXEC is a very powerful feature of Apache that provides users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web-server.  This is very useful in shared web hosting as a way to tighten up security.  By default when Apache / suEXEC is installed using the standard RPM’s or Yum it assumes that your document root is going to be /var/www.  This means that all CGI and SSI programs must reside somewhere within /var/www.  This is generally fine.  However, let’s say you partitioned your system in a way that you wanted /home to contain your web content.  If using suEXEC you would receive errors when trying to run CGI programs under /home (since they are not part of /var/www).  This article will show you how to re-install Apache / suEXEC to change the document root to /home.

Note:  This article assumes that you are running a fresh server w/o a control panel like Plesk or cPanel.  If you are using a control panel, recompiling Apache to modify these settings will likely break a number of things and should not be attempted.

Read the rest of this entry »

Virtuozzo VPS Memory Parameters

August 6th, 2009 by Tony Rogers

Have you ever run “cat /proc/user_beancounters” from the command line and wondered what each resource was?

Included in the output of this command are the three main memory limits that are set using the UBC-Style memory configuration.  They are privvmpages, oomguarpages, and vmguarpages.  These parameters limit different aspects of the memory allocated to each container on the hardware node.

Continue on to the next page for information on these parameters…

Read the rest of this entry »

What Hosting Package Should I choose?

July 30th, 2009 by Jeffrey Cagwin

When it comes to choosing a plan or upgrading, there are usually three options in the web hosting world to choose from: Shared hosting, Virtual Private server, and dedicated server. If your wondering “which one should I choose”, then this article may help you decide. First off, lets get the definitions of these 3 straight.

Shared Hosting – This usually refers to buying a bit of space on a server. You are sharing the server with tens, maybe even hundreds of other people. Shared hosting is for small to medium sized sites. If you own a large site or a busy forum, you may want to think about upgrading your hosting. Shared plans usually limit the number or domains you can host per account.

Virtual Private server – This is for people who need root access to the server to install their own software. Basically a chunk of the server is blocked off for each VPS user. There are usually not that many people sharing a server with VPS plans. VPS is for those people who need the control of a dedicated server but cannot afford the price

Dedicated server
— This is where you get the whole server to yourself and share it with no one. This is for large or intensive CPU or RAM sites. With a dedicated server you have full root access,can install your own software, and can do pretty much whatever you want with the server. Dedicated servers are generally pretty costly in terms of price. This kind of hosting is best suited for a busy portal or forum.

Shared hosting account – provides shared server resources to many websites

Pros:
* Affordable prices;
* Ease of use with least technical knowledge required;

Cons:
* CPU and Memory units are unequally shared by all users;
* Resource overusage is not tolerated and performance is optimized for the average user;
* Custom server configurations are not allowed. Such would have effect on all users on the server;

Virtual private server (VPS) – a server is virtually divided into several virtual servers with guaranteed Memory and CPU units

Pros:
* Dedicated CPU and Memory units;
* Performance is very flexible. Burst CPU and Memory usage is allowed even though for short periods (less than 5 mins);
* Easy to upgrade / downgrade between plans;
* Custom server configurations are allowed;
* Ease of use – usually website control panels (cPanel) do not differ from those for the shared hosting;

Cons:
* Higher prices than Shared;
* Virtualization works with software limits which are vulnerable to heavy overloads. If a VPS has very heavy resource overusage the whole VPS node may be affected;

Dedicated servers – preferred by professionals who have better understanding of their sites’ needs

Pros:
* Guaranteed dedicated CPU and Memory units;
* Custom server configurations are allowed;
* Full access to the server configuration;
* Easy Memory upgrades;

Cons:
* Higher prices than VPS;
* Advanced skills and knowledge are required to take full advantage of the server;
* No performance flexibility;
* Hard CPU and Disk upgrades;

Useful Hidden cPanel Commands

July 26th, 2009 by Rob Magnanti

Have you ever locked yourself out of your server while making some iptables changes? What about when you change your SSH port and then forget what you set it to? These are both fairly common support requests that we receive at slhost. Fortunately, in many cases this is something our customer’s can fix on their end as long as they are using cPanel as their control panel.

cPanel comes with a number of ‘hidden’ autofix commands that allow for administrators to fix common problems simply be logging into WHM and going to a special URL. Two of the most useful ones I’ve seen are flushing iptables and restarting SSH in “safe mode” (basically the default settings and port).

Flushing iptables rules: http://mydomain.com:2086/scripts2/doautofixer?autofix=iptablesflush

Restart SSH in safe mode: http://mydomain.com:2086/scripts2/doautofixer?autofix=safesshrestart

Once you hit the URL you will be prompted to log in. Simply enter your root password and cPanel will do the rest. These have definitely saved me on more than one occasion when my attempt to ’secure’ my server worked a little too well.

* I should note that if you happen to also lock yourself out of WHM through iptables, you will not be able to hit the URL’s I mentioned.  In that case, contact support.

Use Cacti to Graph Everything

July 23rd, 2009 by Rob Magnanti

Cacti is a network graphing solution that we use at slhost.com to monitor everything from the temperature outside of our data center, the bandwidth usage on all of our switches and routers to the number of questions our network administrator Tony asks me in a day.  It can be used to graph essentially anything and would be a very useful tool to any of our customers looking to monitor performance on their VPS.  Keeping historical data of how your VPS is performing is a very good step to tuning and optimizing your system.  This article will walk you through installing Cacti and setting up some custom graphs to monitor your Virtuozzo resource usage.

Continue on to the next page for instructions on installing Cacti.

Read the rest of this entry »

We have a blog!

July 10th, 2009 by Rob Magnanti

Welcome everyone to the new slhost.com blog!  As you may have noticed we launched our new, re-branded website about a month ago.  With that we wanted to begin to be more interactive with those hosting with us.  We are hoping that this blog will bring us closer to our clients and colleagues on both a personal and professional level.  Our knowledgeable staff will also be providing tips, tricks and articles on the hosting industry in general.

My name is Rob and I’ve been with slhost.com for two years and in the web hosting industry for the last five.  I am hoping to be able to provide news from inside slhost as it happens, as well as share with you some of my experience in the hosting and development fields.  I may even throw in a personal anecdote or two along the way.

We’re hoping to get some feedback from everyone on the new blog.  Feel free to register for the blog and make a comment. Also be sure to subscribe to our news feed if you find the content useful.  We plan on adding to the blog frequently.