Wednesday 28 August 2013

Install suPHP on debian

Before starting the installation install the prerequisites needed to build mod_suphp with the command below.

#apt-get install php5-cgi apache2-prefork-dev
Now move to the directory where you would like to download the installation file
#cd /usr/local/src
The download it with the command below.
#wget http://www.suphp.org/download/suphp-0.6.2.tar.gz
Now unpack the file
#tar xvfz suphp-0.6.2.tar.gz
and,
#cd suphp-0.6.2
Now you can install with the following commands.

#./configure
Now if you end up with following error while running ./configure
APXS was not found, so mod_suphp will not be built!
Run the command again with the following option. ( where path to apxs may differ )
#./configure --with-apxs=/usr/bin/apxs2
 Now you can proceed with the commands below.
#make
#make install
Now add the module to apache.
#vi /etc/apache2/httpd.conf
And add the following line.
LoadModule suphp_module /usr/lib/apache2/modules/mod_suphp.so
Then restart apache.
#/etc/init.d/apache2 restart

DONE!!


Enable Iptables Modules for a VPS

Before enabling the modules to the VPS , make sure that its enabled in the root node of the VPS. You can check it using the command below.
#lsmod | grep -i module_name
If its not enabled, then enable it by using the modprobe command 
#modprobe iptables_module
#modprobe ipt_helper
#modprobe ipt_REDIRECT
#modprobe ipt_TCPMSS
#modprobe ipt_LOG
#modprobe ipt_TOS
#modprobe iptable_nat
#modprobe ipt_length
#modprobe ipt_tcpmss
#modprobe iptable_mangle
#modprobe ipt_tos
#modprobe iptable_filter
#modprobe ipt_helper
#modprobe ipt_tos
#modprobe ipt_ttl
#modprobe ipt_SAME
#modprobe ipt_REJECT
#modprobe ipt_helper
#modprobe ipt_owner
#modprobe ip_tables
#modprobe ipt_MASQUERADE
#modprobe ipt_multiport/xt_multiport
#modprobe ipt_state/xt_state
#modprobe ipt_limit/xt_limit
#modprobe ipt_recent
#modprobe xt_connlimit
#modprobe ipt_owner/xt_owner
#modprobe iptable_nat/ipt_DNAT
#modprobe iptable_nat/ipt_REDIRECT

Now to enable the module to the container, first stop the container which one you want to enable the module . Assuming the vps id as 101 here.  

# vzctl stop 101
Now you can enable the module to the vps either by executing the following command

# vzctl set 101 --iptables ipt_REJECT --iptables ipt_tos --iptables ipt_TOS --iptables ipt_LOG --iptables ip_conntrack --iptables ipt_limit --iptables ipt_multiport --iptables iptable_filter --iptables iptable_mangle --iptables ipt_TCPMSS --iptables ipt_tcpmss --iptables ipt_ttl --iptables ipt_length --iptables ipt_state --iptables iptable_nat --iptables ip_nat_ftp --save
                                                 OR
By adding manually to the configuration file /etc/vz/conf/veid.conf 
#vi /etc/vz/conf/101.conf
and then paste following at the end of the file.
 
IPTABLES="iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc"

Now restart the container.
# vzctl restart 101

This will enable the modules to the vps.




Install Ioncube loader in Debian

For installing Ioncube loader in debian follow the steps below.

Get into the server and change the directory where you would like to download the package to. 

#cd /usr/local/src
Now download IonCube loader using the command below ( chose according to which architecture you have )

#wget http://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
                                                        OR
#wget http://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
Now extract the downloaded file
#tar zxvf ioncube_loaders_lin_*.tar.gz

 Now move the directory ioncube to a permanent location
#mv ioncube /usr/local/

Now edit the php.ini file and add the following ( You can choose the version of ioncube loader the one that suites your needs )

#vi /etc/php5/apache2/php.ini
zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.2.so

Now restart apache
#/etc/init.d/apache2 restart


Done !!

Saturday 24 August 2013

CSF Blocking EVERYTHING

If you have csf installed on a OpenVZ container, suddenly you may end up with  csf blocking all ips and even ssh, email and all services will not be accesible, even though server is working, but firewall puts a block on everyone, and appears offline to others.

I got this fixed by doing the following steps:

Login to the host node and edit /etc/vz/conf/vpsid.conf. For example I'm using 101 as vpsid.

[root@node ~]# vi /etc/vz/conf/101.conf
Then add the following line to the end of the file. 

IPTABLES="iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc"
Now restart the container.

[root@node ~]# vzctl restart  101

The problem should be resolved now!!


umount: /***: device is busy.

Sometimes when you try to umount a device you end up with error " umount: /***: device is busy ", 
e.g.
# umount /***
umount: /***: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
Fix 1: It means that some process has a working directory or an open file handle underneath the mount point. The best thing to do is to end the offending process, change its working directory or close the file handle before unmounting.

Fix 2: There is an alternative on Linux though. Using umount -l calls a "lazy" unmount. The filesystem will still be mounted but you won't be able to see or use it, except for processes that are already using it. When the offending program exits (through whatever means) the system will "finish" unmounting the filesystem.

# umount -l /***

 This wil FIX it........