Featured Posts

Using DKIM with Exim and cPanel Similar to the intentions of SPF records and DomainKeys, DKIM is intended to authenticate a sender by using a public/private key pair to digitally sign email, therefore increasing deliverability. At this...

Readmore

Copy Outgoing Email on a cPanel Server with Exim A common request we get is how a user can automatically BCC outgoing email to another address. This is most often requested by law firms that need to be able to retain copies of communication. Forwarding...

Readmore

Do You Care About Your Customers' Data? I was working a case last week for a new client that's been hosting local business websites for over three years. As with all of my case studies, I did a short survey of the client's infrastructure, processes,...

Readmore

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...

Readmore

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...

Readmore

The cPanel Admin Rss

Manually Upgrading MySQL

Posted by Mark | Posted in Misc | Posted on April 13, 2011

2

If at all possible, you should use /scripts/mysqlup to do a MySQL upgrade, however, if you need a version of MySQL outside of what they are offering in current cPanel versions, it is possible to upgrade manually.

These are the instructions for performing a manual upgrade of MySQL to 5.1.30, but this typically applies to all versions over 4.1 and higher. Typically it is best to upgrade to whatever the latest stable branch of MySQL is and apply these instructions to install the RPMS.

If this is on a live system, make sure to make backups of the databases.


mkdir /root/dbbackups

touch /root/dbbackups/list
for db in `mysql -e 'show databases' |awk '{print $1}' | grep -v Database`

do

mysqldump --add-drop-table $db > /root/dbbackups/$db.sql && echo $db >> list

done
mkdir /root/sqllibs
cp /usr/lib/libmysqlclient.* /root/sqllibs

Do a search for all installed MySQL packages to be removed:
rpm -qa | grep -i mysql-

This should present a list of 5 or 6 MySQL RPM’s that are installed, likely. Uninstall them one by one with the rpm -e like so:
rpm -e MySQL-devel-4.1.21-0.glibc23

Some packages are dependencies of each other, so you may need to remove one before being able to remove another.

Download the binaries for the OS version and MySQL version you are using from the cPanel repo:
http://httpupdate.cpanel.net/mysqlinstall/

execute rpm -i for each package (ex: pm -i MySQL-client-5.1.30-0.glibc23.i386.rpm)

Edit /var/cpanel/cpanel.config and change the MySQL version to 5.1 (or whatever version you’re running now). Then run this command:
touch /etc/mysqlupdisable

This will keep cPanel from resetting or reverting back to its original MySQL version during updates.

Restart MySQL first to make sure that it can at least start (which it should). Once you’ve verified this, run mysql -V to make sure that the correct version is installed. You should see output similar as below:
root@server [~]# mysql -V
mysql Ver 14.13 Distrib 5.1.30-beta, for pc-linux-gnu (i686) using readline 5.0

MySQL should now be up and running, but it’s likely that trying to log in directly as the root user will fail. Before Following the below steps, make sure you can do a ‘mysql -u root’ and log in successfully. If not, you’ll need to set the root password. By default, MySQL has a blank root password which will need to be set to ours…twice.
Recopy the libs, but don’t overwrite any that already exist:
mv /root/sqllibs/libmysqlclient.* /usr/lib/mysql/

Next update cPanel’s PHP and DBD MySQL bundle for perl by executing the following:
/scripts/perlinstaller --force Bundle::DBD::mysql
/scripts/makecpphp

Verify that phpMyAdmin and php -m load properly and without errors.

 

Changing an FTP User’s Path

Posted by Vanessa | Posted in Misc | Posted on May 24, 2010

3

By default, your main FTP (cPanel) user will have and FTP path to the user’s home folder, and each FTP user you create after that will have a path that you specify with you create the account in cPanel > FTP accounts.

Unfortunately, cPanel’s interface does not currently let you change the FTP paths for your main account or sub-accounts, but you can easily change these in the FTP user configuration files. Each cPanel user has a file in /etc/proftpd (yes, even if you use pure-ftp), which contains the information about the FTP users for that account. A sample FTP user file for the cPanel ‘user1′ may look like this:

newuser:$1$K4v6EN_V$gmV/YZVYP1w/oJRy/72cg.:2110:2098:user1:/home/user1/public_html/newuser:/bin/ftpsh
user1:$1$21PI_llg$mkBe12xsL2K3YZPSkM.3..:2110:2098::/home/user1:/bin/ftpsh
user_logs:$1$21PI_llg$mkBe12xsL2K3YZPSkM.3..:2110:2098:user1:/usr/local/apache/domlogs/user1:/bin/ftpsh

If you want to change the FTP root for any of the users, simply make the change in this file and restart your FTP service.

Setting Up Wildcard DNS with cPanel

Posted by Vanessa | Posted in Misc | Posted on May 21, 2010

1

Wildcard DNS allows a server to display and combination of subdomains for a website. For example, wildcard DNS for thecpaneladmin.com will allow any subdomain to resolve to this website, even if they have not been specifically created.  Subdomains that have been created individually in cPanel will still route to their respective folders, but anything else will go to the document root of the domain the subdomains are based on. Wildcard DNS is most used for implementation of applications like WordPress MU. To set up wildcard DNS:

In the DNS zone for the parent domain, simply create an A  or CNAME record for *. For example, either of these will work:

*   IN   A   5.5.5.5

*   IN CNAME mywebsite.com.

Now on the server, edit /var/cpanel/userdata/$user/$parentdomain, and look for the serveralias line. This is where the parked domains/aliases for a domain are listed, so you just need to append *.parentdomain to the same line. A serveraliase line for thecpaneladmin.com may look like this:

serveralias: www.thecpaneladmin.com thecpaneladmin.net www.thecpaneladmin.net *.thecpaneladmin.com

Now run:

/scripts/rebuildhttpdconf

And restart Apache. You can test the Wildcard subdomains by going to any subdomain of the parent domain, and it should go to the parent domain’s site. This may not be what you wanted it to do though. With wildcard DNS and virtualhosts, you need an .htaccess rewrite to redirect the subdomains. For example:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC]
RewriteRule (.*) %2/$1 [L]
</IfModule>

In the above example, if your subdomain is test.domain.com, the rewrite will send you to http://domain.com/test/page.html. You can modify the rewrite accordingly to achieve the results you want.

Keep in mind that the Apache configuration has to be done by someone with access to the user’s Apache config files, as you can’t add *.domain.com to cPanel as a subdomain or parked domain at this time. cPanel may change this in the future, but for now it’s something that the end user cannot do without administrator access.

Installing A Wildcard SSL Certificate

Posted by Vanessa | Posted in Misc | Posted on May 18, 2010

2

A wildcard ssl basically allows you to use unlimited subdomains on a given domain name with one SSL certificate.  A user will need to purchase a wildcard SSL from a vendor that supplies them.

Similar to having multiple certificates installed on a server, each subdomain containing the certificate needs its own IP as well.  Wildcard SSL’s do not work like Wildcard DNS – you really do have to specifically install the certificate on each subdomain. Here are two methods to setting up Wildcard certificates for a domain.

Multiple Accounts

In this scenario, you’d have each subdomain hosted as a separate cPanel account, and each of those cPanel accounts will have its own IP address.

  1. Generate the Certificate Signing Request (CSR) in WHM, using *.domain.com
  2. Read this article to learn how to assign each account its own IP address
  3. When you’re obtained the certificate,go to WHM > Install a SSL Certificate and Setup the Domain and paste in the CRT and CA Bundle for *.domain.com
  4. The fields should auto-populate, in which case you need to make sure the IP is correct, then change the SSL hostname from *.domain.com to the target subdomain
  5. Click install to install the certificate

One Account

This method may be best for users that are not resellers or that are on shared hosting servers, where having multiple cpanel accounts may not be ideal. In this case, you’d have one cPanel account and assign multiple IPs to its subdomains.

  1. Generate the Certificate Signing Request (CSR) in WHM, using *.domain.co
  2. Read this article to learn how to assign dedicated IPs to multiple subdomains on the same account
  3. When you’re obtained the certificate,go to WHM > Install a SSL Certificate and Setup the Domain and paste in the CRT and CA Bundle for *.domain.com
  4. The fields should auto-populate, in which case you need to make sure the IP is correct, then change the SSL hostname from *.domain.com to the target subdomain
  5. Click install to install the certificate

Assign Multiple IP Addresses on One Account

Posted by Vanessa | Posted in Misc | Posted on May 14, 2010

7

By default, cPanel supports the usage of one dedicated IP per account. However, you can get around this by editing just a few files on the server. Here are the steps:

1. Edit /var/cpanel/userdata/$USER/$SUBDOMAIN.$DOMAIN for each subdomain (for addon/parked domains you’ll usually edit the file for the subdomain associated with the addon/parked domain) and change the ip value to a ‘dedicated’ ip.

2. Run /scripts/rebuildhttpdconf

3. Edit the dns zone for the subdomain (which will likely be attached to the parent domain) and update the a-record to point to that IP as well. Then syncronize the zone out to the DNS cluster, if one exists:

/scripts/dnscluster synczone <parentdomain>

4. Edit /etc/domainips and add an entry for that sudomain to point to the IP and run /scripts/rebuildippool to make sure the IP is marked as taken.

Changing a Site’s IP Address

Posted by Vanessa | Posted in Misc | Posted on April 7, 2010

7

There are three ways to change a site’s IP address on a cPanel server:

Via WHM:

Go to WHM  > Change site’s IP Address , select the account, then select the IP

Via Command Line:

/usr/local/cpanel/bin/setsiteip -u $user $ip

Manually:

-Edit /var/named/domain.com.db and increment the serial number. For help in changing DNS, see this post

-Replace instances of the old IP with the new IP in /var/cpanel/userdata and /var/cpanel/users

replace 123.123.123.123 222.222.222.222 — /var/cpanel/userdata/user/*

replace 123.123.123.123 222.222.222.222 — /var/cpanel/users/user

-If the new IP is shared, remove the user’s main domain entry from /etc/domainips. If it’s a dedicated IP, add/change the IP in /etc/domainips and /etc/ssldomains (if the site has an SSL)

-Run /scripts/rebuildhttpconf and /scripts/rebuildippool

Re-Installing Auxiliary cPanel Software

Posted by Vanessa | Posted in Misc | Posted on April 1, 2010

0

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 of these, you can pass a –force as an argument to force a reinstall of the application.

cPanel
/scripts/upcp

MySQL
/scripts/mysqlup

PostgreSQL
/scripts/installpostgres

Roundcube
/usr/local/cpanel/bin/update-roundcube

Horde
/usr/local/cpanel/bin/update-horde

Squirrelmail
/usr/local/cpanel/bin/update-squirrelmail

phpMyAdmin
/usr/local/cpanel/bin/updatephpmyadmin

pureFTP
/scripts/ftpup –force (See: Installing and Configuring pure-FTP)

Exim
/scripts/eximup

Courier IMAP
/scripts/courierup –force (See: Installing/Configuring Courier IMAP)

Dovecot
/scripts/dovecotup –force (See: Installing and Configuring Dovecot)

cpAddons
/scripts/cpaddonsup

NSD/BIND
/scripts/setupnameserver (NSD:/scripts/nsdup)

Apache/PHP
/scripts/easyapache (See: EasyApache)

suPHP
/scripts/suphpup

cPanel Internal PHP
/scripts/makecpphp

FrontPage Extensions
/scripts/fpupgrade

Mailman
/scripts/reinstallmailman (will not remove list data)

cpHulkd
/usr/local/cpanel/bin/hulkdsetup

Ruby
/scripts/installruby

How to Assign an IP To Multiple cPanel Accounts

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

1

Cpanel 11.25 introduces a new feature to allow you to set a reseller’s shared IP to be different from that of the server’s shared IP. This feature can be activated in WHM > Reseller Center > Manage reseller’s shared/main IP.  While this will allow you to have multiple accounts on the same IP, those accounts have to be owned by the reseller and will all be using the same IP. What if you have a dedicated IP that you want a couple accounts to share?  There’s currently no built-in cPanel functionality to do this, but you can alter a couple files to make it happen.

This walkthrough is for changing the IP of a domain/account to one that is already taken by another account. If you’re simply changing the site’s IP to one that is free, use the WHM > Change Site’s IP Address function instead.

Opening an Additional Exim Port

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

1

When I was in technical support, I got at least a dozen or more calls a week about clients who couldn’t send email, but had no problem receiving. When incoming mail works fine but the client can’t connect to the SMTP server, 99.9999% of the time it’s being caused by the ISP blocking remote SMTP/port 25 connections.  You can tell your customers this, but by now you probably know that your customers only care about what you can do for them. You know the ISP isn’t going to budge, and you can’t really blame them – the influx of SPAM has forced a lot of ISPs, webhosts, and email providers to change their protocols. And you need to as well.

Luckily cPanel offers an easy solution for opening additional ports for Exim, so your clients that can’t use standard port 25 can still send email through your mail server.

Service Manager

To enable the second port, all you need to do is log into WHM > Service Manager and check both boxes next to “exim on another port” and enter the port (one that is not already used) in the box, then save the settings. If you have a firewall, you also need to make sure the port is open so your users can connect to it.

11 Ways to Free Up Disk Space on a cPanel Server

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

14

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.