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
- Login to root via SSH to your server.
- Install Apache
yum install httpd -y
- Verify if Apache is installed successfully.
httpd -v
- Goto directory /etc/httpd/conf.d
cd /etc/httpd/conf.d
- Create a new .conf file with any name
nano vhost1.conf
- 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 WebsiteChange above 4 values accordingly as per your requirements before saving conf file.
- Restart Apache Server
/etc/init.d/httpd restart
- Open your domain/subdomain on your web browser.