Setup Virtual Hosts with Apache on Node.js CentOS Server

Setup Virtual Hosts with Apache on Node.js CentOS Server

Do you want to host multiple Node.js Websites on the same Server with different location stored? No Problem, we have a solution for you. We will use apache to turn our server into a web server. There are small requirements for this process.

Requirements

    • CentOS Machine with ROOT Access
    • Node.js Installed on Server. Follow Guide here
    • A RECORD of domain/subdomain pointing to your Server IP.

Procedure

  1. Login to root via SSH to your server.
  2. Install Apache

    yum install httpd -y

  3. Verify if Apache is installed successfully.

    httpd -v

  4. Goto directory /etc/httpd/conf.d
     

     

    cd /etc/httpd/conf.d

  5. Create a new .conf file with any name

    nano vhost1.conf

  6. Paste the below code in the conf file and make some changes then save it

    <VirtualHost *:80>
    ServerName vhost1.legacyserver.in
    ServerAlias Virtual Host for TUT Purpose
    ServerAdmin sdeepak@basezap.com
    DocumentRoot “/home/deepak/minicricket/”
    </VirtualHost>

    ServerName – Domain/Subdomain you want to  use for virtual host
    ServerAlias – Small Note for description purpose of the virtual host used for.
    ServerAdmin –  Server Admin e-Mail Details.
    DocumentRoot – Location of your Node.js Directory Website

    Change above 4 values accordingly as per your requirements before saving conf file.

  7. Restart Apache Server

     /etc/init.d/httpd restart

     

  8. Open your domain/subdomain on your web browser.

Similar Posts