Archive

How to change TimeZone On Linux server

The Time zone shows the standard time for a specific area or geographic region. How to change timezone on linux server is always a big question? The time zone is set when we install any operating system on our device or on our server. Timezone settings are one of the most important things to cover during installation because it impacts our system functionalities. There are many ways to change timezone on Linux server but the most used and easy way is to set using the command line.

In this article, we will discuss how to set or change timezone on a Linux server using the command line.

Table of Contents:

  1. How to Check the Current Time Zone
  2. Set/Change Timezone on Linux server Using Command line
  3. Confirm time zone change
  4. Importance of Time zone
  5. Things to remember

1. How to check Current Time Zone:

Before changing the time zone it is important to check the current time zone of your system. Linux system makes it easy to check the current time zone of your system by using the command “timedatectl“. It is available on all modern systemd-based Linux system.

To view the time zone follow the steps:

Open your Linux terminal and run timedatectl command on it

$ timedatectl
image 1

The output of the command shows the current timezone of the system. Now you can go for changes if you want to change the current time zone of your system.

Note: this step is not must for changing time zone you can do it after change this is just a good way. So if you have already your required time zone then there is no need to change.

2. Set/Change Timezone on Linux Server Using Command line

Once you check your current time zone and want to change. First you will need to find the specific name of the time zone you want to use. the specific name is like “Region/city“.

To List, the available time zone use timedatectl list-timezone command

$ timedatectl list-timezones
image 2

Now check the required time zone in the list and run the next command which is “sudo timedatectl set-timezone “you time zone” ” the last argument is the your specific time zone you want to set for your system.

sudo ” is used to run administrator rights or root user.

$ sudo timedatectl set-timezone <your specific time zone>

image 3

After running this command confirm time zone by running:

$ timedatectl
Change Timezone on Linux server

You can see the required time zone here after changing.

3. Importance of time zone

The time zone is very important for your system as many functionalities depends upon the time zone.

Every geographic part has its own specific time zone. Many things depend upon that like:

  • Access for system may be Bound to specific Time zone or Region.
  • If some record need to store in system it need that specific time zone.
  • In case of online server its important to set specific time zone its import from security point of view.

4. Things to remember

In the case of Linux server and database of site attached with that server. There are some issues which we suggest you to remember and check.

After changing time zone of your system you need to check your database if it is storing time and date.

If your database is storing old or wrong time and date. Then reboot your system it will fix your issue.

Reboot restart all services of your system and new time zone is ready to store in database.

Read More: HOW TO TRANSFER A WEBSITE FROM CPANEL TO CYBERPANEL MANUALLY

Follow US on Facebook / Twitter   for update.

How to set custom/extra headers for OpenLiteSpeed while using CyberPanel

Custom/Extra Header can be used for many proposes like:

  1. Content Security policy
  2. Referrer policy
  3. HSTS (Strict-Transport-Security)
  4. Content-type options

If you are using the LiteSpeed Enterprise server you can add Extra headers to your htaccess file and the server will add it automatically just like you used to do with Apache as it is fully Apache Compatible.

However, if you are using OpenLiteSpeed it has to be done via OpenLiteSpeed WebAdmin or by adding it to vHost configuration for the website via CyberPanel.


Table of Contents

  1. Log in to CyberPanel
  2. Open the website Manager
  3. vHost Configuration
  4. Verify Headers.

Here are the steps to add a custom or extra header via vHost configuration from CyberPanel.


1. Log in to your CyberPanel Server

Visit https://<IP Address->:8090

Enter credentials to log in.


2. Open the website manager:

     2.1 Click on the website and then click on the list websites.

Click on website and then click on list websites

      2.2 Click on the manage button in front of your desired website.

Click on mange button in front of your desired website.


3. vHost Configuration :

   

      3.1 Click the vHost conf from the website manager.

Click the vHost conf from the configurations portion in website manager.

      3.2 Find the block name “context” if it is found add extraHeaders value in it like “extraHeaders Access-Control-Allow-Origin *”.

      3.3 If “context ” block not found in vhost conf file Add the following before the rewrite { } portion.

context / {

extraHeaders Access-Control-Allow-Origin *

}

extraHeader

You can add the value of extraHeaders according to your requirement. 


4. How to verify extraHeaders configuration:

To verify extraHeaders configuration follow the steps:

    4.1 Open Network tab:

        1. Vist your website in any browser and open developer tools.

        2. In developer tools click on Networks tab

Open network tab

         3. Click on the file with your domain name. like(abc.xyz)

Screenshot 9

         4. Go to Network Tab and check headers for any request. You should the extra header you added in vHost conf.

Verify vhost configuration


How to set HSTS (Strict-Transport-Security) in custom the header:

HSTS is a web security policy mechanism that helps to protect websites against man-in-the-middle attacks such as protocol downgrade attacks and cookie hijacking.

To set HSTS in custom Header follow the steps:

             => Follow the 1,2 and 3 steps stated above to open the vHost conf file.

             => Add the following before the rewrite { } portion.

context / {

extraHeaders Strict-Transport-Security: max-age=15552000; includeSubDomains; preload;

}

 1. The age parameter tells the browser how long this rule must be cached.
 2. The includeSubDomains should only be added if you want to apply HSTS to subdomains too.
 3. The preload parameter is used for inclusion in Google Chrome’s preload list.

Read More: HOW TO CHANGE TIMEZONE ON LINUX SERVER

Follow US on Facebook / Twitter  for update.