Tuesday 2 December 2014

Nameserver update at registrar end

create host
ex:
ns1 with ip >>

 ns1.nameserver.com >> ip
>> ns2.nameserver.com>> ip
Then update the nameservers >>

Subdomian via cPanel

Log into your cPanel
Go to the Domains section and click on Subdomains.
subdomins_1
Type in the name of the subdomain and select the domain to create it under. It will automatically create a folder for the subdomain in your public_html folder
subdomins_2
Click the Create button. You will then see a message stating it “has been created.”
subdomins_3

cPanel/ WHM Installation / installation of diffrent types of cPanel

Please refere the link
http://docs.cpanel.net/twiki/bin/view/AllDocumentation/InstallationGuide/InstallingCpanel
Or

Connecting to your server remotely via SSH

To connect to your server remotely via SSH:
  1. Open the command line interface (using a terminal application).
  2. Run the command ssh root@$IP (where $IP represents your target server’s IP address).
  3. Enter your server’s root password.

Connecting to your server from a Windows® PC via PuTTy

To connect to your server from a Windows® PC via PuTTy:
  1. Download the client from the PuTTy site and install.
  2. Open the client.
  3. In the Sessionsmenu, enter your server’s IP address.
    • You should make sure the SSH button is selected.
  4. Click Open.
  5. Enter your server’s root password.
=============
  • yum users should run the following command: yum install perl
  • up2date users should run the following command: up2date -i perl
To install cPanel & WHM, run these commands:
  1. cd /home — Opens the /home directory.
  2. wget -N http://httpupdate.cpanel.net/latest — Fetches the latest installation files from cPanel’s servers.
  3. sh latest — Opens and executes the installation files.
If licensing fails (due to a strict firewall or modified IP), run the command /usr/local/cpanel/cpkeyclt to activate your cPanel & WHM license.=====

Installing cPanel DNSONLY

To install cPanel DNSONLY, run these commands:
  1. cd /home — Opens the /home directory.
  2. wget -N http://httpupdate.cpanel.net/latest-dnsonly — Fetches the latest installation files from cPanel’s servers.
  3. sh latest-dnsonly — Opens and executes the installation files.

Getting started in WHM

To access the WHM interface:
  1. Enter https://$IP:2087into your preferred web browser.
    • $IP represents your server’s IP address.
  2. Enter root into the Name field.
  3. Enter your root password into the Password field.
  4. Click Log In.

Cpanel / WHM password not working

Enter via node
1)   soluvm >> vps detail.. > try change root password
If fail>>
<<
2) get details about the node from database
> enter the node via bterminal
vzlist> vzctl enter nodenumber
change the root password( passwd root)
also check that our ip is black listed ..    csf -g ip
And run /script/cphulkdwhitelist IP
Then do
/script/upcp
Service cpanel restart
Service iptables stop
If you need then use the above two commands….
==============
For reseller
==
Please login >> WHM>> password modification

====
    :)
:)     :)      

Hardware RAID

http://docs.oracle.com/cd/E19121-01/sf.x4240/820-2397-15/RAID-Appendix.html

MySql Optimizing

https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
Then GOTO
cd /home/
vi mysqltuner.pl
goto that link and copy all the item..
or google and type mysqltuner..
copy paste
chmod +x mysqltuner.pl
./mysqltuner.pl
copy >>
query_cache_size=8M
thread_cache_size=4
table_open_cache=400
vi /etc/my.cnf
PASTE
service mysql restart
query_cache_size=8M
thread_cache_size=4
table_open_cache=400

Rsync Old server to New server

user cmd while you are in the desired location
======
rsync -zavh httpdocs root@IP:/var/www/vhosts/commodityonline.com/
======

Change cPanel Theme (Shared server also)

Login IP u/p>> Terminal
cd /var/cpanel/username
vi username
change theme =x3  (ex: basic was sonic then change to x3)
write quite
restart the cpanel service
====================

Server hacking Precuations

Web hacks happen due to a lot of reasons, especially for common CMS scripts like WordPress. It can be a bad theme, plugin or an insecure permission. As you can see, we gave the customer steps to secure his wordpress website and he said he will implement it.
We can avoid 99% of hacks by securing the WP Admin area, wp-contents and avoiding low rated plugins/themes. I will have the quality department add/implement few more steps to check these hacks.
Server hacking/ check
=====================
- Logs, check entries from IP’s and what they accessed.
- File/Folder permissions secure?
- All passwords for root, mysql, ftp, etc should be changed to something more difficult
- Brute force should be installed
- Check for the scripts they may have gained access from
>> We can also run maldet, clamav anti viruses on that server to prevent further hacking

Error while boot>> Showing partition table error

do shift +f10 >> (while we are in the installation step)
type >>
diskpart >> enter
list >>
select disk 0
clean
=====================
close the cmd windowa and >> enjoy the installation

Word press>> Changing site url

Migrated a domain from a subdomain in the same IP, >> we can logging to the home page of new server at when we click the about-us or anything  then it will re-direct to the subdomain (old location).
http://codex.wordpress.org/Changing_The_Site_URL
Just use it and enjoy…

Disabling SSH login for root

Disabling SSH login for root
After you create a normal user, you can disable SSH logins for the root account. To do this, follow these steps:
Log in to the server as root using SSH.
Open the /etc/ssh/sshd_config file in your preferred text editor (nano, vi, etc.).
Locate the following line:
PermitRootLogin yes
Modify the line as follows:
PermitRootLogin no
Add the following line. Replace USERNAME with the name of the user you created in the previous procedure:
AllowUsers USERNAME

Litespeed webserver plugin

LiteSpeed Web Server Plugin for WHM is a tool to easily integrate and manage LiteSpeed web server with cPanel. Once installed, it can be accessed from cPanel, WebHost Manager Plugins section.
Login as root
>> cd /usr/src
>> wget http://www.litespeedtech.com/packages/cpanel/lsws_whm_plugin_install.sh
>>chmod 700 lsws_whm_plugin_install.sh
>>./lsws_whm_plugin_install.sh
>>rm -f lsws_whm_plugin_install.sh
>>And Login to WHM and install lite speed in it.

Easy apache

/Script/easyapache
Using easyapache we can install more modules easily
-mysqli
-ion cube loader
-source guardian
-gzip compression
-memcache 512kb
-php-gd (php module)

File found while using the cmd locate but it was hidden >> Hacked

This issue might be a funny one but too dangerous
====
We can locate the file

locate example..

But we cannot see the file or folder by using  ll, ls , vi ,cd cmds..
The amazing fact is there is no log too. But using the hacked file we can easily login with out permission and upload and sown load the files ..
I have sorted this issue by finding the script in the .htacess file and in the index.php, and php.ini file
tough but crazy one

Server load high but no cpu usage

Just check the load via user ..
like
/usr/local/cpanel/bin/dcpumonview | sed -e ‘s/<[^>]*>/ /g’ | grep  username
ex:  /usr/local/cpanel/bin/dcpumonview | sed -e ‘s/<[^>]*>/ /g’ | grep  root

FTP over wget

You can use below script to download files to your server using wget


ftp://wget -r –ftp-user=”your username” –ftp-password=your password [ftp]ftp://serverurl

What is RAID?

RAID (redundant array of independent disks; originally redundant array of inexpensive disks) is a way of storing the same data in different places (thus, redundantly) on multiple hard disks. By placing data on multiple disks, I/O (input/output) operations can overlap in a balanced way, improving performance. Since multiple disks increases the mean time between failures (MTBF), storing data redundantly also increases fault tolerance.
How to reload server with Raid-1 using mdadm raid
We need two identical hard disks for doing this. Let this be sda and sdb.
When reaching the partition menu we need to select custom layout
Follow the steps below for the first drive:
Click Create
From the popup choose RAID Partition and click Create
From the popup select ONLY sda, set the Size to 1000MB (this is the size for /boot), select Fixed size, select Force to be a primary partition and click OK.
For the second drive the steps are similar but in the second pop-up select sdb:
Click Create
From the popup choose RAID Partition and click Create
From the popup select ONLY sdb, set the Size to 1000MB (this is the size for /boot), select Fixed size, select Force to be a primary partition and click OK.
In the main overview we need to create a RAID device for /boot:
Click Create
From the popup choose RAID Device and click Create
From the popup set the Mount Point to /boot, select both sda1 and sdb1 and click OK.
Now we can continue creating the other partitions.
Start with the first drive:
Click Create
From the popup choose RAID Partition and click Create
From the popup select ONLY sda, select Fill to maximum allowable size and click OK.
Second drive:
Click Create
From the popup choose RAID Partition and click Create
From the popup select ONLY sdb, select Fill to maximum allowable size and click OK.
In the main overview we need to create a RAID device for the other partitions:
Click Create
From the popup choose RAID Device and click Create
From the popup I have set the mount point as / and continued with the installation.
Please let me know if you have any further queries.

SoftRAID +New server : Reloading server

In this thread we will see how to provision a server with Software RAID once the server is booted in OS.
1. Install OS with ISO over IPMI on sda drive.
2. yum install mdadm initramfs-tools
3. # Add raid1 or raid0 to /etc/modules
echo “raid1″ >> /etc/modules
(for raid0 add that module)
echo “raid0″ >> /etc/modules
4. # Regenerate initrd.img file
mkinitramfs -o /boot/test -r /dev/mapper/root (replace /dev/mapper/root with your actual LVM root partition)
5. # Rename old img file (replace .x for whatever kernel version you are using)
mv /boot/initrd.img-x.x.x /boot/initrd.img-x.x.x.original
6. # Rename new img file
mv /boot/test /boot/initrd.img-x.x.x
7. grub-install –no-floppy /dev/sda
grub-install –no-floppy /dev/sdb
8. # Change UUID for (hd0,0) on /boot/grub/menu.1st if your file has the UUID in it.
# This most likely involves replacing the root UUID=XXXXX line with root hd(0,0)
# vi /boot/grub/menu.1st
9. Change UUIDs for proper md0 devices on /etc/fstab if your file has the UUID in it.
# Now do the same thing for the /etc/fstab file.
# Replace the UUID=XXXXXXXXX /boot ext3 defaults 0 1 line with /dev/md0 /boot ext3 defaults 0
# vi /etc/fstab
10. Clone the partition table from 1st drive to 2nd
sfdisk -d /dev/sda | sfdisk –force /dev/sdb
11. Create md devices with second drive only
mdadm –create /dev/md0 –level=1 –raid-devices=2 missing /dev/sdb1
mdadm –create /dev/md1 –level=1 –raid-devices=2 missing /dev/sdb2
12. Save new mdconf file
mdadm –detail –scan >> /etc/mdadm/mdadm.conf
13. # Get boot device setup
mkfs.ext3 /dev/md0
mkdir /mnt/md0
mount /dev/md0 /mnt/md0
cp -ax /boot/* /mnt/md0
umount /mnt/md0
umount /boot; mount /dev/md0 /boot
sfdisk –change-id /dev/sda 1 fd
mdadm –add /dev/md0 /dev/sda1
14. # Setup data device
pvcreate /dev/md1
vgextend pve /dev/md1
# this step takes a LONG time
pvmove /dev/sda2 /dev/md1
vgreduce pve /dev/sda2
sfdisk –change-id /dev/sda 2 fd
mdadm –add /dev/md1 /dev/sda2
15. Rebuilding an array currently requires us to manually rebuild the partition table on the fresh hard drive. We need to know which drive is still active and which one is the new one. To see this let’s run the following command:
# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[0]
104320 blocks [2/1] [U_]
md1 : active raid1 sdb2[0]
1052160 blocks [2/1] [U_]
md2 : active raid1 sdb3[0]
243039232 blocks [2/1] [U_]
unused devices: <none>
To read this look at the first managed disk, md0. If you are adding back in a partition on a drive that is not empty you may have to keep track of which drive different ones are on. For the current purposes we will assume that we are installing a fresh, unpartitioned drive.
16. We need to see what the current drive is partitioned as, so we can duplicate the same partition table on the new drive:
# fdisk -l /dev/sdb
Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      104391   fd  Linux raid autodetect
/dev/sdb2              14         144     1052257+  fd  Linux raid autodetect
/dev/sdb3             145       30401   243039352+  fd  Linux raid autodetect
… and just to verify that /dev/sda is blank …
# fdisk -l /dev/sda
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
17. Now we need to edit the partition table on /dev/sda to match exactly what we see on /dev/sdb.
# fdisk /dev/sda
The number of cylinders for this disk is set to 30401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
For the cylinder start/stop values just refer to the existing partition table. It says “Start” and “End” values for each partition. If you just copy these exactly as the fdisk -l for that drive outputs it will create them exactly the same for you.
First cylinder (1-30401, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-30401, default 30401): 13
Command (m for help): p
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          13      104391   83  Linux
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-30401, default 14): 14
Last cylinder or +size or +sizeM or +sizeK (14-30401, default 30401): 144
Command (m for help): p
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          13      104391   83  Linux
/dev/sda2              14         144     1052257+  83  Linux
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (145-30401, default 145): 145
Last cylinder or +size or +sizeM or +sizeK (145-30401, default 30401): 30401
18. We need to set the boot partition as bootable or this drive won’t be very useful if the other dies
Command (m for help): a
Partition number (1-4): 1
19. Now we need to set the partition type to ‘fd’ for all of the partitions which is hex for a linux raid partition.
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): fd
Changed system type of partition 3 to fd (Linux raid autodetect)
20. Let’s look at the partition table we created, it should be identical to the one above from the existing hard drive.
Command (m for help): p
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   fd  Linux raid autodetect
/dev/sda2              14         144     1052257+  fd  Linux raid autodetect
/dev/sda3             145       30401   243039352+  fd  Linux raid autodetect
21. If it looks good then we use w to write to the disk and exit
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
22. I usually run ‘cat /proc/mdstat’ again so I can see the partitions and compare as I add the newly created partitions back into the raid array.
# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[0]
104320 blocks [2/1] [U_]
md1 : active raid1 sdb2[0]
1052160 blocks [2/1] [U_]
md2 : active raid1 sdb3[0]
243039232 blocks [2/1] [U_]
unused devices: <none>
23. Now we have to add in each of the partitions back into the managed disks, one at a time. I run ‘cat /proc/mdstat’ again after each addition to make sure it worked.
# mdadm /dev/md0 –add /dev/sda1
mdadm: added /dev/sda1
# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[1] sdb1[0]
104320 blocks [2/2] [UU]
md1 : active raid1 sdb2[0]
1052160 blocks [2/1] [U_]
md2 : active raid1 sdb3[0]
243039232 blocks [2/1] [U_]
unused devices: <none>
# mdadm /dev/md1 –add /dev/sda2
mdadm: added /dev/sda2
# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[1] sdb1[0]
104320 blocks [2/2] [UU]
md1 : active raid1 sda2[2] sdb2[0]
1052160 blocks [2/1] [U_]
[========>............]  recovery = 43.5% (458752/1052160) finish=0.1min speed=76458K/sec
md2 : active raid1 sdb3[0]
243039232 blocks [2/1] [U_]
unused devices: <none>
# mdadm /dev/md2 –add /dev/sda3
mdadm: added /dev/sda3
# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[1] sdb1[0]
104320 blocks [2/2] [UU]
md1 : active raid1 sda2[1] sdb2[0]
1052160 blocks [2/2] [UU]
md2 : active raid1 sda3[2] sdb3[0]
243039232 blocks [2/1] [U_]
[>....................]  recovery =  0.1% (308480/243039232) finish=78.6min speed=51413K/sec
unused devices: <none>
24. The last step is to update/refresh the grub configuration on both drives. These steps need to be taken on the main drive (eg. /dev/sda not /dev/sda1) of each member of the RAID array:
# /sbin/grub
grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
grub> device (hd0) /dev/sdX
grub> root (hd0,0)
grub> setup (hd0)
NOTE: the device name changes, but the grub values (hd0) do not. This ensures that the drives are detected properly in a failure situation.
And that is it. We are rebuilding as you can see. In this case it should take almost an hour and a half to rebuild the largest partition, with the smaller ones done almost as fast as you can type the commands.

memory exceeds >> php.ini file edit

The error normally occurs when PHP tries to process a big database records or when importing or exporting. To solve the error, there are two fixes. One is to increase PHP memory limit of the account by using a custom php.ini file. But sometimes it won’t work.
If it didn’t work, then you can fix the error by increasing the memory of the particular PHP script (displayed in error message) by adding an additional line at the top of the script:
Code: [Select]
ini_set(”memory_limit”,”32M”);  
(Change the value based on the error message).
Now browse the page again, perform the operation again. It will just work fine if you have set correct value based on the error message.

Can not open `/var/lib/mlocate/mlocate.db’: No such file or directory

The locate command is a very useful command to find the exact path/location of files in Linux if you know the file name. You can install it using yum and the package is mlocate.
Quote
can not open `/var/lib/mlocate/mlocate.db’: No such file or directory
It is a common issue while using locate command, and the error is because we haven’t created the db for locate. To create db for locate, simply run the command :
Code: [Select]
# updatedb
Wait for it to complete and run the locate command again. It should be working fine this time…!!!  :D
You can use the same command (updatedb)to update recent changes to locate’s db.

Enable MySQL slow query log

The slow query log consists of SQL statements that took more than long_query_time seconds to execute and required at least min_examined_row_limit rows to be examined. It is very helpful in troubleshooting bad queries.
Add the following to /etc/my.cnf file to enable the slow query log:
Code: [Select]
log-slow-queries=/var/lib/mysql/slow.log
After that, then do the following commands to create the file with the right ownership and file permissions:
Code: [Select]
touch /var/lib/mysql/slow.log
Code: [Select]
chmod 660 /var/lib/mysql/slow.log
Code: [Select]
chown mysql:mysql /var/lib/mysql/slow.log

Php page showing a warning message: phpinfo() has been disabled

If you get the message while browsing php info page, it means that phpinfo function is disabled. To resolve this you will have to :
Remove phpinfo from disable_functions in php.ini
To locate php.ini file, use command :
Code: [Select]
# php --ini
Check the line Loaded Configuration File: for php.ini location. Remove phpinfo  from disable_functions in php.ini and save it.
Now check the phpinfo page

Softaculous – The INFO.XML file could not be found!

This happens if the scripts are not downloaded. The fix is to run CRON :
SSH to your server as root and enter following commands:
For cPanel:
# /usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/cron.php
For Direct Admin:
#  /usr/local/bin/php -d open_basedir=/ -d safe_mode=0 -d disable_functions=”" /usr/local/directadmin/plugins/softaculous/cron.php
For Plesk:
SSH to your server as root and enter following command :
# php /usr/local/softaculous/cron.php

Whitelist an IP from IPTABLES

To check if an IP is blocked in iptables, use the command :
Code: [Select]
# iptables -nL | grep IP
Sample output :
DROP       all  –    x.x.x.x    0.0.0.0/0
If the IP is blocked in iptables, to see the rule :
Code: [Select]
iptables-save|grep IP
Sample output :
-A LOCALINPUT -s x.x.x.x -i eth0 -j DROP
Take the results and replace “-A” with “-D” and run it with iptables
Eg : iptables -D LOCALINPUT -s x.x.x.x -i eth0 -j DROP

Round cube Mail issue with out an header.

 login WHM>> cPanel >> check the quota>>it should be full

Please increase the quota size.

WHM + cPanel login failed to open session lockfile: FILE=/var/cpanel/sessions/raw==== Disk quota exceeded at /usr/local/cpanel/Cpanel/Session.pm line 238

Error:

failed to open session lockfile: FILE=/var/cpanel/sessions/raw/:vcLgdleh6y8pqVchZOpxJ85a133IKpf7UsU4FrhLW0tFJmVEC7jHZJ90ZtBUKNIZ.lock, Disk quota exceeded at /usr/local/cpanel/Cpanel/Session.pm line 238

====

Check the disk size
=======
# df-Th
you  could see the disc is 100%

Please delete some unwanted files and try login

Fine. 

Nginx Page not found -- 500-

View nginx error log
/var/log/nginx/nginx_error.log

If the service is temporarily stopped Please restart the same .