Posts Under Category: Dedicated Server

CentOS is the most popular and widely used Linux operating system (OS) on VPS / Dedicated server. You must keep your CentOS updated for security reasons. Below are the basic SSH commands to update CentOS on a VPS / Dedicated server.

Check for update

It will check your machine to see if any update is available.

yum check-update

Run Update

You just need to run one command to apply all updates. Below command will update your machine.

yum update

You can also run yum update command with -y option.

yum –y update

The –y option will answer yes to all prompts such as confirmation that you want to install or update a particular package.

Our Recommended VPS Hosting

When you run cPanel Security Advisor, and if you get kernel out of date warning message, you need to update server kernel. The warning message may be something like below:

Current kernel version is out of date. current: 2.6.32-358.2.1.el6, expected: 2.6.32-358.23.2.el6 Update current system software in the “Update System Software” area, and then reboot the system in the “Graceful Server Reboot” area.

Updating from WHM may not solve this problem. This tutorial explains how to update kernel and solve this warning.

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

yum update

Accept kernel upgrade when asked. Reboot server after update.

Done!!

Our Recommended VPS Hosting

Please follow below steps to change root password via SSH of a dedicated server / VPS.

Step 1:

Login as root to your server via SSH.
login-root

Step 2:

Run below command

passwd

Step 3:

Enter your new password and press enter.
enter-new-password

Step 4:

Re-enter your new password to confirm the password.
re-type-password

If completed successfully, the shell will show you a successful message showing

passwd: all authentication tokens updated successfully.

root password changed

Done!!!

Our Recommended VPS Hosting

This tutorial explains how you can change or move MySQL /tmp directory to a new location on a server / VPS. Login as root to your server via SSH.

Step 1: Open /etc/my.cnf file for editing

nano /etc/my.cnf

Step 2: Add below line under the [mysqld] section and save the file.

tmpdir=/home/mysqltmp

To save file press: Ctrl + O
To exit from nano editor press: Ctrl + X

This will set new location of MySQL tmp to /home/mysqltmp. You may change to any different location.

Step 3: Create new directory

mkdir /home/mysqltmp
chmod 1777 /home/mysqltmp

Step 4: Restart MySQL

/etc/init.d/mysql restart

Step 5: Check new location

mysqladmin var | grep tmpdir

This should show following return.

| slave_load_tmpdir                       | /home/mysqltmp
| tmpdir                                  | /home/mysqltmp

Done!!

Our Recommended Dedicated Server

Many server / VPS have very small /tmp partition like 500 MB. It is recommended to have /tmp partition of minimum 2GB.
If you server is facing issue of /tmp partition filling-up quickly, here is how you can increase its size.

This tutorials explains how easily you can increase size of /tmp partition on a cPanel server / VPS.
Login as root via SSH to your server, and follow below steps / commands.

Step 1: Stop services

Before you start resizing, you should stop cpanel, apache and mysql. Run following command to stop these services

/etc/init.d/cpanel stop
/etc/init.d/httpd stop
/etc/init.d/mysql stop

Step 2: Umount /tmp and /var/tmp

umount -l /tmp
umount -l /var/tmp

Step 3: edit /scripts/securetmp

vi /scripts/securetmp

And change value of my $tmpdsksize For making size of /tmp partition to 2GB change its value to 2048000. After making change save this file. It should be like this:

$tmpdsksize = 2048000

Step 4:Run these commands to resize /tmp partition

rm -fv /usr/tmpDSK
/scripts/securetmp

Step 5: Start services

/etc/init.d/httpd start
/etc/init.d/mysql start
/etc/init.d/cpanel start

Done!!! The /tmp partition on your cPanel server is now of 2GB

This tutorial is applicable only for cPanel Server / VPS

Our Recommended Dedicated Server

I will try to explain the tutorial step by step on a fresh VPS.

I just got a fresh VPS with only operating system installed. OS installed on my VPS is centos 6 64-bits. Below is details of my new VPS.

OS: centos 6 64-bits
IP: 5.231.81.71

Login to your VPS/server as root via SSH and follow these simple steps.

Step 1: Install Apache

My first step is to install Apache on my server. Run following command to install Apache on the VPS.

yum install httpd
service httpd start

For detailed instruction, please refer to this tutorial:
How to install Apache on a Linux Server

After installing Apache, VPS IP will show default Apache page.
default-apache-page

Step 2: Upload HTML pages

Now upload your HTML pages in /var/www/html/ directory.
Your website is now running on your VPS. Address of your website is your VPS IP.
website-on-ip

Step 3: Use a domain name

Now its time to use a domain name like domain.com for your website. This can be achieved using A-record. Create a A-Record and point it to your VPS IP. A-record can be created from domain control panel.
a-record

After creating A-record, wait for few hours for DNS propagation.
Done!!

Our Recommended VPS Hosting

In this tutorial I will explain how to mass change permission of all files and folders/directory on a Linux server.
Login to server via SSH as root and execute following commands.

To change permission of all files and folders to 644 in /home/username/pulic_html

chmod 644 /home/username/public_html -R

To change permission of all files to 644 in /home/username/pulic_html

cd /home/username/pulic_html
find . -type f -exec chmod 644 {} \;

To change permission of all folder to 755 in /home/username/pulic_html

cd /home/username/pulic_html
find . -type d -exec chmod 755 {} \;

Our Recommended Dedicated Server

By default all MySQL database on a server is saved in /var/lib/mysql directory. If you don’t have enough space left in /var directory or if its filling up quickly, you can move your MySQL directory to /home partition.

Assuming you have enough space in /home partition, follow below steps to move MySQL to a new location in /home/var_mysql directory.

Login in server as root via SSH and run following command:

mysqldump --all-databases | gzip > /home/alldatabases.sql.gz
/etc/init.d/mysql stop
mkdir /home/var_mysql
mv /var/lib/mysql /home/var_mysql
chown -R mysql:mysql /home/var_mysql/mysql
ln -s /home/var_mysql/mysql /var/lib/mysql
/etc/init.d/mysql start

Done!!!
You should now have your MySQL at a new location /home/var_mysql

Explanation of above commands

mysqldump --all-databases | gzip > /home/alldatabases.sql.gz

This will create a full backup of all MySQL database. If anything goes wrong, you can restore all MySQL database using this backup file. Name of this file will be alldatabases.sql.gz and it will be saved in /home directory.

/etc/init.d/mysql stop

This will stop mySQL.

mkdir /home/var_mysql

This will create a new directory var_mysql in /home

mv /var/lib/mysql /home/var_mysql

This will move /var/lib/mysql to /home/var_mysql

chown -R mysql:mysql /home/var_mysql/mysql

This will give ownership of /home/var_mysql/mysql directory to user mysql.

ln -s /home/var_mysql/mysql /var/lib/mysql

This will symlinking the old /var/lib/mysql to the new location.

/etc/init.d/mysql start

This will start the MySQL.

What if anything goes wrong

We have create a full MySQL backup in our first step. If anything goes wrong, you will always have the full mysql backup to restore all database. Please refer to below tutorial to restore your databases using the full MySQL backup file.
http://www.lophost.com/tutorials/ssh/how-to-create-and-restore-mysql-backup-of-all-accounts/

Our Recommended Dedicated Server

Login to your server as root via SSH and run below command:

To start Apache

service httpd start

To stop Apache

service httpd stop

To restart Apache

service httpd restart

Our Recommended VPS Hosting

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

httpd -v

This will show you the Apache version installed on your server.
apache-version

Our Recommended VPS Hosting