cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
estieg
Former Employee

How To Setup Multiple 3rd Party Domains To One VPS Account - Tutorial

Antonyw1969 wrote,

“While I'm waiting for my primary domain to transfer in I'm trying to do my homework on setting up 3 new clients website who will all keep their domains registered with their current provider but I will host their websites. Question: A(Host) record IP update, understood but how does my VPS know which folder to send each domain to?.. example: someone types www.example.com into their browser and they find their way to my IP address but then how will they find their way to the correct folder?”

 

Oslinux replied,

“Once the domain has been pointed to your VPS's server you will need to configure your web server for the domain. Since the most common web server is Apache I will post a sample config:

<VirtualHost oslinux:80>
   ServerName oslinux.xyz
   ServerAlias www.oslinux.xyz
   ServerAdmin myemail@mydomain.net
   DocumentRoot /var/www/html/oslinux.xyz/  

  <Directory "/home/oslinux/public_html">

     Options Indexes FollowSymLinks

     AllowOverride ALL

     Require all granted

  </Directory>
  

  DirectoryIndex index.html
   ErrorLog logs/error.log
   CustomLog logs/access.log combined
</VirtualHost>

In the config above replace oslinux.xyz with the domain you want to serve.

Server Alias is not needed and used if you want several subdomains/domains pointing to the same location like adding www to your domain.  

Server Admin should be your email address

DocumentRoot should point to the folder for the domain (Apache's default location is /var/www/html Recommended to create a folder with the same name as the domain to make managing it easier. You can use other locations for the folders but make sure your Apache user has read access to the location. If you are using a different folder than the default you will need to include the

<Directory "/home/oslinux/public_html"> </Directory> section only needs to be added in you are using a different directory, replace /home/oslinux/public_html with the location for the domain.

I would recommend you create separate configs for each domain and name the file to match the domain and add .conf to the end oslinux.xyz.conf

The default location for Apache config files is

Fedora based Distros "/etc/httpd/conf.d"

Debian based Distros "/etc/apache2/sites-available"

Here are some guides for creating virtual hosts.

Debian Based:

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-...

Fedora Based:

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7

Apache docs on virtual hosts.

https://httpd.apache.org/docs/2.4/vhosts/examples.html

If I answered your question, please mark it as the solution or give it a "Kudo"