11 Apr 2018

Installing CloudFlare plugin on cPanel server

This is a free Content Delivery Network (CDN) for your domain. CloudFlare provides a better Internet security services and distributed domain name server services, sitting between the visitor and the Cloudflare user’s hosting provider, acting as a reverse proxy for websites. CloudFlare’s cPanel plugin is also available to manage the CloudFlare account simply through the cPanel itself.

The CloudFlare cPanel plugin installation is very simple and it can be achieved within 5 minutes. This plugin integrates CloudFlare with your cPanel server. Try this and enjoy!!!

Installation Steps

Step 1. SSH to the server in which you need to install CloudFlare plugin.

Step 2. Enter the cPanel basic directory:

cd /usr/local/cpanel

Step 3. Download the tar file to your server.

curl -k -L https://github.com/cloudflare/CloudFlare-CPanel/tarball/master > cloudflare.tar.gz

Step 4. Untar the file

tar -zxvf cloudflare.tar.gz

Step 5. This will extracts a directory which includes a UNIQUE_ID. The sample format of this will be as follows:

cloudflare-CloudFlare-CPanel-w40bbb3

Here w40bbb3 is the UNIQUE_ID.

cd cloudflare-CloudFlare-CPanel-UNIQUE_ID/cloudflare

Step 6. Execute the install script in the following format:

./install_cf API_HOST_KEY mod_cf "Your Company Name"

API_HOST_KEY – You will get this from your CloudFlare panel.
Your Company name – You can give your hostname here.

How to find the API_HOST_KEY?

You can copy the API_HOST_KEY from your CloudFlare account. Please do the following steps to find out the API_HOST_KEY.

Step 1. Log into your CloudFlare account.

Step 2. Go to “My Settings”.

Step 3. Scroll down to “Global API Key”.

Step 4. Click on the “View API Key” button to see your API identifier.

Installation Steps

Step 1. SSH to the server in which you need to install CloudFlare plugin.

Step 2. Enter the cPanel basic directory:

cd /usr/local/cpanel

Step 3. Download the tar file to your server.

curl -k -L https://github.com/cloudflare/CloudFlare-CPanel/tarball/master > cloudflare.tar.gz

Step 4. Untar the file

tar -zxvf cloudflare.tar.gz

Step 5. This will extracts a directory which includes a UNIQUE_ID. The sample format of this will be as follows:

cloudflare-CloudFlare-CPanel-w40bbb3

Here w40bbb3 is the UNIQUE_ID.

cd cloudflare-CloudFlare-CPanel-UNIQUE_ID/cloudflare

Step 6. Execute the install script in the following format:

./install_cf API_HOST_KEY mod_cf "Your Company Name"

API_HOST_KEY – You will get this from your CloudFlare panel.
Your Company name – You can give your hostname here.

How to find the API_HOST_KEY?

You can copy the API_HOST_KEY from your CloudFlare account. Please do the following steps to find out the API_HOST_KEY.

Step 1. Log into your CloudFlare account.

Step 2. Go to “My Settings”.

Step 3. Scroll down to “Global API Key”.

Step 4. Click on the “View API Key” button to see your API identifier.

mod_cf is optional. If set, the installer will also try to install mod_cloudflare

That’s it!!! Now, you will be able to see an icon for “CloudFlare” in all your cPanel accounts.

cloudflare

Sample Output for a successful installation:

info [verify_api_spec_files] LoadFile
Done
Register Complete

==> mod_cloudflare: Installed successfully.
==> You may need to customize your EasyApache profile to include Mod CloudFlare

CloudFlare module installed successfully.

In some cases, if you see the output as :

Your HOST_KEY (d892a17e61de5caa062302d54714eb39e4d42) is invalid.

If you see this error, please contact CloudFlare support and ask for valid Host key.

That’s it 🙂

Share this
19 Mar 2018

Installing and configuring ClamAV for cPanel server

WHM comes with a free, pre-installed version of clamavconnector (Clam antivirus) that is not activated by default.

Activate it by following this procedure:

  1. Connect to your WHM interface as root.
  2. On the home page, click on the cPanel link (icon).
  3. Click on “Manage Plugins”.
  4. Select the box “Install and keep updated” in the corresponding section to clamavconnector.
  5. Click on save at the bottom of the page to confirm the installation.

WHM will then download the necessary packages for clamavconnector and will install it automatically,  this may take a few minutes.

Once the installation has been completed, you will have a virus scan link in your cPanel interface.

Please go through the relevant screen captures:

clamav.png

clamav2.png

clamav3.png

That’s it !!!

Share this
15 Mar 2018

How to install nslookup, dig, host commands in Linux

That can’t do moment we face when we are trying to check if the website is pointing to correct IP and the nameservers which are authoritative for our servers are added correctly at the registrar end. A newly installed machine will not have dig, nslookup, host commands. So we have to manually install them on our servers. All these commands are included in a package called “bind-utils”. But different OS have different package names. I will be doing everything as root user, if you don’t have root privileges then you just have to add sudo before every command.

Installing is pretty straight process by the way.
My ubuntu sources list

root@serversupportz:~# cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu lucid main
deb http://archive.ubuntu.com/ubuntu lucid-updates main
deb http://security.ubuntu.com/ubuntu lucid-security main
deb http://archive.ubuntu.com/ubuntu lucid universe
deb http://archive.ubuntu.com/ubuntu lucid-updates universe

In ubuntu systems it is “dnsutils”

 

root@serversupportz:~# apt-get update
root@serversupportz:~# apt-get install dnsutils -y

In RHEL/Centos it will be bind-utils

root@serversupportz:~# yum install bind-utils
Share this
22 Feb 2018

How to enable Varnish in cPanel server

Varnish is a caching technology. Varnish is a web accelerator and also referred as HTTP accelerator or reverse HTTP proxy, which will significantly enhance the performance of your website. Varnish cache is really fast thereby, speed up the delivery depending on your architecture.

Varnish enhance your website’s performance. Varnish stores a copy of the page which is served by the web server the first time a user visits the website. Next time, when the user requests for the same page, varnish will serve the copy instead of serving it from the web server. Thus, your webserver needs to handle only less traffic and there by increase the website performance and also reduce the server load.

 

Working of Varnish Cache

Once Varnish is installed in your server, it will listen in the port 80. Make Apache to listen in any other port other than 80. When a client requests for a page in your website, Varnish will try to serve the page from its cache memory. This is cache hit. If the page is not in its cache memory, then Varnish will request to HTTP (Apache) to serve the page and caches it for future reference.

Features of Varnish

1. Reduces the server load
2. High speed (cache + stored in RAM)
3. Useful to gain more visitors

Installation

1. Make Apache listen in any other port other than 80. Here I am making Apache to listen in port 8080. It can be done in two ways. Either editing the httpd.conf file or editing the Tweak settings in WHM

a) Editing httpd.conf file

# vi /usr/local/apache/conf/httpd.conf

Locate the following line in /usr/local/apache/conf/httpd.conf file and change the port from 80 to 8080

Listen 0.0.0.0:80

Once edited, the Apache config file for “Listen” should be as follows:

# grep -iw listen /usr/local/apache/conf/httpd.conf
Listen 0.0.0.0:8080

OR

b) Editing WHM – Tweak settings

WHM > Tweak Settings > Apache non-SSL IP/port

Set the port to 8080 and save the settings.

# grep VARNISH_LISTEN_PORT /etc/sysconfig/varnish
VARNISH_LISTEN_PORT=80

5. Edit Varnish config: /etc/varnish/default.vcl . Correct the IP address in this file to your IP address and port to 80

backend default {
  .host = "YOUR IP ADDRESS";
  .port = "80";
}

6. Start Varnish service on your server

# chkconfig varnish on
# service varnish start
# service varnish start
Starting Varnish Cache:                                    [  OK  ]

That’s it!!

You can check this by using the netstat command.

#netstat -plan | grep :80

Example:

# netstat -plan | grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      15129/varnishd      
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      12897/httpd        

Now, you can start monitor your Varnish with varnishstat

 

If you need to change your Varnish configuration file and you can test the configuration before restarting Varnish service by

# varnishd -C -f /etc/varnish/default.vcl

Note: While doing “yum install varnish” if you are getting libedit error, then follow the steps below:

varnish-3.0.5-1.el5.centos.x86_64 from varnish-3.0 has depsolving problems
  --> Missing Dependency: libedit.so.0()(64bit) is needed by package varnish-3.0.5-1.el5.centos.x86_64 (varnish-3.0)
Error: Missing Dependency: libedit.so.0()(64bit) is needed by package varnish-3.0.5-1.el5.centos.x86_64 (varnish-3.0)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

In this case, you need to install the libedit rpm which is suitable for your architecture. You can find the rpm from http://rpmfind.net/linux/rpm2html

# wget ftp://rpmfind.net/linux/dag/redhat/el5/en/x86_64/dag/RPMS/libedit-20090923-3.0_1.el5.rf.x86_64.rpm
# rpm -ivh libedit-20090923-3.0_1.el5.rf.x86_64.rpm

Example:

# rpm -ivh libedit-20090923-3.0_1.el5.rf.x86_64.rpm
warning: libedit-20090923-3.0_1.el5.rf.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing...                ########################################### [100%]
   1:libedit                ########################################### [100%]

Done!!!

Share this
21 Feb 2018

How to create MySQL database and user from command line

This is actually the base of MySQL command usage. By the help of a control panel we can simply create a database, create DB users, edit variables, set previeages etc. But in some situations it is necessary to manage these MySQL options via command line. Here I am explaining the commands for creating database and database user form command line.

Enter the mysql prompt by following the step below:

# mysql -u root -p

It then prompts for password. Enter the MySQL root password.

Example:

root@serversupportz[/]# mysql -u root -p
Enter password:

MySQL command to create a DB(Database).

mysql> CREATE DATABASE name_of_the_database;

Example:

mysql> CREATE DATABASE serversupportz_wp;
Query OK, 1 row affected (0.04 sec)

You can verify it by:

mysql> SHOW DATABASES;

MySQL command to create a DB user.

mysql> CREATE USER name_of_the_database_user;

Example:

mysql> CREATE USER serversupportz_wp;
Query OK, 0 rows affected (0.07 sec)

You can find out the details of all users from mysql.user file:

mysql> select user from mysql.user;
mysql> select host, user, password from mysql.user;
mysql> select * from mysql.user;

Access the database

mysql> use name_of_the_database;

Example:

mysql> use serversupportz_wp
Database changed

That’s it 🙂

Share this
15 Feb 2018

How to Migrate Email from cPanel to cPanel

When transferring accounts between servers, transferring of email accounts is quite different. Transferring data from one server to another is technically called migration even if it is full website or email accounts or databases. When you perform a full website migration of a cPanel account, you do not need to migrate the emails manually. The cPanel transfer will migrate the email accounts also. As we know, there can be DNS propagation after a DNS change when you migrate your website. In the DNS propagation time, some of the emails coming to your email address may be directed to the old server and some of them to the new server. It should be ensured that you do not loss any valuable emails. This is what makes the email migration different from other migrations. Let’s see how the email account transfer is done for both cPanel and non-cPanel accounts.

Email Migration

Email migration can be performed in two ways. You can either utilize the cPanel interface or use the command line prompt.

In this article we are going to take a look on how to perform the migration in cPanel in order to navigate this process.

Follow the ensuing steps below:

Step 1: Backing up email directories

The first step in the email migration is to backup email directories present in the old server.

1) Login to cPanel interface for the account in question in the old server.

2) Open ‘File Manager’ under the section ‘Files’.

 

 

3) Go ‘Up One Level’ above public_html.

 

 

4) You can see the mail directory there. Enter into the directory.

 

 

5) Right click on the directory and click on the option available to compress the directory.

6) Now, download the compressed file to your computer.

Step 2: Restore email backups

1) Login to the cPanel interface of the new server.

2) Create the email accounts just as you did in the old server. You can create email accounts from the ‘Email Accounts’ section under the ‘Mail’ category.

3) Open ‘File Manager’ under the section ‘Files’.

4) Go ‘Up One Level’ above public_html and you can see the mail directory there. Enter into the directory.

5) Upload the email backup file to the directory.

6) Unzip the backup file and the delete the zip file.

7) Open Webmail and configure it to display the new email folders.

If you need any further assistance please contact our support department.

Share this
12 Feb 2018

MySQL script for Performance tuning

What is MySQL performance tuning and what does it mean ?

MySQL has a lot of variables in its configuration. We can edit and set/alter variables to our requirements on our server. We can improve the MySQL performance by varying those values in configuration file. A lot of methods and shell scripts are available for tuning your MySQL server. Here I am explaining the installation and usage of one shell script for tuning the MySQL.

This performance tuning shell script will help you to optimize your MySQL server on a huge traffic cPanel server.

Installation steps

The MySQL tuner has simple installation steps. You can download the latest version from HERE.

Step I : SSH to your server as root user.
Step II : wget the latest version.

wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh

Step III : Change the file permission as executable.

chmod 755 tuning-primer.sh

Step IV : Execute the script.

./tuning-primer.sh

See the attached image which has a sample tuner output.

 

tuner

That’s it 🙂

Share this
08 Feb 2018

Cronjob to delete all emails older than one month

Before starting with the cronjob script, we must know the locations where the emails stored in the server. Then we can go to the steps to remove them  Exactly there are three folders in a cPanel based server for managing received emails.

Those are cur, new, tmp. The main differences between these three are listed below

new : This is the folder where all emails are first received.
cur : Is the folder having emails that are opened/read by mail client.
tmp : Is the folder contains processed emails for delivery purpose.

In most cases these emails in the server cause high disk space usage in the server. We can remove older email by using different ways. Here I’m explaining the steps to remove emails older than one month from the server by the help of cron.

To clear old emails from the server means, remove email related files from cur folder under mails directory and all other mail user directory. There are cur and new directories under the mail folder for cPanel default mail and also the same in each users domain directory. ie /home/username/mail/domain.com/***/cur Here *** represents each mail user folder. (admin/ for admin@domain.com)

Step 1 : Creating an executable file with command to remove emails

For simplicity, create an executable file under anywhere (here I selected the location under root) and place the script to remove older mails.

Here I’m using the find command to find and remove mails which are older than 30 days (-mtime switch for finding mails older than 30 days.

[root@serversupportz]# touch mailcleaner.sh

Edit the file using your favorite file editor

[root@serversupportz]# vim mailcleaner.sh

find /home/username/mail/yourdomain.com/*/cur -type f -mtime +30 -exec rm -f {} \;
~
 :wq

Then change that file to an executable one. (ie file permission to 755)

[root@serversupportz]# chmod 755 /root/mailcleaner.sh

Step 2 : Creating CRON job

Next step is to set the cronjob under root (for setting a cronjob refer this link). Here I’m setting the cron job to run every 1 day of the month.

[root@serversupportz]# crontab -e
 0 0 1 * * /root/mailcleaner.sh > /dev/null 2>&1
 :wq
[root@serversupportz]# crontab -l : To list all cronjobs.

In this case the file mailcleaner.sh will execute first day of every month and remove all emails older than 30days.
Thank you.

Share this
14 Nov 2017

How to install SSL certificate on webmin

Webmin is one of the most commonly using Web Hosting control panels. This is an open source control panel which works on port 10000. Here Serversupportz going to explain how/steps to install SSL certificate on a Webmin server.

To add SSL certificate on a domain in your server which has Webmin installed, you must have a valid SSL certificate. Upload the SSL certificate to your server, under the domain name.

Follow the below pasted steps for installing SSL certificate on Webmin:

  1. Upload your SSL certificate file to your server – we recommend that this isn’t in your web root but under the domain name so you know where it is.
  2. Log into your Webmin control panel.
  3. Select the virtual host that you want to secure.
  4. Click on SSL options.
  5. Click “Yes” on Enable SSL.
  6. Select Certificate/Private key and browse to the location of the SSL certificate.
  7. Select Private key file and browse to the location of the ssl private key file.
  8. Save changes and return to the server index.
  9. Restart necessary services.

You may need to restart Apache. From the Apache Webserver page click on “Stop Apache” top right and then “Start Apache” when displayed.

 That’s it!
Share this
14 Nov 2017

How to partition a hard drive using “parted” command?

Recently I had to work on a “Parted” based server. Not always we’ll get chances to work on “parted” based servers. Hence I thought of documenting it. Parted is a command which helps you to modify hard-disk partitions. More than a command, it’s a GNU utility. Using Parted we can add, delete and edit partitions along with the file systems located on them. More than that, suppose think of a criteria that you need to partition a 6TB hard-disk on a Linux server. Most possibly we’ll think of fdisk utility. I’ve to say sorry, because fdisk can’t partition hard-drives more than 2TB in a Linux server. Fdisk will parttion only upto 2TB and around 4TB will remain as unused space. Hence, in that situation “parted” is the only solution. So, you can refer to this article if you need to partition a hard-drive which is greater than 2TB. If you’re first time to “parted”, be careful in doing it because the changes are written to the disk immediately. So please make sure you’ve selected the correct disk before start working on it. Here in this example, the disk size is only 500 GB but I’m using parted to partition it.

First, we can check if “parted” is available on the server. For that we can use the following command:

# parted

You’ll get a similar output if you have parted command available.

If “parted” isn’t available on your server, you can install it using the following yum command in a RHEL server:

# yum install parted

Now, we can check the partitions available on the hard-drives. For that we can use “print” command in “parted” prompt. By-default, “parted” selects the first drive /dev/sda.

# parted
  print

This will also shows the model number of the hard-disk, size of the hard-disk, partition table and the partitions.

To quit the “parted” prompt, we can use “quit”. Also to switch to different hard-drives we can use “select” command.

# parted
  select /dev/sdb 

Now, we can see how we can partition a hard-disk using “parted” command. Here, I’m going to partition /dev/sdb.

1. Set disk label.

We can use “mklabel” command to set the partition table to GPT. “GPT” means GUID partition table format. To set the disk label, enter the “parted” prompt and then use the following commands:

#parted 
 select /dev/sdb
 mklabel gpt
 print ---> This is to verify whether gpt is set as the partition table.

2. Partitioning using “parted”

We can directly enter the /dev/sdb “parted” prompt or we can use “parted” command then “select /dev/sdb” to enter into it.

# parted /dev/sdb 
  mkpart primary 0GB 500GB
  print 

Here, as my hard-disk size is 500 GB, I’m using it as the end point. Use according to your requirement.

3. Format the partition

Now we can use “mkfs” to format it.

# mkfs.ext4 /dev/sdb1

Format the partition

# mkfs.ext4 /dev/sdb1

4. Mounting the partition

Now, we can create a directory and mount it. In my case I’m using it as a backup drive.

# mkdir /backupx
# mount /dev/sdb1 /backupx

For permanent mounting, we need to add it in /etc/fstab.

That’s it!

Share this

©2018 Serversupportz Limited. All Rights Reserved.

Click Me