Pages

Tuesday, February 19, 2013

Hosts file in linux and windows

The hosts file is a computer file used by an operating system to map hostnames to IP addresses. The hosts file is a plain text file, and is conventionally named hosts.

The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system's Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network.

In some operating systems, the hosts file's content is used preferentially to other methods, such as the Domain Name System (DNS), but many systems implement name service switches (e.g., nsswitch.conf for Linux and Unix) to provide customization. Unlike the DNS, the hosts file is under the direct control of the local computer's administrator

 
















































































































Operating SystemVersion(s)Location
Unix, Unix-like, POSIX/etc/hosts[2]
Microsoft Windows3.1%WinDir%\HOSTS
95, 98/98SE, Me%WinDir%\hosts[3]
NT, 2000, XP (x86 & x64),[4] 2003, Vista, 7 and 8%SystemRoot%\system32\drivers\etc\hosts [5]
Windows MobileRegistry key under HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts
Apple Macintosh9 and earlier
Mac OS X 10.0 – 10.1.5 [6](Added through NetInfo or niload)
Mac OS X 10.2 and newer/etc/hosts (a symbolic link to /private/etc/hosts)[6]
Novell NetWareSYS:etc\hosts
OS/2 & eComStation"bootdrive":\mptn\etc\
SymbianSymbian OS 6.1–9.0C:\system\data\hosts
Symbian OS 9.1+C:\private\10000882\hosts
MorphOSNetStackENVARC:sys/net/hosts
AmigaOS4DEVS:Internet/hosts
Android/etc/hosts (a symbolic link to /system/etc/hosts)
iOSiOS 2.0 and newer/etc/hosts (a symbolic link to /private/etc/hosts)
TOPS-20
Plan 9/lib/ndb/hosts
BeOS/boot/beos/etc/hosts[7]
Haiku/boot/common/settings/network/hosts[7]
OpenVMSUCXUCX$HOST
TCPwareTCPIP$HOST

 

UNDERSTANDING SSL FOR CPANEL AND WHM

SSL (Secure Sockets Layer) is essential for securing online communications. When you access your WHM (WebHost Manager) or cPanel, you're logging into powerful administrative interfaces. Without SSL, your login credentials and all data exchanged could be vulnerable to interception. Enabling SSL encrypts this traffic, protecting your sensitive information.


WHY SECURE WHM AND CPANEL?

  • Data Protection: Encrypts your username, password, and all administrative commands.

  • Trust and Reliability: Ensures that you are connecting to the legitimate server and not an imposter.

  • Compliance: Many hosting providers and best practices recommend or require SSL for administrative interfaces.


HOW TO ENABLE SSL THROUGH WHM

The easiest way to secure your WHM, cPanel, and Webmail services is directly through the WHM interface.

  1. Log in to WHM: Access your WebHost Manager using your root or reseller credentials.

  2. Navigate to Service SSL Certificates: In the WHM search bar, type "SSL" and select "Manage Service SSL Certificates."

  3. Select cPanel/WHM/Webmail Service: On the "Manage Service SSL Certificates" page, you will see various services listed. Locate and click on "cPanel/WHM/Webmail Service."

  4. Install an Existing Certificate or Generate a New One:

    • If you have an SSL certificate already issued for your hostname, you can upload it here.

    • WHM also provides options to generate a self-signed certificate, which is sufficient for encrypting traffic for your administrative interfaces, though it might show a browser warning because it's not issued by a trusted Certificate Authority. For public-facing sites, a CA-issued certificate is required.

  5. Review and Apply: Follow the on-screen prompts to install or generate the certificate. WHM will handle the configuration for these services.


BACKEND FILE LOCATION

For those who manage their servers at a deeper level, the primary SSL certificate file for cPanel, WHM, and Webmail services is typically located at:

/var/cpanel/ssl/cpanel/cpanel.pem

This file contains the certificate, private key, and certificate authority (CA) bundle that secures these specific services. However, for most users, interacting with this file directly is unnecessary as WHM automates the process.

Monday, February 18, 2013

Moving MySQL on cPanel: A Simple Guide

There are times you might need to change where your MySQL databases are stored on your cPanel server. Maybe your current disk is full, or you want to put your databases on a faster storage device. Whatever the reason, moving MySQL is straightforward and won't break your cPanel.


STEP 1: BACK UP YOUR DATA

Always back up your data before making any big changes. It's like saving your game progress before a big boss fight.

One easy way to create a backup:

tar -cvf mysql.tar /var/lib/mysql

This command creates a compressed file called mysql.tar that contains all your MySQL data.


STEP 2: TELL MYSQL ABOUT THE NEW LOCATION

You need to update MySQL's main configuration file, my.cnf, to point to the new data directory.

  1. Open the file /etc/my.cnf.

  2. Find the section labeled [mysqld].

  3. Add or change the datadir line to reflect your new path.

For example, if you're moving MySQL from /var/lib/mysql to /home2/mysql, you would add this line:

datadir=/home2/mysql

Do NOT restart MySQL yet!


STEP 3: MOVE THE DATA

Now it's time to copy your existing MySQL data to the new location. We'll use rsync for this, which is good for copying files efficiently.

It's best to stop MySQL, copy the data, and then start it again. If you have a very large database and the copy will take a long time, you can run rsync multiple times while MySQL is still running. However, the final copy must be done with MySQL stopped to ensure data consistency, especially if you use InnoDB tables.

Here's the command to sync, using our example of moving to /home2/mysql:

rsync -av /var/lib/mysql /home2

Next, you need to create a link so cPanel and other applications can find the MySQL socket file in its new home:

ln -sf /home2/mysql/mysql.sock /tmp


STEP 4: RESTART MYSQL

Since you've already updated the my.cnf file, all you need to do now is restart the MySQL service. It will automatically start using the new data directory.

After restarting, your MySQL databases should be running smoothly from their new location.