Posts Under Category: Tutorials

Following command will install PHP on your CentOS server / VPS.

Login to your server as root via SSH and run following command.

yum install php php-mysql


yum install php

Installation wizard will ask your confirmation. Press Y to complete installation.

Check Installation

Once PHP is installed, you can check the PHP version installed using below command

php -v

It will show something like this:

[root@server ~]# php -v
PHP 5.3.3 (cli) (built: Nov 22 2013 10:45:17)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Restart Apache

After installing PHP, restart Apache using below command

service httpd restart

Test PHP

After installing PHP and restarting Apache, its time to test PHP installation on the server.
Create a phpinfo.php fie in /var/www/html/ with following code:


Now open your http://Server-IP/phpinfo.php in any browser.
This should show PHP settings on your server. You have successfully installed PHP on your server.

You can now edit various PHP settings like memory_limit, max_execution_time, max_upload_size, post_max_size etc. in:



Our Recommended VPS Hosting

Following command will install MySQL on a CentOS server / VPS.

Login to your server as root via SSH, and run following command.

Step 1:

yum install mysql-server
service mysqld start

Step 2:

Set MySQL server root password.

sudo /usr/bin/mysql_secure_installation

MySQL server will ask MySQL server root password. Since you just installed mysql, there is no MySQL root password. So, just press enter.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

MySQL will prompt you to set a root password. Press Y to set mySQL server root password.

Set root password? [Y/n]

Enter and re-enter root password for MySQL server. Please use a strong password and do not use your server root password.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Now MySQL will ask a series of questions. Press Y for all.

Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

At the end MySQL will show success message.

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Our Recommended VPS Hosting

You should open only limited ports for incoming and outgoing traffic on a server. You can use firewall like CSF firewall to open only trusted ports on a server.

If you want to check all open/listening ports that your server is using, run below command via SSH:

netstat -an


netstat -tulp


netstat -tulpn

The command will print a list of all open ports, protocol using the port, local address and foreign address (IP).

Our Recommended VPS Hosting

For security reason, it is highly recommended that you use SSH key to login to your server via SSH instead of using root password. In this tutorial I will explain how to use SSH key to login to your server via SSH as root user.

Step 1:

Disable SSH Password Authorization Tweak. For security reason, you should disable SSH Password Authorization Tweak from:

WHM Home >> Security Center >> SSH Password Authorization Tweak


Step 2:

Now we will generate SSH key on a cPanel server. In WHM, navigate to:

WHM Home >> Security Center >> Manage root’s SSH Keys

And click Generate a New Key.

Step 3:

Fill the form for the new SSH key and click Generate Key button. Key name can be anything like your server name or your name. Use a strong key password. Please note, you should not use your root password.

Step 4:

In this step we will authorize the key. Click Manage Authorization for the key that we have generated.
And Authorize this new key.

Step 5:

In this step we will download the SSH key. Click View/Download Key under Private Keys section.

Enter the password that you have used in step 3 while generating this key and click convert button.

Step 6:

Copy the key and paste it on a notepad file. Save this text file as ssh.ppk on your computer. Please note, you may use different name for this ssh key file, but you must use .ppk extension.

Step 7:

So, we have generated and downloaded the SSH key. To use this SSH key with putty, we need to download Pageant.
Download Pageant

Step 8:

After downloading pageant, run it and click Add Key button.

Browse and select the ssh.ppk file that we have saved in step 6. Pageant will ask for password. Enter the password that you have used in step 3. This will add the key in pageant.

Step 9:

Start putty and try to login to your server as root.

Done!! You will get logged in to your server as root user.

Our Recommended VPS Hosting

For security reason, it is recommended that you change your server default SSH port from 22 to any other port. We have a detailed step by step tutorial for changing SSH port.
How to change SSH port of a Linux server

But if you have forgot your server new SSH port number, or if the new SSH port is blocked at server, here is how you can reset SSH port back to default 22 port on a cPanel server.

Step 1:

Login in WHM of your server using root.


Step 2:

Add following url at the end of your WHM url and run it.


The final url may be like:


Your server SSH port is now reset to default 22. If its not working, you may need to restart SSH from

WHM >> Restart Services >> SSH Server

Our Recommended VPS Hosting

In this tutorial, I will explain how to update cPanel License key of a server / vps. cPanel license key can be updated from SSH. You need to update your server license key when you have a new licence key, or you want to upgrade from trail version to paid version.

Login to your server as root and via SSH and run following command



Now try to login in WHM using URL: http://server-ip:2086 OR http://server-ip/whm

Our Recommended VPS Hosting

If you want to see CPU details of your Linux server / VPS, here is how you can check.
Login to your server as root and via SSH, and run following command:

cat /proc/cpuinfo

This will show you your server CPU details like Total processors, CPU model number, speed, cache.

Our Recommended VPS Hosting

Using below commands you can start, stop and restart MySQL from SSH.
Login to your server as root via SSH, and run following commands.

Start MySQL

service mysql start


/etc/init.d/mysql start

Stop MySQL

service mysql stop


/etc/init.d/mysql stop

Restart MySQL

service mysql restart


/etc/init.d/mysql restart

Status of MySQL

If you want to know the status of MySQL on your server, run below command.

service mysql status

read more

Use following command to know the hostname of your server.


You should run above command in SSH as root user.

Our Recommended VPS Hosting

If you want to check how much disk space your server has, how much disk has been used and how much free disk space is left on your Linux server, here is simple command for that.

Login to your server as root via SSH and run following command.

df -h

This will show size, Used, Available, File system mount points.

If you want to check disk usage summery of any particular directory, say /home use below command:

df -h /home

Our Recommended VPS Hosting