Bash Script - Whitelist an account in Mod Security

The following script disable Mod Security for an account.


#!/bin/bash
mkdir -p /usr/local/apache/conf/userdata/std/2/$1/$2

echo -e " \nSecRuleEngine Off \n" > /usr/local/apache/conf/userdata/std/2/$1/$2/mod_security2.conf

/scripts/ensure_vhost_includes --user=$1

echo "Mod security disable for the account:$1 successfully"



Note:- Copy the above commands in a .sh file. Here let it be mod_sec.sh then,

# chmod 755 mod_sec.sh
    -To give execute permission to the script.
# ./mod_sec.sh <user_name>  <domain_name>
    -Execute the command as shown above.

How to change main domain name of KLOXO?



There is no direct option to change main domain in KLOXO.

But you can change main domain, if you can add more than one domain (not parked domain) in a user account. ie,the quota limit of domain in the user account must be more than one.

Let, you have to change your main domain from 'maindomain.com' to 'newmaindomain.com'

1.Login to the user account, then select
   >>Home>>Resources>>Add Domain 

2. Add the domain 'newmaindomain.com'
    You can't add a new domain if the domain quota of the user is 1.

3.Goto,
   >>Home>Resources>> Default Domain
    You can change your default domain from maindomain.com to newmaindomain.com

4.Now you have to login to backend of the server and copy all the contents of  maindomain.com directory to newmaindomain.com directory. Don't forget to check the domain's document root before copying files. If the document root is pointing to the same directory, no need to copy the files.

OpenVZ - Change Disk Quota

To check if your VE ran out of its disk quota, use the following commands (inside a VPS).

# df
   -To show disk space usage

# df -i
   -To show the inodes usage

If one of the commands give you usage of 100%, that means you hit one of the disk quota limit. You can increase the limit from the host system (Hardware Node) only.

To change the current Disk Quota,

1.Login to Hardware Node,

# vzquota stat <VPSID>
   -To  get the current values for disk quota. The result will be as shown in the figure.


2. To increase the disk space quota, use vzctl set --diskspace

# vzctl set <VPSID> --diskspace  $(( 1048576*3 )):$(( 1153434*3 )) --save
   -To increase quota by a factor 3

3. To increase the disk inodes quota, use vzctl set --diskinodes.


# vzctl set <VPSID> --diskinodes $(( 200000*4 )):$(( 220000*4 )) --save 
   -To increase quota by a factor 4

# vzctl exec <VPSID> df -i
   -To check whether the changes affected or not.

OpenVZ- UBC Parameters

UBC Parameters:

                     UBC, or User BeanCounters is a set of limits and guarantees controlled per Virtual Environment. UBC is the major component of OpenVZ resource management.


 The figure shows the UBC parameters of a VPS.
Enter in to VPS and run the following command.

# cat /proc/user_beancounters
   -To show the UBC parameters of a VPS.

                   You can see if you hit the limits for some UBC parameters by analyzing the last column (named failcnt). It shows a number of fails for this counter, i.e. a number of times a parameter hit the limit. Usually what you need to do is to increase the parameter. But you need to do it carefully.


If you want to increase kmemsize,

1. Get the current values for the parameter's barrier and limit
    Let, kmemsize barrier is 'x', and its limit is 'y'.

2. Increase the values. Say, we want to increase kmemsize by 2 times.

   # vzctl set <VPSID> --kmemsize $((x*2)):$((y*2)) --save 
    The above command doubled the parameter using bash arithmetic.

By using --save flag, we denote we want to both apply the new settings to the running VE, and save them in the configuration file (from which they will be taken during next VE start).

3. Check the new configuration.

# vzcfgvalidate /etc/vz/conf/<VPSID>.conf 


Note:-You can change the other parameters as like 'kmemsize'.
 

How to remove IP block?

IP Block can be of 2 kinds..,temporary block and permanent block.

# cat /etc/csf/csf.deny | grep <IP>

# iptables -nL | grep <IP>

If the IP is blocked in server, the above commands will list the IP block rules of that particular IP.


**If the block is temporary, do the following to remove block.

# csf -tr <IP>

**If the block is permanent, do the following to remove block.

 # csf -dr <IP>


Note1:- If the command csf is not working, you have to search for the command using whereis command.
# whereis csf
The above command will list the csf executable file.
eg:-
# /usr/sbin/csf -dr <IP>

Note2:- You can check the reason of IP block in /var/log/lfd.log. Use the following command
# cat /var/log/lfd.log | grep <IP>



cPanel - install Softaculous


1. Login to the server WHM as root user.

2. First check if ioncube loader is installed, if not, install it.

Sometime it is not enabled, so enable the ioncube loader from WHM.
 Main >> Server Configuration >> Tweak setting  >> php --> mark the ioncube.

3. Login to server via SSH.



cd /usr/local/src
wget -N http://files.softaculous.com/install.sh
chmod 755 install.sh
./install.sh

4. Restart cpanel (/etc/init.d/cpanel restart).

5. Now go to : WHM >> Plugins >> Softaculous - Instant Installs
Reference:-
http://www.softaculous.com/docs/Installing_Softaculous_in_cPanel

OpenVZ - Frequently used Commands

# vzctl start <VPSID>

   -To start a vps

# vzctl stop <VPSID>

   -To stop a vps

# vzctl restart <VPSID>

   -To restart a vps

# vzctl status <VPSID>

  -To check the status of vps

vzctl destroy <VPSID>

   -To To Delete a VPS. All the data will be deleted, no confirmation, so be careful when using this command.

# vzlist -a

   -To list all vps in the Hardware Node

# vzlist

  -To list running vps in the Hardware Node

vzcalc -v <VPSID>

    -To calculate the vps resources usage.

vzctl exec <VPSID> <Command>

    -To execute a command inside the container. Command can be df, ls etc.

# vzctl enter <VPSID>

    -To enter into vps

vzyum <VPSID> install package_name

    -To install any package/Software on a VPS from Node

vzctl set <VPSID>  --hostname  vps.domain.com  --save

    -To set the Hostname of a VPS

vzctl set  <VPSID>  --ipadd 1.2.3.4 --save

    -To add a new IP to the VPS

vzctl set  <VPSID> --ipdel  1.2.3.4  --save

    -To delete the IP from VPS

vzctl set  <VPSID>  --userpasswd  root:new_password  --save

    -To reset root password of a VPS

vzctl set  <VPSID>  --nameserver 1.2.3.4  --save

    -To add the nameserver IP's to the VPS

vzcpucheck -v

    -To check current CPU usage/vps. It'll list all vps.