Jun 30

Change Server Time Zone

To change the server time zone do the following steps

mv /etc/localtime /etc/localtime.bk
ln -s /usr/share/zoneinfo/Requiredtimezone /etc/localtime

After this you need to restart mysql to correct it mysql time.
Steps to check mysql and server time are correct

# date +%s
1332653030
# mysql
SELECT FROM_UNIXTIME(1329969413);

Check if both time matches.

In WHM, you can do it in Main >> Server Configuration >> Server Time.

Jun 30

Issue when try to add new IP address in VPS server

This is something generic to uncommon errors, this issue arises when we try to add new IP in vps server.

When we click on the option “Add a New IP Address” under IP Functions on WHM, we get the following error sometimes.

“To add, edit, or remove IPs, please contact your server administrator”

This can be solved by adding the new IP manually in two seperate files of VPS server.

1) One is, add the IP in the format like –> IP Address + Netmask to /etc/ips inside the correct VPS to which you wish to add the new IP

* Restart ipaliases (/etc/init.d/ipaliases restart)

2) Secondly, by standing in the main node, add the IP in vps configuration file.

For example, if virtual server ID is 123,

* vi /etc/vz/conf/123.conf

* search for line “IP_ADDRESS”

– Add your new IP in the line IP_ADDRESS=”x.x.x.x y.y.y.y z.z.z.z”

* Restart the VPS (vzctl restart 123)

* Done and your new IP is added, you can see the new IP in “Show IP Address Usage” of WHM.

 

Jun 30

Enable Wildcard E-mail

Just like wildcard domains, there is a technique exists for routing mails send to non-existing email accounts to a legitimate email account situated in a particular domain. This method can generally be called as Wildcard E-mail.

Suppose a client open up a ticket where he is requested to set a wilcard email to test@mydomain.com, where this email account is an existing one in his domain. And he wants all mails sending to wild.*@mydomain.com(a non existing account and the “*” could be anything) would be delivered to test@mydomain.com.

The above request can be fulfilled by setting the following Account Level Filtering rule.

————————-
Put a Filter name as ‘wildcard’ or something identifiable name

Then Rule as, “To <–> begins” with

keyword as ‘wild’ ( where ‘wild’ here means any non existing email accounts starting with that term, ie wild.*@mydomain.com, the client wanted here)

Actions, “Redirect to email” <—> “test@mydomain.com”
————————-

You are done!!!

From now onwards mails sending to wild.*@mydomain.com, ie wild1, wild123, wild*** etc would be delivered to test@mydomain.com.

Jun 28

Deny IP on .htaccess file

You can write rule to deny particular IP or range of IPs in .htaccess file.

===============

order allow,deny
deny from IP <– the IP you want to deny
allow from all

===============

Jun 28

cPanel/WHM Autofixer

 The autofixer can be envoked two ways:

 /scripts/autorepair <script name>

 or in WHM:

 https://example.com:2087/scripts2/doautofixer?autofix=test
 https://your.server.ip.here:2087/scripts2/autofixer (and enter the name of the script)
 http://httpupdate.cpanel.net/autofixer/

 So for instance, if you wanted to repair a broken SSH configuration and you can't access SSH on your server,
 there is a script called "safesshrestart" in the autofixer repository that you can run:

 https://example.com:2087/scripts2/doautofixer?autofix=safesshrestart

 Alternatively, you can pass the script through /scripts/autorepair.

                   Commonly used autofixers (taken from the cPanel Documentation)

                   * test : Test autofixer on your system, nothing gets changed.
                   * bsdbindfix : Resolve port issue with BIND 9.
                   * compresszlibfix : Fix for compress zlib error.
                   * dbdmysql : DBD::mysql fix for older version of Red Hat (i.e. 7.3).
                   * fpindexfile : Fix for FrontPage index.
                   * iptablesflush : Flush iptables rules from WHM if you are firewalled from SSH access.
                   * libxml64fix : Fix for libXML on 64-bit systems.
                   * resellerresourceacctounts : Fix for reseller resource accounts.
                   * safesshrestart : Restores SSH Config and restarts SSH, should you be locked out.
                   * vfilterfix : Restores /etc/vfilters files.
                   * yumduprpmfix : This script will attempt to locate and resolve any duplicate RPMs

Jun 28

Redirect Subdirectories to the Root Directory using .htaccess

Suppose “block” is a sub directory in the domain “domain.com”, so you can redirect the sub directory to the root directory as follows.

RedirectMatch 301 ^/block/$ http://domain.com/

Jun 27

Remove IP from BruteForce – cphulkd

Please follow up the steps to remove IP from brute force lock through command line:

#mysql

#mysql> use cphulkd;

#mysql>BACKUP TABLE `brutes` TO ‘/path/to/backup/directory’;

#mysql> SELECT * FROM `brutes` WHERE `IP`=’xxx.xxx.xxx.xxx’;

#mysql> DELETE FROM `brutes` WHERE `IP`=’xxx.xxx.xxx.xxx’;

#mysql>quit

You can either do this through WHM interface >> in options “cPHulk Brute Force Protection” in “Security Center“.

 

Jun 26

APC Install Using Pecl

APC is a cache speeding up php execution and allows you to speed up applications by in-memory caching.

You can already install it though:

# pecl install apc

Or, for those with /tmp mounted as noexec:

{{{{install new package from pecl site}}}}}}

I downloaded here >> APC-3.1.6.tgz
# wget http://pecl.php.net/get/APC-3.1.6.tgz
# tar -xvzf APC-3.1.6.tgz
# cd APC-3.1.6
# phpize
# ./configure
# make
# make install

Now configure PHP to use the new extension, add the following in the php.ini file.
extension=apc.so

Jun 26

Setting Maximum Mails Per Hour For A Domain

Try the following steps to set maximum mails per hour count for a single domain other than the server wide default setting “maxemailsperhour” in /var/cpanel/cpanel.config

– Edit the file
vi /var/cpanel/user/user-name

– Add the entry MAX_EMAIL_PER_HOUR=number

– After saving the file , run the script

/scripts/update_email_limits user-name

This will create corresponding domain entry in /var/cpanel/maxemailsperdomain