1B. Django 1.8 Server Build - CentOS 7 hosted on VPS (multi-domain hosting setup)
This is a complementary material to the previous article: 1. Setup CentOS 7 hosted on VPS
In this tutorial, we'll add another domain (einsteinish.com) to the same server with ip 45.79.90.218 where we're already hosting sfvue.com.
The process of adding additional domain is not much different from the one adding an initial domain.
Let's see current status of our server environment.
Select "Remote Access" from the top menu:
We've already setup ssh in our previous tutorial.
See Setting Domain Names to Use Linode's Name Servers.
After we purchase a domain, the next step is setting our domain registrar to use our name servers. Use our domain name registrar's interface to set the name servers for our domain name to the following entries:
ns1.linode.com ns2.linode.com ns3.linode.com ns4.linode.com ns5.linode.com
We can find the list of name servers in the next section when we try to add a new domain zone.
Before we can add any DNS records, we must create a domain zone â a container for DNS records associated with a single domain name. The Linode Manager allows us to add new domain zones, import domain zones from other DNS servers, clone existing zones that we've already created in the DNS Manager, check to make sure that a zone is correctly loaded, view the raw output of a zone file, and permanently remove a zone and all associated DNS records.
If we have just purchased a new domain name, the first step is to add a new domain zone in the DNS Manager. This creates a container for the DNS records for our domain name. If we don't know what DNS records to add, the DNS Manager can insert some basic records when we create the new domain zone.
We've already setup a zone for sfvue.com:
By clicking the sfvue.com, we can see how our existing setup looks like:
Now, it's time to add a zone for our second domain, einsteinish.com.
From the DNS Manager tab, select the Add a domain zone link.
Enter the domain name in the Domain field, and also enter an administer's email address in the SOA Email field.
Click Add a Master Zone. Then, the following page appears with our domain zone information, and it's virtually identical to the sfvue.com's zone info we saw earlier:
Under normal circumstances, there's no reason to suspect any problem with our domain zones or DNS records, but sometimes things go wrong. We can use the Check zone feature to verify that our domain zone is working correctly.
In order to check the status of our domain zone, from within the DNS Manager, click the Zone file option to the far right of our chosen domain zone.
A webpage with the results of the einsteinish.com domain zone check will then appear:
Our first domain zone for sfvue.com stays good as well:
If we see a message stating that our zone looks good, everything is working correctly; otherwise, check if all of the DNS records in our domain zone are properly configured.
The DNS Manager allows us to view the contents of a domain zone file. This is especially useful should we need to import the zone to a different server, or if we wish to inspect the file.
We can view the contents of the domain zone file through the DNS Manager tab of our Linode Manager. From there, select the Zone file link to the far right column of our chosen domain's name.
To see the zone file for our new einsteinish.com domain, click the Check option to the far right of our chosen domain zone:
Once we've created a domain zone, we can start filling it with DNS records. DNS records are the link between our domain and our virtual private server. We'll see how to add, edit, and remove DNS records.
Should we remove our Linode(s), we will no longer be able to use Linode's DNS Manager to host our domain zones.
Our new domain einsteinish.com is registered via GoDaddy.
Here are the steps:
- Log in to the GoDaddy.com Account Manager.
- Select Manage Domains from the Domain Names drop-down menu or the Manage Your Account list.
- Select the domain name (einsteinish.com) we wish to modify using the checkboxes and then click Set Name Servers.
- Enter our updated name server information in the spaces provided under the Name Servers heading.
Click "Enter custom nameservers":
and click OK.
Save Changes at the bottom. -
We need to setup DNS Zone file: pointing to Linode. Here is the initial screen shot:
Select "Edit" icon on the right, then put the domain name and ip-address of target host (in our case, it'll be hosted on Linode server with ip 45.79.90.218).
Click "Finish". Here is our updated Zone file info:
If we've just made a DNS change and aren't seeing it reflected yet, try waiting 48 hours. DNS updates will take effect, or propagate, within the time period set by our zone file's TTL. In some cases the new information may not be reflected for up to 48 hours.
While we can't control DNS caching at every point on the internet, we do have control over our web browser. Try holding down the Shift key or the Control key (depending on browser) while we refresh the page to bypass our browser's cache of the old DNS data. We can also try bringing up our site in an alternate browser, or Previewing Our Website Without DNS.
In this sample, we have two domains sfvue.com and einsteinish.com which are using Django framework.
References are:
- 1. Setup CentOS 7 hosted on VPS
- 1B. Setup CentOS 7 hosted on VPS (multi-domain hosting setup) - Name server and Zone File settings (from GoDaddy to Linode)
- A sample production app (sfvue.com) with virtualenv and Apache
In this section, we'll only deal with Apache configuration for name-based multiple domain server.
The configurations are available in /etc/httpd/sites-available folder:
$ ls /etc/httpd/sites-available einsteinish.com.conf sfvue.com.conf
Also, we have aliases for the two domain in /etc/httpd/sites-enabled folder:
$ sudo ln -s /etc/httpd/sites-available/sfvue.com.conf /etc/httpd/sites-enabled/sfvue.com.conf $ sudo ln -s /etc/httpd/sites-available/einsteinish.com.conf /etc/httpd/sites-enabled/einsteinish.com.conf $ ls -la /etc/httpd/sites-enabled total 8 drwxr-xr-x 2 root root 4096 Jan 4 13:34 . drwxr-xr-x 8 root root 4096 Dec 17 20:31 .. lrwxrwxrwx 1 root root 47 Jan 4 13:34 einsteinish.com.conf -> /etc/httpd/sites-available/einsteinish.com.conf lrwxrwxrwx 1 root root 41 Jan 3 17:59 sfvue.com.conf -> /etc/httpd/sites-available/sfvue.com.conf
Note that in /etc/httpd/conf/httpd.conf file, we need to add the following line to tell Apache where it can find configuration:
IncludeOptional sites-enabled/*.conf
The configurations files look like this.
/etc/httpd/sites-available/sfvue.com.conf:
<VirtualHost *:80> ServerAdmin webmaster@sfvue.com ServerName sfvue.com ErrorLog /var/www/sfvue.com/logs/error.log CustomLog /var/www/sfvue.com/logs/access.log combined WSGIDaemonProcess sfvue3 python-path=/var/www/django/sfvue3:/var/www/django/sfvue3/venv/lib/python2.7/site-packages WSGIProcessGroup sfvue3 WSGIScriptAlias / /var/www/django/sfvue3/sfvue/wsgi.py Alias /static/ /var/www/django/sfvue3/static/ </VirtualHost> <Directory /> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> WSGIPythonPath /var/www/django/sfvue3/ <Directory "/var/www/django/sfvue3/sfvue"> <Files wsgi.py> Require all granted </Files> </Directory>
/etc/httpd/sites-available/einsteinish.com.conf:
<VirtualHost *:80> ServerAdmin webmaster@einsteinish.com ServerName einsteinish.com ErrorLog /var/www/einsteinish.com/logs/error.log CustomLog /var/www/einsteinish.com/logs/access.log combined WSGIDaemonProcess einsteinish3 python-path=/var/www/django/einsteinish3:/var/www/django/einsteinish3/venv/lib/python2.7/site-packages WSGIProcessGroup einsteinish3 WSGIScriptAlias / /var/www/django/einsteinish3/einsteinish/wsgi.py Alias /static/ /var/www/django/einsteinish3/static/ </VirtualHost> <Directory /> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> WSGIPythonPath /var/www/django/einsteinish3/ <Directory "/var/www/django/einsteinish3/einsteinish"> <Files wsgi.py> Require all granted </Files> </Directory>
Continued to 2. Django 1.8 Server Build - CentOS 7 hosted on Linode : ssh login and firewall
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization