-3

I am trying to find a way to add 2 domains to the VPS server I bought.

Server config: OS Ubuntu with Apache, Mysql, PHP installed.

I have 2 domains purchased from godaddy. domain-one.com and domain-two.com

I want to point both the domains to my freshly created VPS server.

I am a pure newbie in server and domains.

Khan Sharukh
  • 101
  • 2
  • 1
    Welcome to Server Fault! Good for you! But I don't see a question mark `?` in there, so do you have a question? Getting good answers requires a clear and useful question which is [well written](http://meta.serverfault.com/a/3609/37681) , [on-topic](http://serverfault.com/help/on-topic) and contains sufficient details to provide you with a good solution. – HBruijn Apr 24 '19 at 12:49

1 Answers1

1

Please refer to the following steps to add a website/domain to a VPS.

To host only one website on a server, we don’t have to create a virtual host, we can simply make sure that Apache is running and upload our files to /var/www/html and the site will be online at once. But, if you can add multiple website/domain, you have to create a virtual host for a new website.

Now, we will create a virtual host with domain name abc.com, please replace it with your actual domain name.

Create a file for the virtual host configuration with the following command:

For Ubuntu:

nano /etc/apache2/sites-available/domain1.com.conf

Please add the following lines to the configuration file.

<VirtualHost *:80>
ServerAdmin test@abc.com
ServerName www.abc.com
ServerAlias abc.com
DirectoryIndex index.php index.html
DocumentRoot /var/www/html/abc.com/public_html
LogLevel warn
ErrorLog /var/log/httpd/abc.com_error.log
CustomLog /var/log/httpd/abc.com_access.log combined
</VirtualHost>

For Ubuntu, we have to enable the virtual host first by performing this command:

a2ensite domain1.com

Restart apache

On Ubuntu:

systemctl restart apache2

Now, let’s create a file in /var/www/html/abc.com/public_html, don’t forget to replace the abc.com with your actual domain name.

mkdir -p /var/www/html/abc.com/public_html
nano /var/www/html/abc.com/public_html/home.html

Then, insert the following line to the home.html file

<html><center><h1>Welcome to abc.com</h1></center></html>

Verify the setup

Navigate the website abc.com on your web browser.

You will see a page like this

Welcome to abc.com

Regarding the name server:
If you want to point your website to your VPS, you will need to install the BIND DNS server in your VPS. Please refer to the following article it will help you to install and configure the BIND server.

http://www.servermom.org/how-to-install-and-setup-bind9-on-ubuntu-server/ http://www.yolinux.com/TUTORIALS/LinuxTutorialWebSiteConfig.html#DNS

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
Sagar Bud
  • 11
  • 2