Vimzaa Knowledgebase
  • Getting Started
  • Virtual Private Servers
    • What is Virtual Private Server
    • Getting Started With Linux
      • An Introduction to the Linux Terminal
      • Basic Linux Navigation and File Management
      • An Introduction to Linux Permissions
      • An Introduction to Linux I/O Redirection
      • Linux Permissions Basics and How to Use Umask on a VPS
    • Connect with SSH
      • How to Add SSH Keys to VPS
      • SSH Essentials: Working with SSH Servers, Clients, and Keys
    • How To Edit the Sudoers File on Ubuntu and CentOS
    • Introduction to Nginx and LEMP on Ubuntu
      • Initial Server Setup with Ubuntu
      • Installing LEMP Stack on Ubuntu 14.04
      • Installing LEMP Stack on Ubuntu 16.04
    • Anti-Spam Best Practices
  • cPanel Hosting
    • Cloudflare
    • cPanel - Advanced
      • How to add and manage cron jobs / scheduled tasks in cPanel
      • How to track DNS using cPanel
      • How to create custom ‘error pages’ in cPanel
      • How to flush your local machines DNS Cache
      • How to use the Google Public DNS for faster DNS lookups
      • How to check if your domain has ‘propagated’ following DNS changes
      • Install Wildcard SSL Certificates using LetsEncrypt with cPanel
      • Correct SPF Records
      • Check processes or users with high iowait (99.99%) from Cloudlinux Logs
      • How to tune MySQL on a cPanel server with MySQLTuner
      • Clear disk space on cPanel Server by removing backups, trash etc
      • Add monitoring script to server for monitoring top, iostat etc
      • Testing your site before ‘go-live’ by editing your hosts file
    • cPanel - Domains
      • How to use the Site Publisher in cPanel
      • Managing addon domains in cPanel
      • What is the difference between addon domains and ‘alias’ domains?
      • Managing subdomains in cPanel
      • Managing domain aliases in cPanel
      • Managing domain redirects using cPanel
      • How to use the Simple Zone Editor in cPanel for managing your DNS Records
      • How to use the Zone Editor within cPanel to manage your DNS records
      • How to redirect all domain ‘alias’ to the main domain using cPanel
      • How to enable Cloudflare on your cPanel account
      • How to check what nameservers a domain is using
      • How to create Custom Nameservers / Vanity Nameservers
      • How do I transfer a domain name to Vimzaa?
    • cPanel - Managing Databases
      • Managing a MySQL Database in cPanel with phpMyAdmin
      • Manage MySQL Database in cPanel
      • Simplified database creation with the cPanel MySQL Wizard
      • Managing MySQL databases remotely using ‘Remote MySQL’ in cPanel
    • cPanel - Managing Email Accounts
      • Managing email accounts with cPanel
      • How to create and manage email forwarders using cPanel
      • Managing email routing with cPanel
      • Change Your E-Mail Account Password
      • Improving mail deliverability (SPF & DKIM)
    • cPanel - Managing Files
    • cPanel - Metrics
    • cPanel - Software and Applications
    • cPanel - Security
    • SiteBuilder Pro
    • Enable or disable PHP modules
    • How can I migrate my cPanels to Vimzaa Website Hosting?
    • SSH Access to cPanel Servers
    • How do I add another domain to my Hosting Account?
    • How do I access WHM (Web Host Manager)?
  • Plesk Hosting
    • An Introduction to Plesk
    • Getting Started with Plesk
      • How to login to Plesk for the first time
      • The Plesk User Interface Explained
      • Understanding Subscriptions in Plesk
      • How to upload content with Plesk
      • How to manage mailboxes / mail accounts with Plesk
      • Managing Web ApplicationsManaging Web Applications
    • Plesk Tutorials
      • A basic getting started guide to creating your first site with Plesk
      • How to manage DNS and nameservers using Plesk
    • Plesk Funtionality - Explained
      • Managing your User Account in Plesk
      • Managing your Web Hosting with Plesk
  • Game Servers
    • Setup Teamspeak 3 Server on Linux
    • Installing SteamCMD for Steam Game Servers
  • SSL Certificates
  • Domains
    • Can I register or transfer my domain to Vimzaa
    • Can I buy a domain name together with a web hosting plan
    • Default nameservers for shared webhosting
Powered by GitBook
On this page
  • The cPanel (Linux) Temporary URL:
  • How To Change your Computer’s Hosts File:
  1. cPanel Hosting
  2. cPanel - Advanced

Testing your site before ‘go-live’ by editing your hosts file

We all know the importance of testing your site after a migration to your hosting account. More often than not we wish to do this prior to updating the domain’s DNS nameservers to Brixly. We have a few options that allow us to do this – via the control panel, as well as by modifying your local PC’s hosts file.

The cPanel (Linux) Temporary URL:

Every cPanel user’s main domain is accessible via the IP address of the server and their username. For example:

<a href="http://1.1.1.1/~username">http://1.1.1.1/~username</a>

(You will need to replace the “IP Address” with the actual IP Address of the server, as well as “username” with your cPanel user to utilize this).

The following addresses will bring you to the contents of your main public_html folder, you can append subfolders to the URLs for further testing if needed, for example:

<a href="http://1.1.1.1/~username/subfolder/anotherfolder/yetanotherfolder/">http://1.1.1.1/~username/subfolder/anotherfolder/yetanotherfolder/</a>

How To Change your Computer’s Hosts File:

Temporary URLs work well in most cases, but in other cases some content management systems rely heavily on DNS and redirections in order to function properly, making testing via temporary URLs difficult as clicking links will take you to the domain name again, itself. In cases like this – we update the hosts file for testing on your local PC.

One thing to keep in mind, regardless of which operating system you use at home, you can simply add your host information to the bottom of the file – in the following format:

X.X.X.X   domain.com
X.X.X.X   www.domain.com

X.X.X.X will be the IP address we are going to force your computer (and only your computer) to resolve the domain to. This will be the IP address assigned to the domain name. Domain.com will be the domain name to test prior to updating the DNS.

Another thing to keep in mind when testing your site using the hosts file method- after updating your hosts file, you will need to clear the cache and cookies from your web browser and restart the browser in order for things to take full effect. In some instances, you may need to flush your DNS cache on the local system as well.

Updating a Hosts File on Windows:

Go to Start -> All Programs -> Accessories

Right click on Notepad, and select “Run as Administrator”

Click “Continue” at the UAC prompt.

In the notepad application – From the toolbar, go to File -> Open

Open the Following File:

C:\Windows\System32\drivers\etc\hosts

(This path may vary based on your drive/installation configuration, and you may need to choose the file type to open from the drop down menu as “All Files” in order to see your hosts file).

Add your new host entry to the bottom of the file and save.

figure 2. A Windows 7 hosts file with an example entry added so that mydomain.com resolves to the IP of 1.2.3.4

Updating a Hosts File in Linux:

Open up your favourite terminal application (Most flavours store the default terminal application in the Accessories folder). Also, in this example, we are using the text editor called “nano” which is pre-installed on most Linux distributions. You may also use other text editors such as vim or emacs if you wish.

If you are already logged in as user root, run:

nano /etc/hosts

If you are logged in as a non-root user, run:

sudo  nano /etc/hosts

Then authenticate with your password to grant root access.

Once the text editor application opens, add your new host entry to the bottom of the file and save.

Updating a Hosts File on a Mac:

You will need to launch your Terminal, which you can search for using Spotlight, or you may also access this via Applications/Utilities

Once the terminal application has launched, type the following into the terminal command line:

sudo nano /private/etc/hosts

Enter the Administrator password.

After the file has opened, add your new host entry to the bottom of the file and save.

Again, make sure you clear the cache from your browser and in some cases the DNS cache may need to be flushed as well.

After you update the DNS for your site, make sure to remove any host entries that you may have added during the process to ensure the domain is resolving in the same manner on your local system as other users on the internet!

PreviousAdd monitoring script to server for monitoring top, iostat etcNextcPanel - Domains

Last updated 6 years ago

change_hosts_file