Linux: Remove WHM Disk Warning

cpanel_logo

 

There are many times I am seeing the error below when accessing to the WHM.

Sorry for the inconvenience!
The filesystem mounted at / on this server is running out of disk space. cPanel operations have been temporarily suspended to prevent something bad from happening. Please ask your system admin to remove any files not in use on that partition.

And even after I have cleared the disk space from the server, WHM doesn’t allow me to access to WHM interface.

To get this issue fixed, you may remove the following files and retry again,

/root/.cpanel/datastore/_bin_df_-P_-k_-l

cPanel: How to block visitor by country through GeoIP

To block a certain country IP range, you do not need to know which IP range it is and what you need is to use the GeoIP feature.

To install GeoIP, refer to the following URL,
http://www.mickgenie.com/cpanel-how-to-install-mod_geoip

Next, you will need to insert the following command to the .htaccess file,

RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$
RewriteRule ^(.*)$ http://www.google.com [L]

The command use to redirect China IP to google.com***

***This is an example only and it is not to abuse any user/visitor reside in China.

cPanel: How to install mod_geoip

There are many ways to install mod_geoip in the web but the easiest way to compile it with cPanel server is to compile it through the easyapache.

To get it done, run the following command as root,

cd /var/cpanel/easy/apache/custom_opt_mods/
wget http://docs.cpanel.net/twiki/pub/EasyApache3/CustomMods/custom_opt_mod-mod_geoip.tar.gz
tar -zxf custom_opt_mod-mod_geoip.tar.gz

Next compile it with easyapache,

/scripts/easyapache

Then select the Mod_GeoIP in the Short Options List.

cPanel: Howto Resize tmp

This article will guide you how to resize the tmp drive from your cPanel server.

To get rid of /tmp drive keep on full, you may follow the following step,
1.  Stop the following services,

service httpd stop
service mysql stop

2. Un-mount the following drive

umount /var/tmp
umount /usr/tmp (if you are using VPS)
umount /tmp

3. Remove the temporary space

rm -f /usr/tmpDSK

4. Assign the tmp drive space (in bytes).

replace 512000 [value] -- /scripts/securetmp

Assign /tmp to 1GB
eg. replace 512000 1024000 -- /scripts/securetmp

5. Execute and apply it.

/scripts/securetmp

6. Start the services again,

service mysql start
service httpd start

 

cPanel: php_network_getaddresses: getaddrinfo failed: Name or service not known

I found out this problem just after the disk replace on backup drive but have no idea why it is occurred. However, the fixes is found.

With this issue, you may find the following error,

In SquirrelMail:

Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:143 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /usr/local/cpanel/base/3rdparty/squirrelmail/plugins/login_auth/functions.php on line 129

In HordeMail:

Login failed because your username or password was entered incorrectly.

In RoundCube:

Connection to IMAP server failed.

To resolve this problem, try to check the following issue,
1. If /etc/nsswitch.conf is exists.
2. If the permission of /etc/nsswitch.conf is 644, else do,

chmod 644 /etc/nsswitch.conf

3. check if /etc/nsswitch.conf come with any content. Update your system to get the fresh content.

cPanel: How to disable mod_security2 for account or path

To disable mod_security2 from cPanel server,

1. Create the following folder.

/usr/local/apache/conf/userdata/std/2/username/domain.com

2. Create a file name disabled_modsec2.conf in the above path.
3. Enter the following line if you want to disable mod_security2 for whole domain.

<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>

For specific path,

<LocationMatch your_path>
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
</LocationMatch>

4. Run the following script from root access.

/scripts/ensure_vhost_includes –user=username

 Alternatively,
Edit the following file,

/usr/local/apache/conf/modsec2.conf

Enter the information below,

SecRule SERVER_NAME "domain.com" phase:1,nolog,allow,ctl:ruleEngine=off

Replace the domain.com will do.

cPanel: Accessing cPanel through a firewall with cPanel Proxy

By default, cPanel, WHM and Webmail using custom port instead of port 80. Hence, you might not able to access to the cPanel, WHM and webmail through a firewall enabled network such as company, University or public network.

To get this issue fixed with cPanel 11.x and later, you may enable cPanel Proxy which is designed by cPanel to allow you access through normal web port 80.

To enable cPanel Proxy, make sure that you have the following setting enabled in WHM-> Tweak Settings.

– Proxy subdomains
– Proxy subdomain creation
– Proxy subdomain override

To enable proxy domain on account wide,

/scripts/proxydomains –user=<username> add

where username is the cPanel username.

To enable proxy domain on a single domain,

/scripts/proxydomains –domain=<domain.com> add

where domain.com is your domain name such as mickgenie.com

Lastly, to remove the proxy domain, change the “add” to “remove”.

cPanel: Prevent certain domain to be created

With cPanel 11.32 and above, you may prevent certain domain to be created from your server such as google.com, yahoo.com, microsoft.com, and etc.

To see which domain are blocked by default, view the file /usr/local/cpanel/etc/commondomains.

To block the domain to be created.
1. Create file /var/cpanel/commondomains.
2. Insert the domain list to the above file and each domain should be in new line.