Powered By Blogger

Thursday 27 December 2012

How to change Date, Time , Zone on linux server

How to change Date, Time , Zone on linux server

    You have to use date command to display the current date and time or set the system date / time over ssh session.

    # date
    Tue May 11 22:27:44 CET 2010


    Set Date:

    Use the following syntax to set new data and time:

    [HTML]date set="STRING"[/HTML]


    example

    #date -s "2 June 2010 18:00:00"


    Set Time:


    To set time use the following syntax:


    # date +%T -s "05:10:15"

    Where,

    * 05: Hour (hh)
    * 10: Minute (mm)
    * 15: Second (ss)


    To change timezone

    The file /etc /localtime, is a link to or copy of a file containing information about your time zone. The Zone information files located in /usr/share/zoneinfo this depends on your distribution.

    [HTML]
    cd /etc/

    ln -sf /usr/share/zoneinfo/EST localtime
    [/HTML]

    If youwish to set up it to IST (Asia/Calcutta):

    ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime

Wednesday 26 December 2012

Install ImageMagick

First of all check whether there is a cPanel script for installing ImageMagick available in the server or not. If yes,
# /scripts/installimagemagick
   -This will install ImageMagick automatically.
If not, follow the steps given below to install ImageMagick.

Install ImageMagick

1. # cd /usr/local/src/
2. # wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
3. # tar -xvfz ImageMagick.tar.gz
         -To download the ImageMagick setup compressed file and extract it.
4. # cd ImageMagick-6.6.9-6
    # ./configure
    # make
        -To configure and make ImageMagick from the source.
5. # make install
        -To install ImageMagick if the make process is successfully completed.
6. # make check
         -It will check the installation of ImageMagick. If  the installation completed successfully check will give a positive result.

7. # php -m | grep imagick
        -To check whether the  imagick module is loaded or not.

Bind ImageMagick Into PHP

For your new ImageMagick installation to work with your web php scripts, you now need to bind it into PHP. To do this, just follow the steps below.

1. Login to WHM and navigate to the “Module Installers” option under “Software” in the left hand menu

2. On the following page, select the “Manage” link beside the PHP Pecl language option

3. Enter imagick into the “Install a PHP Pecl” field and then click the install button.

DNS Server setup.

A DNS server, or name server, is used to resolve an IP address to a hostname or vice versa.
You can set up four different types of DNS servers:
  • A master DNS server for your domain(s), which stores authoritative records for your domain.
  • A slave DNS server, which relies on a master DNS server for data.
  • A caching-only DNS server, which stores recent requests like a proxy server. It otherwise refers to other DNS servers.
  • A forwarding-only DNS server, which refers all requests to other DNS servers.
Before configuring BIND to create a DNS server, you must understand some basic DNS concepts.
The entire hostname with its domain such as server.example.com is called a fully qualified domain name (FQDN). The right-most part of the FQDN such as .com or .net is called the top level domain, with the remaining parts of the FQDN, which are separated by periods, being sub-domains.
These sub-domains are used to divide FQDNs into zones, with the DNS information for each zone being maintained by at least one authoritative name server.
The authoritative server that contains the master zone file, which can be modified to update DNS information about the zone, is called the primary master server, or just master server.
The additional name servers for the zone are called secondary servers or slave servers. Secondary servers retrieve information about the zone through a zone transfer from the master server or from another secondary server. DNS information about a zone is never modified directly on the secondary server

chroot features

chroot feature is run named as user named, and it also limit the files named can see. When installed, named is fooled into thinking that the directory /var/named/chroot is actually the root or / directory. Therefore, named files normally found in the /etc directory are found in /var/named/chroot/etc directory instead, and those you would expect to find in /var/named are actually located in /var/named/chroot/var/named.
The advantage of the chroot feature is that if a hacker enters your system via a BIND exploit, the hacker's access to the rest of your system is isolated to the files under the chroot directory and nothing else. This type of security is also known as a chroot jail.

Configure dns server

In this example we will configure a dns server and will test from client side.
For this example we are using three systems one linux server one linux clients and one window clients.
bind and caching-nameserver rpm is required to configure dns. check them for install if not found install them.
rpm
set hostname to server.example.com and ip address to 192.168.0.254
set hostname and ipaddress
main configuration file for dns server is named.conf. By default this file is not created in /var/named/chroot/etc/ directory. Instead of named.conf a sample file /var/named/chroot/etc/named.caching-nameserver.conf is created. This file is use to make a caching only name server. You can also do editing in this file after changing its name to named.conf to configure master dns server or you can manually create a new named.conf file.
In our example we are creating a new named.conf file
vi named
We are using bind's chroot features so all our necessary files will be located in chroot directory. Set directory location to /var/named. Further we will set the location of forward zone and reverse lookup zone files. If you cannot create this file manually then download this file and copy to /var/named/chroot/etc/
To download do right click here and choose save link As..
named.conf

Or do editing exactly as shown here in image
named.conf
save this file with :wq and exit


Configure zone file

We have defined two zone files example.com.zone for forward zone and 0.168.192.in-addr.arpa for reverse zone. These files will be store in /var/named/chroot/var/named/ location. We will use two sample files for creating these files.
Change directory to /var/named/chroot/var/named and copy the sample files to name which we have set in named.conf
copy sample files
Now open forward zone file example.com.zone
example.com.zone
By default this file will look like this
forward look up zone file
Change this file exactly as shown in image below
forward lookup zone
If you feel difficulty to modify this file then download this configured file and copy to /var/named/chroot/var/named
To download do right click here and choose save link As..
example.com.zone

Now open reverse lookup zone file 0.168.192.in-addr.arpa
reverse lookup zone
By default this file will look like this
reverse lookup zone
Change this file exactly as shown in image below
reverse lookup zone file configured
If you feel difficulty to modify this file then download this configured file and copy to /var/named/chroot/var/named
To download do right click here and choose save link As..
0.168.192.in-addr.arpa

Now changed the ownership of these zone files to named group
chgrp
Now start the named service
service named restart
If service restart without any error means you have successfully configured master name server in our next article we will learn how to configure salve dns server and test it.

Anzil Ali Liyakkath
anzil.ali@webhostrepo.com

 

 

Share this post


Tuesday 25 December 2012

Quota enabling in cpanel


Quota Unlimited issue in CPanel Openvz

Hello,

You can fix this issue by following the steps shown below.

1. Login to HN as root user.

2. [root@HN ~] # vzlist -a | grep <IP of VPS>
                  <VPSID>         59 running   <IP>  server.example.com

3. [root@HN ~] # vzctl stop <VPSID>

4. [root@HN ~] # vzctl set <VPSID> --quotaugidlimit 1000 --save
                  CT configuration saved to /etc/vz/conf/<VPSID>.conf

5. [root@HN ~] # vzctl start <VPSID>

If you are facing Case1 issue only, try creating new accounts.

If you are facing Case2 issue you have to do the following steps too.

6. [root@HN ~] # vzctl enter <VPSID>

7. [root@vps ~] # /scripts/fixquotas

Reference-http://linuxadmintips4u.blogspot.in/2012/10/cpanel-unlimited-quota-issue-in-openvz.html

NAGIOS setup .

I. Overview
II. 6 steps to install Nagios plugin and NRPE on remote host.
  1. Download Nagios Plugins and NRPE Add-on
  2. Create nagios account
  3. Install Nagios Plugins
  4. Install NRPE
  5. Setup NRPE to run as daemon
  6. Modify the /usr/local/nagios/etc/nrpe.cfg
III. 4 Configuration steps on the Nagios monitoring server to monitor remote host:
  1. Download NRPE Add-on
  2. Install check_nrpe
  3. Create host and service definition for remote host
  4. Restart the nagios service

I. Overview:

.
Following three steps will happen on a very high level when Nagios (installed on the nagios-servers) monitors a service (for e.g. disk space usage) on the remote Linux host.

  1. Nagios will execute check_nrpe command on nagios-server and request it to monitor disk usage on remote host using check_disk command.
  2. The check_nrpe on the nagios-server will contact the NRPE daemon on remote host and request it to execute the check_disk on remote host.
  3. The results of the check_disk command will be returned back by NRPE daemon to the check_nrpe on nagios-server.

Following flow summarizes the above explanation:

Nagios Server (check_nrpe) —–> Remote host (NRPE deamon) —–> check_disk
Nagios Server (check_nrpe) <—– Remote host (NRPE deamon) <—– check_disk (returns disk space usage)

II. 7 steps to install Nagios Plugins and NRPE on the remote host

.

1. Download Nagios Plugins and NRPE Add-on

Download following files from Nagios.org and move to /home/downloads:
  • nagios-plugins-1.4.11.tar.gz
  • nrpe-2.12.tar.gz

2. Create nagios account

[remotehost]# useradd nagios
[remotehost]# passwd nagios

3. Install nagios-plugin

[remotehost]# cd /home/downloads
[remotehost]# tar xvfz nagios-plugins-1.4.11.tar.gz
[remotehost]# cd nagios-plugins-1.4.11
[remotehost]# export LDFLAGS=-ldl

[remotehost]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
[remotehost]# make
[remotehost]# make install

[remotehost]# chown nagios.nagios /usr/local/nagios
[remotehost]# chown -R nagios.nagios /usr/local/nagios/libexec/

Note: On Red Hat, For me the ./configure command was hanging with the the message: “checking for redhat spopen problem…”. Add --enable-redhat-pthread-workaround to the ./configure command as a work-around for the above problem.

4. Install NRPE

[remotehost]# cd /home/downloads
[remotehost]# tar xvfz nrpe-2.12.tar.gz
[remotehost]# cd nrpe-2.12

[remotehost]# ./configure
[remotehost]# make all
[remotehost]# make install-plugin
[remotehost]# make install-daemon
[remotehost]# make install-daemon-config
[remotehost]# make install-xinetd

5. Setup NRPE to run as daemon (i.e as part of xinetd):

  • Modify the /etc/xinetd.d/nrpe to add the ip-address of the Nagios monitoring server to the only_from directive. Note that there is a space after the 127.0.0.1 and the nagios monitoring server ip-address (in this example, nagios monitoring server ip-address is: 192.168.1.2)
       only_from       = 127.0.0.1 192.168.1.2
  • Modify the /etc/services and add the following at the end of the file.
       nrpe 5666/tcp # NRPE
  • Start the service
       [remotehost]#service xinetd restart
  • Verify whether NRPE is listening
       [remotehost]# netstat -at | grep nrpe
       tcp 0      0 *:nrpe *:*                         LISTEN
  • Verify to make sure the NRPE is functioning properly
[remotehost]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12

6. Modify the /usr/local/nagios/etc/nrpe.cfg

The nrpe.cfg file located on the remote host contains the commands that are needed to check the services on the remote host. By default the nrpe.cfg comes with few standard check commands as samples. check_users and check_load are shown below as an example.

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

In all the check commands, the “-w” stands for “Warning” and “-c” stands for “Critical”. for e.g. in the check_disk command below, if the available disk space gets to 20% of less, nagios will send warning message. If it gets to 10% or less, nagios will send critical message. Change the value of “-c” and “-w” parameter below depending on your environment.
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1

Note: You can execute any of the commands shown in the nrpe.cfg on the command line on remote host and see the results for yourself. For e.g. When I executed the check_disk command on the command line, it displayed the following:

[remotehost]#/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
DISK CRITICAL - free space: / 6420 MB (10% inode=98%);| /=55032MB;51792;58266;0;64741

In the above example, since the free disk space on /dev/hda1 is only 10% , it is displaying the CRITICAL message, which will be returned to nagios server.

III. 4 Configuration steps on the Nagios monitoring server to monitor remote host:

.

1. Download NRPE Add-on

Download nrpe-2.12.tar.gz from Nagios.org and move to /home/downloads:

2. Install check_nrpe on the nagios monitoring server

[nagios-server]# tar xvfz nrpe-2.12.tar.gz
[nagios-server]# cd nrpe-2.1.2
[nagios-server]# ./configure
[nagios-server]# make all
[nagios-server]# make install-plugin

./configure will give a configuration summary as shown below:

*** Configuration summary for nrpe 2.12 05-31-2008 ***:

General Options:
————————-
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios

Note: I got the “checking for SSL headers… configure: error: Cannot find ssl headers” error message while performing ./configure. Install openssl-devel as shown below and run the ./configure again to fix the problem.
[nagios-server]# rpm -ivh openssl-devel-0.9.7a-43.16.i386.rpm krb5-devel-1.3.4-47.i386.rpm zlib-devel-1.2.1.2-1.2.i386.rpm e2fsprogs-devel-1.35-12.5.
el4.i386.rpm
warning: openssl-devel-0.9.7a-43.16.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing… ########################################### [100%]
1:e2fsprogs-devel ########################################### [ 25%]
2:krb5-devel ########################################### [ 50%]
3:zlib-devel ########################################### [ 75%]
4:openssl-devel ########################################### [100%]
Verify whether nagios monitoring server can talk to the remotehost.
[nagios-server]#/usr/local/nagios/libexec/check_nrpe -H 192.168.1.3
NRPE v2.12

Note: 192.168.1.3 in the ip-address of the remotehost where the NRPE and nagios plugin was installed as explained in Section II above.

3. Create host and service definition for remotehost

Create a new configuration file /usr/local/nagios/etc/objects/remotehost.cfg to define the host and service definition for this particular remotehost. It is good to take the localhost.cfg and copy it as remotehost.cfg and start modifying it according to your needs.
 
host definition sample:
define host{
use linux-server
host_name remotehost
alias Remote Host
address 192.168.1.3
contact_groups admins
}

Service definition sample:
define service{
use generic-service
service_description Root Partition
contact_groups admins
check_command check_nrpe!check_disk
}
Note: In all the above examples, replace remotehost with the corresponding hostname of your remotehost.

4. Restart the nagios service

Restart the nagios as shown below and login to the nagios web (http://nagios-server/nagios/) to verify the status of the remotehost linux sever that was added to nagios for monitoring.
[nagios-server]# service nagios reload

Linux: 10 Netstat Command Examples

1. List All Ports (both listening and non listening ports)

List all ports using netstat -a

# netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:30037         *:*                     LISTEN
udp        0      0 *:bootpc                *:*                                

Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     6135     /tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     5140     /var/run/acpid.socket

List all tcp ports using netstat -at

# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:30037         *:*                     LISTEN
tcp        0      0 localhost:ipp           *:*                     LISTEN
tcp        0      0 *:smtp                  *:*                     LISTEN
tcp6       0      0 localhost:ipp           [::]:*                  LISTEN

List all udp ports using netstat -au

# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 *:bootpc                *:*
udp        0      0 *:49119                 *:*
udp        0      0 *:mdns                  *:*

2. List Sockets which are in Listening State

List only listening ports using netstat -l

# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:ipp           *:*                     LISTEN
tcp6       0      0 localhost:ipp           [::]:*                  LISTEN
udp        0      0 *:49119                 *:*

List only listening TCP Ports using netstat -lt

# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:30037         *:*                     LISTEN
tcp        0      0 *:smtp                  *:*                     LISTEN
tcp6       0      0 localhost:ipp           [::]:*                  LISTEN

List only listening UDP Ports using netstat -lu

# netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 *:49119                 *:*
udp        0      0 *:mdns                  *:*

List only the listening UNIX Ports using netstat -lx

# netstat -lx
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     6294     private/maildrop
unix  2      [ ACC ]     STREAM     LISTENING     6203     public/cleanup
unix  2      [ ACC ]     STREAM     LISTENING     6302     private/ifmail
unix  2      [ ACC ]     STREAM     LISTENING     6306     private/bsmtp

3. Show the statistics for each protocol

Show statistics for all ports using netstat -s

# netstat -s
Ip:
    11150 total packets received
    1 with invalid addresses
    0 forwarded
    0 incoming packets discarded
    11149 incoming packets delivered
    11635 requests sent out
Icmp:
    0 ICMP messages received
    0 input ICMP message failed.
Tcp:
    582 active connections openings
    2 failed connection attempts
    25 connection resets received
Udp:
    1183 packets received
    4 packets to unknown port received.
.....

Show statistics for TCP (or) UDP ports using netstat -st (or) -su

# netstat -st

# netstat -su

4. Display PID and program names in netstat output using netstat -p

netstat -p option can be combined with any other netstat option. This will add the “PID/Program Name” to the netstat output. This is very useful while debugging to identify which program is running on a particular port.
# netstat -pt
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        1      0 ramesh-laptop.loc:47212 192.168.185.75:www        CLOSE_WAIT  2109/firefox
tcp        0      0 ramesh-laptop.loc:52750 lax:www ESTABLISHED 2109/firefox

5. Don’t resolve host, port and user name in netstat output

When you don’t want the name of the host, port or user to be displayed, use netstat -n option. This will display in numbers, instead of resolving the host name, port name, user name.
This also speeds up the output, as netstat is not performing any look-up.
# netstat -an
If you don’t want only any one of those three items ( ports, or hosts, or users ) to be resolved, use following commands.
# netsat -a --numeric-ports

# netsat -a --numeric-hosts

# netsat -a --numeric-users

6. Print netstat information continuously

netstat will print information continuously every few seconds.

# netstat -c
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 ramesh-laptop.loc:36130 101-101-181-225.ama:www ESTABLISHED
tcp        1      1 ramesh-laptop.loc:52564 101.11.169.230:www      CLOSING
tcp        0      0 ramesh-laptop.loc:43758 server-101-101-43-2:www ESTABLISHED
tcp        1      1 ramesh-laptop.loc:42367 101.101.34.101:www      CLOSING
^C

7. Find the non supportive Address families in your system

netstat --verbose
At the end, you will have something like this.
	netstat: no support for `AF IPX' on this system.
	netstat: no support for `AF AX25' on this system.
	netstat: no support for `AF X25' on this system.
	netstat: no support for `AF NETROM' on this system.

8. Display the kernel routing information using netstat -r

# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     *               255.255.255.0   U         0 0          0 eth2
link-local      *               255.255.0.0     U         0 0          0 eth2
default         192.168.1.1     0.0.0.0         UG        0 0          0 eth2
Note: Use netstat -rn to display routes in numeric format without resolving for host-names.

9. Find out on which port a program is running

# netstat -ap | grep ssh
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        1      0 dev-db:ssh           101.174.100.22:39213        CLOSE_WAIT  -
tcp        1      0 dev-db:ssh           101.174.100.22:57643        CLOSE_WAIT  -
Find out which process is using a particular port:
# netstat -an | grep ':80'

10. Show the list of network interfaces

# netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0         0      0      0 0             0      0      0      0 BMU
eth2       1500 0     26196      0      0 0         26883      6      0      0 BMRU
lo        16436 0         4      0      0 0             4      0      0      0 LRU
Display extended information on the interfaces (similar to ifconfig) using netstat -ie:
# netstat -ie
Kernel Interface table
eth0      Link encap:Ethernet  HWaddr 00:10:40:11:11:11
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Memory:f6ae0000-f6b00000
 
 
 
 
============================================================================
Anzil Ali Liyakkath 
anzil.ali@webhostrepo.com 

Install Ubuntu With Software RAID 10

1 Before you start

I'll asume you have already known about RAID 10, but I'll cover a some important information before you begin.
  • You will need 4 partitions dedicated for the RAID array, each will need to be on their own physical drive.
  • Only half of the disk space used for the RAID 10 volume will be useable.
  • All partitions used for RAID should be the same or close to the same size.

  • 2 Prepare your disks

    Use a partition program that can create RAID partitions, I use cfdisk which is text based but easier to use than fdisk. Partition your disks, make a 50 MB partition on the first drive, this is for /boot since grub doesn't support RAID well. Set up a partition on four drives to be RAID type, in cfdisk choose FD as the type. In my setup all of the system besides /boot will reside in one RAID 10 volume.
    For best swap performance put a swap partition on each drive. I put a one GB swap on each drive.

    Boot the Ubuntu Live CD.
    Run the Terminal.
    #sudo su
    #cfdisk /dev/sda


    cfdisk /dev/sdb


    The next two drives are partitioned the same as /dev/sdb:

    #cfdisk /dev/sdc
    #cfdisk /dev/sdd

    3 Install RAID utility, mdadm, and set up the RAID array

    apt-get install mdadm
    mdadm -v --create /dev/md0 --level=raid10 --raid-devices=4 /dev/sda2 /dev/sdb1 /dev/sdc1 /dev/sdd1
    Then create the file system on the RAID array. Format it now because the partitioner in the installer doesn't know how to modify or format RAID arrays. I used XFS file system, because XFS has great large file performance. Then you will create an alias for the RAID array with the link command because the Ubuntu installer won't find devices starting with "md".

    #mkfs.xfs /dev/md0
    #ln /dev/md0 /dev/sde

    4 Ubuntu Install

    Run the installer, when you are in the partitioner choose manual and be careful not to modify the partition layout. For the /dev/sda1 partition choose ext3 as the file system and set /boot on.

    Set your swap partitions to be used as swap.
    You select the type of file system you already formatted the RAID device and set the mount point. Do not choose to reformat or make partition table changes to the RAID array, because the partitioner will misconfigure it.
    Click continue on the warning about the RAID not being marked for formatting.

    When the installer finishes tell it to continue to use the Live CD.

    5 Install RAID support inside the new install

    A default Ubuntu setup won't automatically boot into a software RAID setup, you will need to chroot into the new install and have the chroot configured to see all the device information available in the LiveCD environment so that the mdadm install scripts can properly set up config and boot files for RAID support.
    mkdir /myraid
    mount /dev/md0 /myraid
    mount /dev/sda1 /myraid/boot
    mount --bind /dev /myraid/dev
    mount -t devpts devpts /myraid/dev/pts
    mount -t proc proc /myraid/proc
    mount -t sysfs sysfs /myraid/sys
    chroot /myraid
    apt-get install mdadm
    exit
    You can now reboot into your new system.

    Extra commands you may need

    A helpful command that will tell you the status of the RAID and which partitions belong to a volume:
    cat /proc/mdstat
    If you reboot into the Live CD and want to mount your RAID array you will need to install mdadm in the Live CD environment and activate the RAID:
    sudo su
    apt-get install mdadm
    mdadm --assemble /dev/md0

    If you need to start over or remove the RAID array

    Software RAID information is embedded in a place on each RAID partition called the superblock. If you decide to change your RAID setup and start over, you can't just repartition and try to recreate the RAID array. You will need to erase the superblock first on each partition belonging to the RAID array you want to remove.
    Make sure your important data has been backed up before doing these steps.
    First we will make sure RAID is unmounted and stopped.
    sudo su
    umount /dev/md0
    mdadm --stop /dev/md0
    mdadm --zero-superblock /dev/sda2
    mdadm --zero-superblock /dev/sdb1
    mdadm --zero-superblock /dev/sdc1
    mdadm --zero-superblock /dev/sdd1


    Anzil Ali Liyakkath
    anzil.ali@webhostrepo.com 

    Installin OPenVZ

    1 Installing OpenVZ

    In order to install OpenVZ, we need to add the OpenVZ repository to yum:
    cd /etc/yum.repos.d
    wget http://download.openvz.org/openvz.repo
    rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
    The repository contains a few different OpenVZ kernels (you can find more details about them here: http://wiki.openvz.org/Kernel_flavors). The command
    yum search ovzkernel
    shows you the available kernels:
    [root@server1 yum.repos.d]# yum search ovzkernel
    Loading "fastestmirror" plugin
    Loading mirror speeds from cached hostfile
     * base: ftp.halifax.rwth-aachen.de
     * openvz-kernel-rhel5: openvz.proserve.nl
     * updates: ftp.halifax.rwth-aachen.de
     * addons: ftp.halifax.rwth-aachen.de
     * openvz-utils: openvz.proserve.nl
     * extras: ftp.halifax.rwth-aachen.de
    openvz-kernel-rhel5       100% |=========================|  951 B    00:00
    primary.xml.gz            100% |=========================|  22 kB    00:00
    openvz-ker: ################################################## 14/14
    openvz-utils              100% |=========================|  951 B    00:00
    primary.xml.gz            100% |=========================| 6.7 kB    00:00
    openvz-uti: ################################################## 26/26
    ovzkernel-ent.i686 : The Linux kernel compiled for huge mem capable machines.
    ovzkernel-PAE.i686 : The Linux kernel compiled for PAE capable machines.
    ovzkernel-ent-devel.i686 : Development package for building kernel modules to match the ent kernel.
    ovzkernel-PAE-devel.i686 : Development package for building kernel modules to match the PAE kernel.
    ovzkernel.i686 : Virtuozzo Linux kernel (the core of the Linux operating system)
    ovzkernel-xen.i686 : The Linux kernel compiled for Xen VM operations
    ovzkernel-xen-devel.i686 : Development package for building kernel modules to match the kernel.
    ovzkernel-devel.i686 : Development package for building kernel modules to match the kernel.
    [root@server1 yum.repos.d]#
    Pick one of them and install it as follows:
    yum install ovzkernel
    This should automatically update the GRUB bootloader as well. Anyway, we should open /boot/grub/menu.lst; the first kernel stanza should now contain the new OpenVZ kernel. The title of that kernel just reads "CentOS". I think it's a good idea to change that title and add something with "OpenVZ" to it so that you know that it's the OpenVZ kernel. Also make sure that the value of default is 0 so that the first kernel (the OpenVZ kernel) is booted automatically instead of the default CentOS kernel.
    vi /boot/grub/menu.lst
    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making changes to this file
    # NOTICE:  You have a /boot partition.  This means that
    #          all kernel and initrd paths are relative to /boot/, eg.
    #          root (hd0,0)
    #          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
    #          initrd /initrd-version.img
    #boot=/dev/sda
    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title CentOS OpenVZ (2.6.18-53.1.19.el5.028stab053.14)
            root (hd0,0)
            kernel /vmlinuz-2.6.18-53.1.19.el5.028stab053.14 ro root=/dev/VolGroup00/LogVol00
            initrd /initrd-2.6.18-53.1.19.el5.028stab053.14.img
    title CentOS (2.6.18-92.1.1.el5)
            root (hd0,0)
            kernel /vmlinuz-2.6.18-92.1.1.el5 ro root=/dev/VolGroup00/LogVol00
            initrd /initrd-2.6.18-92.1.1.el5.img
    title CentOS (2.6.18-92.el5)
            root (hd0,0)
            kernel /vmlinuz-2.6.18-92.el5 ro root=/dev/VolGroup00/LogVol00
            initrd /initrd-2.6.18-92.el5.img
    Now we install some OpenVZ user tools:
    yum install vzctl vzquota

    Open /etc/sysctl.conf and make sure that you have the following settings in it:
    vi /etc/sysctl.conf
    [...]
    net.ipv4.ip_forward = 1
    net.ipv4.conf.default.proxy_arp = 0
    net.ipv4.conf.all.rp_filter = 1
    kernel.sysrq = 1
    net.ipv4.conf.default.send_redirects = 1
    net.ipv4.conf.all.send_redirects = 0
    net.ipv4.icmp_echo_ignore_broadcasts=1
    net.ipv4.conf.default.forwarding=1
    [...]
    If you need to modify /etc/sysctl.conf, run
    sysctl -p
    afterwards.
    The following step is important if the IP addresses of your virtual machines are from a different subnet than the host system's IP address. If you don't do this, networking will not work in the virtual machines!
    Open /etc/vz/vz.conf and set NEIGHBOUR_DEVS to all:
    vi /etc/vz/vz.conf
    [...]
    NEIGHBOUR_DEVS=all
    [...]
    SELinux needs to be disabled if you want to use OpenVZ. Open /etc/sysconfig/selinux and set the value of SELINUX to disabled:
    vi /etc/sysconfig/selinux
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - SELinux is fully disabled.
    SELINUX=disabled
    # SELINUXTYPE= type of policy in use. Possible values are:
    #       targeted - Only targeted network daemons are protected.
    #       strict - Full SELinux protection.
    SELINUXTYPE=targeted
    Finally, reboot the system:
    reboot
    If your system reboots without problems, then everything is fine!
    Run
    uname -r
    and your new OpenVZ kernel should show up:
    [root@server1 ~]# uname -r
    2.6.18-53.1.19.el5.028stab053.14
    [root@server1 ~]#

    Basic operations in OpenVZ environment

    Basic operations in OpenVZ environment

    Jump to: navigation, search
    This article assumes you have already installed OpenVZ. If not, follow the link to perform the steps needed.

    Create and start a container

    To create and start a container, run the following commands:
    [host-node]# vzctl create CTID --ostemplate osname
    [host-node]# vzctl set CTID --ipadd a.b.c.d --save
    [host-node]# vzctl set CTID --nameserver a.b.c.d --save
    [host-node]# vzctl start CTID
    
    Here CTID is the numeric ID for the container; osname is the name of the OS template for the container, and a.b.c.d is the IP address to be assigned to the container.
    Example:
    [host-node]# vzctl create 101 --ostemplate fedora-core-5-minimal
    [host-node]# vzctl set 101 --ipadd 10.1.2.3 --save
    [host-node]# vzctl set 101 --nameserver 10.0.2.1 --save
    [host-node]# vzctl start 101
    
    Your freshly-created container should be up and running now; you can see its processes:
    [host-node]# vzctl exec CTID ps ax
    

    Enter to and exit from the container

    To enter container give the following command:
    [host-node]# vzctl enter CTID
    entered into container CTID
    [container]#
    
    To exit from container, just type exit and press Enter:
    [container]# exit
    exited from container VEID
    [host-node]#
    

    Stop and destroy the container

    To stop container:
    [host-node]# vzctl stop CTID
    Stopping container ...
    Container was stopped
    Container is unmounted
    
    And to destroy container:
    [host-node]# vzctl destroy CTID
    Destroying container private area: /vz/private/CTID
    Container private area was destroyed
    

    Tuesday 18 December 2012

    FFMPEG installation.


    Installation of FFMPEG is treated as the toughest installations as it has many dependencies. Check with the below steps for easy installation.

    1. Enable 9xhost and EPEL yum repositories

        The CentOS 6 RPM packages of ffmpeg, mplayer and MP4Box packages are available on 9xhost.net. These RPM packages are copied from ATrpms and RPM Fusion YUM repositories for a simplified installation.

        Some packages on 9xhost YUM repo depend on EPEL repo. To enable EPEL repo, install the epel-release RPM package

        rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm

    1.1 To enable 9xhost YUM repository, create the file /etc/yum.repos.d/9xhost.repo

        nano /etc/yum.repos.d/9xhost.repo

        and add following repository configuration:

        [9xhost]
        name=9xhost Packages CentOS 6 - $basearch
        baseurl=http://dl.9xhost.info/yumrepo/centos/6/$basearch/
        enabled=1
        gpgcheck=0

    2. Install ffmpeg mplayer and mencoder

        for x86 (32bit system)

        yum install ffmpeg mplayer

        for x86_64 (64bit system)

        yum install ffmpeg mplayer --exclude "*.i386"

        Note: there is no separate package for mencoder. It is also provided by mplayer package.

        This will also install various dependency packages like libtheora, libvorbis, libogg, lame, opencore-amr, x264, xvidcore etc.

    3. Install flvtool2

        cPanel has its own ruby installer script. So install ruby using following cPanel script:

        /scripts/installruby

        Flvtool2 is available as a Ruby Gems package. Use following gem command to install flvtool2:

        gem install flvtool2

    4. Install MP4Box2

        MP4Box is provided by gpac package. Install gpac and its library packages:

        for x86 (32bit system)

        yum install gpac gpac-libs

        for x86_64 (64bit system)

        yum install gpac gpac-libs --exclude "*.i386"

    5. Install ffmpeg-php

        Ffmpeg-php requires ffmpeg development package. Install it using yum:
        for x86 (32bit system)

        yum install ffmpeg-devel

        for x86_64 (64bit system)

        yum install ffmpeg-devel --exclude "*.i386"

        Now download the latest ffmpeg-php package:

        wget http://downloads.sourceforge.net/ffmpeg-php/ffmpeg-php-0.6.0.tbz2

        Untar this package, build and install it with following commands:

        tar xjf ffmpeg-php-0.6.0.tbz2
        cd ffmpeg-php-0.6.0
        sed -i ‘s/PIX_FMT_RGBA32/PIX_FMT_RGB32/g’ ffmpeg_frame.c
        phpize
        ./configure
        make
        make install

        The make install command will show PHP extensions path where ffmpeg PHP extension is installed:

        root@server [~/ffmpeg-php-0.6.0]# make install
        Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

        Now edit php.ini file

        nano /usr/local/lib/php.ini

        and make sure that value of extension_dir is set to PHP extension directory as given by above make install command:


        extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"

        Add following line just below extension_dir and this will enable ffmpeg PHP extension:

        extension="ffmpeg.so"

        Restart Apache to make this change effective:

        /scripts/restartsrv_httpd

        You can verify the status of ffmpeg extension on a PHP info web page or from command line as given below:


        root@server [~]# php -i | grep ffmpeg
        ffmpeg
        ffmpeg-php version => 0.6.0-svn
        ffmpeg-php built on => Jun 2 2012 20:48:04
        ffmpeg-php gd support => enabled
        ffmpeg libavcodec version => Lavc52.123.0
        ffmpeg libavformat version => Lavf52.111.0
        ffmpeg swscaler version => SwS0.14.1
        ffmpeg.allow_persistent => 0 => 0
        ffmpeg.show_warnings => 0 => 0
        OLDPWD => /root/ffmpeg-php-0.6.0
        _SERVER["OLDPWD"] => /root/ffmpeg-php-0.6.0
        _ENV["OLDPWD"] => /root/ffmpeg-php-0.6.0

    6. Installation paths

        Following are the file system paths of tools that we installed:

        ffmpeg: /usr/bin/ffmpeg
        mplayer: /usr/bin/mplayer
        mencoder: /usr/bin/mencoder
        flvtool2: /usr/bin/flvtool2
        MP4Box: /usr/bin/MP4Box

    Saturday 8 December 2012

    SPAM CHECK

    Check for bulk/spam emails.

    The 1st thing you should check for is the number of emails in the Exim queue using the below command:

    Code: [Select]
    exim -bpc

    Then check if the emails are from same source:

    Code: [Select]
    exim -bp

    Quote
    0m  1.6K 1Ryd9X-000aSt-8N <euser@host.hostname.com>
              user1@aol.com

     0m  1.6K 1Ryd9X-000aTK-NT <euser@host.hostname.com>
              user2@sbcglobal.net

     0m  1.6K 1Ryd9X-000aTT-Ui <euser@host.hostname.com>
              user3@aol.com

     0m  1.6K 1Ryd9Y-000aUC-Tp <euser@host.hostname.com>
              user4@aol.com

     0m  1.6K 1Ryd9Z-000aUN-59 <euser@host.hostname.com>
              user5@aol.com

     0m  1.6K 1Ryd9Z-000alM-P0 <euser@host.hostname.com>
              user6@aol.com

    As you can see all the emails were sent a few minutes before I checked (0m), so there is definitely a bulk emailer/spammer. See if there is a cPanel user in the name "euser".

    Code: [Select]
    grep euser /etc/userdomains

    If there is one, suspend/block him.

    If you don't get much details. Check the header of one of the emails, using the below command.

    Code: [Select]
    exim -Mvh message_id

    for eg:

    Code: [Select]
    exim -Mvh 1Ryd9Z-000alM-P0

    Analyze the subject, from and to email address to locate the spammer.

    Mailnull spammers, won't show up in the above headers most of the time. However an SSH connection is opened and we can identify them after seeing the netstat output.

    Quote
    tcp        0      0 127.0.0.1:32587             127.0.0.1:25                ESTABLISHED 547580/sshd: euser
    tcp        0      0 127.0.0.1:32568             127.0.0.1:25                ESTABLISHED 547580/sshd: euser
    tcp        0      0 127.0.0.1:32458             127.0.0.1:25                ESTABLISHED 547580/sshd: euser
    tcp        0      0 127.0.0.1:32541             127.0.0.1:25                ESTABLISHED 547580/sshd: euser

    Suspend the "euser" in that case and disable SSH access for him.

    If you still don't find any spammers, enable extended logging for Exim. Read http://www.webhostgear.com/118.html

    Also check the exim logs using the message_id to find more details.

    Quote
    exigrep message_id /var/log/exim_mainlog

    exigrep 1Ryd9Z-000alM-P0 /var/log/exim_mainlog

    Prevent Spamming

    To prevent spamming, you should enable SpamFilters, SpammAssassin and anti-virus in the server. Read

    http://www.sput.nl/software/exim.html
    http://wiki.exim.org/SpamFiltering and http://www.webhostgear.com/338.html

    Install Softaculous in cpanel from WHM

    You can install Softaculous in cpanel from WHM and also from command line without having to visit cPanel/WHM.
    Before starting the Softaculous installation please make sure that the ‘ionCube Loader’is enabled on the server.
    To install from WHM
    =================
    1. Log into server via ssh.
    2. cd /usr/local/cpanel/whostmgr/docroot/cgi
    3. wget -N http://www.softaculous.com/ins/addon_softaculous.php
    4. chmod 755 addon_softaculous.php
    5. Then go to WHM –> Plugins–>softaculous– Instant Installs


    Install from command line
    =======================
    1.Log into server via ssh.
    2.cd /usr/local/cpanel/whostmgr/docroot/cgi
    3. wget -N http://www.softaculous.com/ins/addon_softaculous.php
    4. chmod 755 addon_softaculous.php
    5. /usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/whostmgr/docroot/cgi/addon_softaculous.php

    Thursday 6 December 2012

    Enabling Quotas on a Virtuozzo® VPS

    For WHM version 11.32 If you are running cPanel and WHM on a Virtuozzo Virtual Private Server (VPS), you may need to take extra steps to enable quotas.
    PICK Important: cPanel and WHM quotas will not work unless both first- and second-level Virtuozzo quotas are enabled.

    About Virtuozzo and Quotas

    There are 2 types of disk quotas on a Virtuozzo server:
    1. Per-container, or first-level, quotas allow system administrators to control the sizes of VPS file systems by limiting the amount of disk space and the number of inodes a Virtual Server (also called a Container) can use.
    2. Per-user and per-group, or second-level, quotas enable the Virtual Server administrator to limit the amount of disk space and the number of inodes that users and groups within the VPS can use.

    First-level Quotas

    First-level quotas are enabled during the Container (or VPS) start-up process.
    To see whether first-level quotas have already been enabled, issue the following command:
    • vzquota show Container_ID

    Second-level Quotas

    Second-level disk quotas are controlled by the QUOTAUGIDLIMIT parameter in the Container configuration file.
    By default, the value of this parameter is zero, which disables per-user/group quotas. To view the parameter, issue the command:
    • grep -i QUOTAUGIDLIMIT /etc/sysconfig/vz-scripts/CT_ID.conf
    If you get an empty result, or a result of zero, second-level quotas are not supported by this environment.
    To turn on second-level quotas for the Container, see http://download.swsoft.com/virtuozzo/virtuozzo4.0/docs/en/lin/VzLinuxUG/293.htm.  or

    Turning On and Off Second-Level Quotas for Container

    The parameter that controls the second-level disk quotas is QUOTAUGIDLIMIT in the Container configuration file. By default, the value of this parameter is zero and this corresponds to disabled per-user and per-group quotas.
    If you assign a non-zero value to the QUOTAUGIDLIMIT parameter, this action brings about the two following results:
    1. Second-level (per-user and per-group) disk quotas are enabled for the given Container;
    2. The value that you assign to this parameter will be the limit for the number of file owners and groups of this Container, including Linux system users. Note that you will theoretically be able to create extra users of this Container, but if the number of file owners inside the Container has already reached the limit, these users will not be able to own files.
    Enabling per-user and per-group quotas for a Container requires restarting the Container. The value for it should be carefully chosen; the bigger value you set, the bigger kernel memory overhead this Container creates. This value must be greater than or equal to the number of entries in the Container /etc/passwd and /etc/group files. Taking into account that a newly created Red Hat Linux-based Container has about 80 entries in total, the typical value would be 100. However, for Containers with a large number of users this value may be increased.
    When managing the quotaugidlimit parameter, please keep in mind the following:
    • if you delete a registered user but some files with their ID continue residing inside your Container, the current number of ugids (user and group identities) inside the Container will not decrease.
    • if you copy an archive containing files with user and group IDs not registered inside your Container, the number of ugids inside the Container will increase by the number of these new IDs.
    The session below turns on second-level quotas for Container 101:
    # vzctl set 101 --quotaugidlimit 100 --save
    Unable to apply new quota values: ugid quota not initialized
    Saved parameters for Container 101
    # vzctl stop 101; vzctl start 101
    Stopping Container ...
    Container was stopped
    Container is unmounted
    Starting Container ...
    Container is mounted
    Adding IP address(es): 192.168.1.101
    Hostname for Container set: ct101
    Container start in progress...
    Setting the QUOTAUGIDLIMIT parameter to a non-zero value will:
    1. Enable second-level (per-user and per-group) disk quotas for the VPS (or Container).
    2. Limit the number of file owners and groups within this VPS, including Linux system users, to the value assigned to this parameter.
    • note Note: In theory, you can create extra VPS users, but once the number of file owners inside the VPS reaches the limit, these extra users will not be able to own files.

    Monday 3 December 2012

    VPS HARDENING

    VPS level.
    * Disable direct root login.
    * Change SSH port to a non-standard one (this port will be enabled in firewall).
    * Secure /tmp
    * Install root kit checkers like rkhunter and chkrootkit.
    * Disable telnet.
    * Install firewall CSF + LFD (for brute force protection).
    * Enable Shell Fork Bomb/Memory Protection via WHM

    Application level

    * Disable ServerTokens and ServerSignature in Apache.
    * Install and configure mod_security module for Apache.
    * Enable suPHP and suexec for PHP protection.
    * Disable harmful PHP functions like exec.

     : After installing CSF make sure testing mode is turned OFF


    Anzil Ali Liyakkath
    anzil.ali@webhostrepo.com


    RK HUNTER INSTALLATION

    This worked fine for me to install rkhunter in my server.

    Login and ssh to your server :
    change directory  to -
    # cd /usr/local/src

    Download the tar file 
    # wget http://downloads.sourceforge.net/project/rkhunter/rkhunter/1.4.0/rkhunter-1.4.0.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Frkhunter%2F&ts=1354538280&use_mirror=nchc

    Untar the downloaded file
    # tar -zxvf rkhunter-1.4.0.tar.gz

    Change directory to -
    # cd /rkhunter-1.4.0

    Run the installer file - 
    # ./installer.sh --install
     

    To check whether RK HUNTER is installed on the server try this command which shows all the available commands to use rkhuntr :-







    # rkhunter -help


    You are done !!

    Anzil Ali Liyakkath
    anzil.ali@webhostrepo.com







    ChkRootKit

    Install ChkRootKit


    Follow these steps to install ChkRootKit
    cd /usr/local/src/

    – Down load the chkrootkit.
     
    # wget http://www.spenneberg.org/chkrootkit-mirror/files/chkrootkit.tar.gz
    # wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz

    - Unpack the chkrootkit you just downloaded. 
    # tar -xvzf chkrootkit.tar.gz

    - Change to new directory  
    # cd chkrootkit-*
    (select the version )

    - Compile chkrootkit
    # make sense

    - Run chkrootkit
    # ./chkrootkit

    __________________________________________________

    How to setup a daily scan report?
    - Load crontab
    # crontab -e
    - Add this line to the top:
    ===============================================================>
    0 1 * * * (cd /usr/local/src/chkrootkit*; ./chkrootkit 2>&1 | mail -s “chkrootkit output” email@domain.com)
    ===============================================================>

    Sunday 2 December 2012

    Migrate from Plesk to cPanel via command line

    If you're anything like me, you prefer to do things via command line (CLI) rather than relying on a GUI to do most things in Linux. You also realize that while some of us don't like to use control panels (plesk, cpanel, webmin, etc..), they are necessary when providing a shared hosting environment for your clients.

    While cPanel has an excellent migration utility (and they'll even migrate it for you for free in most cases), it will sometimes fail for one reason or another. If you do it via command line, you'll be able to cut out some of those failures.

    Here are the steps to migrate a customer from a plesk 8.x (yeah, pretty dated) box to a cpanel 11.3x box.

    Info about our xfer:
    Source server: plesk.company.com
    Source account owner: siteuser
    Destination server: cpanel.company.com


    Source server (plesk)
    1. SSH into the source server and become root
    2. To find out the account owner, just see who owns the files in their /home/sites/domain.com directory.
    3. cd into the home directory and run the pkgacct command calling the username that owns the account you want to xfer.

    # cd /home
    # /scripts/pkgacct siteuser

     4. When that completes without error, move the file to the destination server using scp

     
    # scp /home/cpmove-siteuser.tar.gz [email]root@cpanel.company.com[/email]:/home/
    (enter root's password if you're not using keys)
     
    Destination server (cpanel)
    1. SSH into the destination server and become root
    2. cd into /home and run the restorepkg command calling that same username to create the user and complete the migration
     
    # cd /home
    # /scripts/restorepkg siteuser
     
     
     
     After this runs, you'll see that everything for that user has now transferred over!

    Things that are handy to know:
    1. If the user's account is huge, and perhaps there's not enough room on the server, you can run the pkgacct command with --skiphomedir flag:

     # /scripts/pkgacct --skiphomedir siteuser


     
    Things to check:
    1. database names may now have different names on the cpanel server depending on your configuration. Instead of 'databasename' it may now be 'siteuser_databasename' or something similar.
    2. Run through the site - make sure all of the client's pages come up how they're supposed to - there may have been some special settings in the plesk php.ini or other configuration file that you'll have to now do on the destination/cpanel server.



    Anzil Ali Liyakkath 
    anzil.ali@webhostrepo.com 




    Plesk to cPanel

    How to transfer your website from Plesk to cPanel

    In this tutorial we will show you how to create a full back up of your hosting account on Plesk and migrate it on a cPanel hosting.

    Even the Plesk control panel provides a feature for automatic backup creation, very often this option is disabled by the hosting providers and only manual back up is possible. Furthermore, it can be restored only by the Plesk back up restore tool. Happily, you should not be worried because it is quite easy to create your own back up just in a few clicks using a standard FTP client and the admin panel of your Plesk account.
    Usually the website consists of files and database(s). In this tutorial we will guide you how to create a back up both of them. For files backup we will use a normal FTP client and the databases will be exported via the phpMyAdmin tool available via the Plesk control panel.
    Please click on the images in order to enlarge the screen shots for more detail.
    Basic steps of creating a custom backup:
    1. Copying all files of your main website accessible via http://yourdomain.com.
    2. Copying all files of your websites accessible via your subdomains.
    3. Exporting all of your databases via the PHPMyAdmin
    Copying your files on your local drive:
    In order to copy your files on your local computer and create a custom backup of your files open your favorite FTP client and login under your account.
    1ftplogin
    In the FTP host you should type your domain name or the FTP host provided by your WebHosting company. 99% of all cases your should not experience any difficulties using your domain name as FTP host.Then fill in your FTP username and password for your account.
    As soon as you log in a similar content should be displayed on your scree:
    httpdocs
    Most probably on the left side you should see your local HDD content and on the right side your hosting account content. I will recommend you to create a local folder called backup for example, where you will download your hosting account content.
    The content of your website that is directly accessible at http://yourdomain.com is located under the httpdocs directory. If you have any subdomains created (http://subdomain.yourdoman.com) you should copy the content of the subdomains folder as well.
    So, first drag and drop the httpdocs folder from the right part to your back up directory on your local computer. Depending on your website size it might take some time to complete the process.
    subdomains
    As soon as you have your httpdocs folder copied you may copy the whole subdomains directory as well or selectively copy your subdomains content one by one.Please note that if you have uploaded any data under your account out of your httpdocs and subdomains folders it will be good idea to copy it as well on your local HDD.
    Export your databases:
    Exporting your MySQL databases should not be a problem by following these basic steps below:
    First access your Plesk control panel and login by using your Plesk username and password.
    Be advised that your main FTP account username and password might be different from your Plesk control panel login credentials.
    plesklogin
    Wait for a second to have your page reloaded and click on your domain name from bottom of the page.
    61
    From the new page click on the Databases Icon from the service section
    771
    From the new page select your database from the list by clicking on its name.
    dbnames
    This will take you to a new page from where you should click on the DB WebAdmin tool. A new window should be open for you from which you will need to click on your database name (on the top left corner).
    In order to add an addon domain to your account you need an addon slot.
    You will have to order as many addon slots as the number of addon domains you need to add.
    You can order an addon slot from Customer’s Area -> Order Extras.
    As soon as the page is reloaded and your database tables are displayed click on the Export thumb on the top. After having your page reloaded you will have several options available.
    10101From this screen you should make sure that you have selected all of your database tables (see the screenshot). Additionally, it is recommended to tick the “add drop tables” option before having your database exported. If you need your database in any format different than SQL you can change it via the Export options under the tables list menu.
    As soon as you have all the options applied select “Save As File” and click on the “Go” button on the bottom right corner. A question box will be displayed asking for the exact location where you would like to store your MySQL database dump. Select the appropriate location on your local HDD and click Save.
    Please note that if you have more than one databases you should export all of the following the instructions above.
    Restoring your website on your new cPanel hosting account:
    In order to restore your website on your cPanel account you will need to upload your files and databases to your new host. You can easily upload your files by following our video tutorial at:
    http://www.tmdhosting.com/tutorials/video/ftp.html
    As soon as you have your httpdocs files and subdomains folders uploaded under your public_html directory you should import your databases. First, you will need to create a new database via your cPanel -> MySQL databases section following the instructions in our tutorial at:
    http://www.tmdhosting.com/tutorials/video/cpanel/cpanel-x3-createmysql.html
    When you have your databases created you should import your mysql dump which you have exported earlier via your cPanel -> phpMyAdmin. Please follow the instructions at:
    http://www.tmdhosting.com/tutorials/video/phpmyadmin/phpma-import.html
    When you have both your files and databases uploaded on your new host you should reconfigure your application to work with the new hosting enviropment. This can be done by editing your application configuration file. Most probably you will need to modify the mysql database name, username, password and hostname as well as the server path to your new document root for your domain name. The mysql database name, username and password are as you have set them during the creation process in your cPanel -> MySQL database. As for the database hostname — most probably it is localhost — still, you might always contact the support team of your host for the exact database hostname to which your application should connect.
    The document root on cPanel hosting servers is usually: /home/your-cpanel-username/public_html/
    I hope you will find this tutorial useful. If you experience any difficulties to create your back up just drop a comment and we will be glad to help you by adding further instructions in this tutorial. Be advised that TMDHosting Support team will perform the website transfer for you free of charge as a part of our hosting package. For more information you may check our hosting plan features or contact our representatives via the live chat.


    Anzil Ali Liyakkath
    anzil.ali@webhostrepo.com