Hi KincaiHostingns! This time, we will explain how to connect multiple domains to a VPS or what is commonly referred to as multiple hosts / multiple websites. What does it do? If you only have a domain and a VPS, then no problem! You can put each website file on the VPS, then connect the domain to the VPS. What if you have multiple websites? For example, you have 2 domains / subdomains:
domain 1: a .com
domain 2: b. net
Then you want to point the two domains to the VPS and put the website files on the VPS. Can it? Can! Please follow the guide on how to connect multiple domains to the following vps.
The ways to connect multiple domains to a VPS include:
Make sure you have set the main domain with the default nameserver. To set the nameservers, please enter the client area ( my.domainesia.com ). Then select the Domains menu then select a domain name. In the Nameservers menu, please select Use default nameservers. Note, each user can have a different nameserver!
As for how to access VPS via SSH, please follow the remote VPS method via SSH. Make sure you access SSH on the VPS using the root login, OK!
3. Enter the Website File to the VPS
Now it's time to enter the desired website files into the VPS. You must enter the websie file in the / var / www / html / folder. To make it easier, you can compress the website files into .zip first.
If you want to move files from a Linux-based computer / from Hosting to a VPS, you can use the command
scp path_direktori_folder_asal root@IP_VPS:/var/www/html/ |
If you are using Windows, please use the command at the command prompt as follows,
winscp path_direktori_folder_asal root@IP_VPS:/var/www/html/ |
4. Enabling VirtualHost on Apache
Please write
nano /etc/apache2/apache2.conf |
then search for writing
IncludeOptional sites-enabled/*.conf |
make sure there is no hashtag (#) before IncludeOptional sites-enabled / *. conf
You can add a domain to a VPS via 2 sides, namely the domain side and the web server side.
For the domain side,
please point the domain to the VPS IP via the Zone Editor menu. Please follow How to Redirect Subdomain / Domain to a Different IP . Select the domain then select A record and add the VPS IP Address.
For the web server side
Domain1.conf is the setting file for domain 1. If you want to add domain 2, then later you have to add domain2.conf.
Now, add the domain1.conf settings file first by,
nano /etc/apache2/sites-available/domain1.conf |
Then fill in the following text:
<VirtualHost *:80> DocumentRoot /var/www/html/nama_folder_website ServerName namadomainkamu ServerAlias www.namadomainkamu# enter other directives here, e.g. :Options FollowSymLinks AllowOverride All Order allow,deny allow from all</Directory>ErrorLog /var/log/apache2/namadomainkamu-error_log CustomLog /var/log/apache2/namadomainkamu-access_log common</VirtualHost> |
After that, don't forget to save!
Now, add the domain2.conf file with the following command,
nano /etc/apache2/sites-available/domain2.conf |
Then fill it with writing like the following,
<VirtualHost *:80> DocumentRoot /var/www/html/nama_folder_website ServerName namadomainkamu ServerAlias www.namadomainkamu </VirtualHost> |
Then don't forget to save!
You must activate the domain1.conf and domain2.conf files first. To activate it, please write the following command,
ln -s /etc/apache2/sites-available/domain1.conf /etc/apache2/sites-enabled/domain1.conf ln -s /etc/apache2/sites-available/domain2.conf /etc/apache2/sites-enabled/domain2.conf |
or use this command,
sudo a2ensite domain1.conf sudo a2ensite domain2.conf |
7. Manage Website File Ownership
In order for the website files entered in / var / www / html / earlier to be read by the web server, please change their ownership first. Please write the following command,
chown www-data:www-data -R /var/www/html/nama_folder_website* |
If there are 2 website folders, then do the command for each website file.
Now it's time for you to restart Apache by the way
9. Domain Can Connect with VPS
Yeay! Finally, the domain can be connected to the VPS. So, now you can add multiple website files to your VPS and then point them to their respective domains.
It is very easy to connect multiple domains to a VPS. What you need to note is that the domain must be pointing to the VPS first. Then enter the website files into the / var / www / html / folder. Only then the Apache configuration file settings. If you have any questions, please don't hesitate to ask us. The KincaiHosting Support Team will be happy to help you 🙂 Already have a domain and cheap VPS , then want to add to your Hosting collection? Quiet! You can order cheap hosting at KincaiHosting! There are various cheap hosting packages that you can choose from!