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.
- CentOS Machine with ROOT Access
- Node.js Installed on Server. Follow Guide here
- A RECORD of domain/subdomain pointing to your Server IP.
- Login to root via SSH to your server.
- Install Apache
yum install httpd -y
- Verify if Apache is installed successfully.
- Goto directory /etc/httpd/conf.d
- Create a new .conf file with any name
- Paste the below code in the conf file and make some changes then save it
ServerAlias Virtual Host for TUT Purpose
ServerAdmin [email protected]
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.
- Restart Apache Server
- Open your domain/subdomain on your web browser.