Featured Posts

Tips to Reduce Your Customer Support Costs When hosting websites, whether as a mainstream hosting provider, a hobby, or to supplement another service, it's your job to make sure your customers have access to technical support in case they need...

Read more

Roundcube: MySQL or SQLite? cPanel 11.25 introduces a new feature: The ability to have RoundCube use SQLite instead of MySQL. After benchmarking resource usage and performance, I've come to the conclusion that SQLite is definitely...

Read more

Simple Bash Script to Fix Account Permissions This is a simple bash script I wrote to fix the permissions and ownership of files within a cpanel account. To use, simply copy the script your server, chmod 755, and pass the usernames as arguments: ./fixperms...

Read more

Re-Installing Auxiliary cPanel Software Cpanel has a lot of supporting software that you may be using on your server. In case something goes amiss, here is a list of scripts that reinstall cpanel-provided software on your system. For most all...

Read more

10 Free Monitoring Solutions to Consider Server and network monitoring can be crucial to a host's success. I mean, how embarrassing is it when your customers are aware of downtime before you are? You don't have to pay big bucks or spend loads...

Read more

The cPanel Admin Rss

Managing Multiple Hard Drives with cPanel

Posted by Vanessa | Posted in Misc | Posted on June 6, 2010

1

If you have a server with single standalone drives, you may have considered the possibility of adding additional hard drives to provide more disk capacity to your system. Luckily, this is very easy to set up and use with cPanel.

First things first, I’ll assume that you already have the hard drive physically installed in your system. This guide will show you how to partition, format, and configure cPanel to use an additional hard drive, in the simplest way possible.

10 Free Monitoring Solutions to Consider

Posted by Vanessa | Posted in Misc | Posted on January 17, 2010

1

Server and network monitoring can be crucial to a host’s success. I mean, how embarrassing is it when your customers are aware of downtime before you are? You don’t have to pay big bucks or spend loads of time setting up monitoring for your server. We’ve compiled a list of free monitoring solutions you can use to guarantee minimal downtime for your users, and show customers how reliable your service is!

11 Ways to Free Up Disk Space on a cPanel Server

Posted by Vanessa | Posted in Misc | Posted on January 16, 2010

4

I’m sure that most of you have been to the point where one or more of your servers start to fill up as you get more customers. The server’s performing just fine, but there’s one problem…you’re out of disk space! Here are a few simple tricks to freeing up disk space on your cPanel server to help maximize your server’s potential.

1) Delete user cPanel and Fantastsico backups

If you have the backup feature in cPanel enabled, chances are your users are storing the backups on the server instead of downloading and removing them. On larger servers, this can account for a lot of disk space usage. You may want to consider warning your users ahead of time that backups will automatically be removed from the server after a certain period of time or on certain dates.  You can mass-delete all user cPanel backups on the server with this command:

for user in `/bin/ls -A /var/cpanel/users` ; do rm -fv /home/$user/backup-*$user.tar.gz ; done

To remove Fantastico backups:

rm -rfv /home/*/fantastico_backups

2) Move your backups offsite

Similarly to above, if you’re using the cPanel Backup System and are storing your backups locally on the server, you could be using twice as much space as you need to. Consider mounting a backup server to your hosting server and storing the backups there (there is an option to mount external media in WHM > Configure Backups) or using an alternate method of backing up your server that doesn’t involve storing the backups locally. While local backups may be convenient at times, they tend to be useless when a server failure occurs.

3) Delete cPanel File Manager temp files

When users upload files in File Manager within cPanel, File Manager creates a temp file that may or may not get removed upon upload. You can remove these files using this command:

rm -fv /home/*/tmp/Cpanel_*

4) Move or archive logs

Most of the server’s logs are stored in /var/log, which can get rather large on more populated servers. You can change the length of time and frequency of the log rotation in /etc/logrotate.conf, and enable compression to save additional space (at the expense of CPU when the logs are being gzipped). If you want older logs, consider creating a cron job to periodically transfer them to a backup or log server so they aren’t taking up space on your hosting server.

5) Remove cPanel update archives

Cpanel and EasyApache updates tend to leave behind files that you probably don’t need. The following can be deleted or moved to a backup server to free up a little bit of space:

/usr/local/apache.backup*

/home/cpeasyapache (actual name may vary depending on cpanel version)

6) Clean up Yum files

Yum updates leave package cache files on the server. You can clean up all unneeded yum files by running:

yum clean all

7) Remove pure-ftp partials

When your users upload files to the server via FTP when your server runs pureFTP as an FTP daemon, the FTP server creates temporary files starting with .pureftpd-upload* that get renamed the the actual filename when the upload completes. If the upload doesn’t complete, these files are left on the server. You can find and delete these by running:

locate .pureftpd-upload | xargs rm -fv

*If you don’t run an updatedb regularly, you might want to do so before running this command

8) Decrease the reserved disk space

By default, Linux reserves 5% of the disk space from each partition for the root user, so root can still log in even if the disk is full. You may have noticed when running a df that you may be using 900GB out of a 1TB drive, but only have 50GB available…that’s because the other 50GB is reserved.

For larger drives, you really don’t need the whole 5%. I would recommend setting this value down to 2500 blocks so you can utilize more of the disk space. You can do this with tune2fs:

tune2fs -r 2500 /dev/sda1

You’ll want to probably man the tune2fs command before you use it for other options on setting the reserved space for your partitions.

9) Remove unneeded accounts

If you have a larger churn rate you probably have some user accounts laying around on your server that you don’t need. Check out WHM > List Suspended Accounts (or ls /var/cpanel/suspended) and look for suspended accounts that you may be able to remove from the server to free up space. You can terminate accounts in WHM > Terminate an Account or using the command /scripts/killacct <user> <y/n> (y/n indicating whether to save the DNS records)

10) Check for contrabands

As a hosting provider you should have a Terms of Service that specifically tells your customers what they can (or rather cannot) store on your server. Most hosts have specific rules about the hosting of non-website-related backups and copyrighted material, but don’t pro actively scan their servers for it.  It wouldn’t hurt to run a few locate commands to find common files associated with copyright violations, like .mp3, .avi, .exe, etc, and have your customers remove them from the server. I once cleared over 300Gb of space on a server just by having customers remove contraband files from the server. On top of that, you’re also preserving the integrity of your business from a legal standpoint.

11) Consider a larger server

Some of your customers may have a legitimate need for large amount of disk space, and therefore you may be unable to keep the disk space usage on your server at a reasonable level. A lot of hosting providers have alternate servers that are more “low key” but have huge disk storage volumes to accommodate customers that have larger sites. You might want to consider investing in a server that will be less populated and only the users that occupy a large amount of space.

Adding Services to Chksrvd for Monitoring

Posted by Vanessa | Posted in Misc | Posted on December 28, 2009

0

Chkservd is the service in cPanel that checks to make sure that services are running, then restarts them if necessary.  It’s also responsible for the ‘Service Manager’ section in cPanel, which is also an interface where added services can be easily checked on and off.

Service files are in /etc/chkserv.d/

To add a new service, create a line in ”’/etc/chkserv.d/chkservd.conf’” in the same format as the others:

service:1

1 means the service should be enabled, 0 means it’s off.

In ”’/etc/chkserv.d”’ each service has its own file.  Create a file called as the name of the service you are monitoring.  The contents of the file are in the format of:

#SERVICE = PORT, SEND, RESPONSE, RE-START COMMAND

There are two ways that cPanel checks services with chkservd:

*Connection-based monitoring – By default, cPanel will try to connect to the service’s specified port, issue a command, and if a response is received within 10 seconds it will consider the service to be online. For instance, FTP:

service[ftpd]=21,QUIT,220,/scripts/restartsrv_ftpserver

*Process-based monitoring – cPanel will check for a specific process to determine whether it is online. For instance, named:

service[named]=x,x,x,/scripts/restartsrvr_bind,named,named|bind

If you have more than one restart command, you can separate them with semicolons in order of preference that they should be run.  Output of these commands will be logged to the chkservd.log

After you’ve created the service’s configuration file, restart chkservd:

/etc/init.d/chkservd restart

You should then see the service listed in WebHost Manager in the ‘service manager section’

Chkservd logs are in /var/log/chkservd.log.  Checks are done every 8 minutes, and everyone online service gets a +, offline services get a -.  If the service is determined to be offline, the restart command(s) specified in that service’s chkservd configuration file is issued and the output is logged.