Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Install Domain Access

Video loading...

  • 0:01
    Install Domain Access with Addison Berry
  • 0:04
    In this lesson, we're going to get hands on with the domain access module
  • 0:08
    by actually get it installed and getting a Drupal site up and running
  • 0:12
    so that we can then dive into more configuration.
  • 0:15
    We're going to start off by looking at the documentation
  • 0:19
    so you can—there's actually copious amounts of documentation,
  • 0:22
    so I'll point out exactly what we'll be following to do this installation in this tutorial.
  • 0:27
    Then we will go ahead and get Domain Access set up,
  • 0:31
    and that's also going to involve configuring our settings.php file.
  • 0:36
    There's a special include that you need to have.
  • 0:38
    So while domain access is a normal Drupal module,
  • 0:41
    there are some additional steps that are required for you to do
  • 0:45
    in order to make sure it gets installed properly.
  • 0:47
    Once we have all of the things in place and we get it installed,
  • 0:50
    then we're going to go ahead and test and just make sure that the installation did actually complete correctly.
  • 0:55
    So let's dive in.
  • 0:57
    So I'm going to start off on
  • 1:03
    which is the Domain Access project page.
  • 1:06
    So this is both where you can get the download for the module
  • 1:10
    and also find documentation.
  • 1:12
    So if you scroll down to the bottom,
  • 1:14
    you get the downloads, and we're going to be using version 7.
  • 1:17
    So you can download that or you can use Drush to download it into your Drupal site
  • 1:22
    that you have installed now.
  • 1:24
    And if we come back up and you look at the resources in the sidebar here,
  • 1:28
    we can find the documentation, so let's go ahead and look at that.
  • 1:32
    And you'll notice when you get to the Domain Access documentation,
  • 1:35
    if you scroll down, there's a large subsection here.
  • 1:38
    There's a lot of different things under this section.
  • 1:41
    You can also see this in the sidebar.
  • 1:43
    So there's a whole bunch of documentation that's in here.
  • 1:46
    We're going to focus just on installation right now obviously.
  • 1:50
    So I'm going into Installation,
  • 1:52
    and you can see again there's a lot more stuff before installing.
  • 1:55
    So one of the things that we're going to want to do is check to make sure our domains are actually pointing correctly.
  • 2:00
    So we'll check all of the domains real quick.
  • 2:02
    And then we are going to need to configure the settings.php file
  • 2:07
    and then go ahead and run the installation.
  • 2:09
    So if I go into Configuring settings.php,
  • 2:12
    there are some notes about some things to be careful of.
  • 2:15
    We're not going to change the default things.
  • 2:17
    So it's fine to sort of skip over these things that you may or may not need to look at.
  • 2:23
    But what I want to come down to here is this Add section.
  • 2:27
    This is the important part that's going to make this module work for you.
  • 2:32
    So you'll see that you have two options for doing this.
  • 2:36
    So what's happening is there's actually an include file,
  • 2:39, in the Domain Access module code.
  • 2:42
    And Domain Access needs your settings.php file to know about that
  • 2:47
    and be able to execute that code in order for it to work properly
  • 2:51
    and read your domains and do what it needs to do.
  • 2:54
    So this is the first step we're going to have to do
  • 2:57
    before we actually run the installation of the module
  • 3:00
    which then would just be a normal module installation.
  • 3:03
    So you can see that we are going to want to
  • 3:06
    add a line to our settings.php file.
  • 3:10
    And simply we can copy and paste this.
  • 3:12
    You just need to know where this file is here, this one.
  • 3:17
    It's in the domain module folder that we downloaded.
  • 3:21
    There are other options for how you can do this if you want to include it,
  • 3:26
    but this preferred method is preferred and is the one that we're going to be using in this particular tutorial.
  • 3:33
    So here's the documentation, and obviously you can read a lot more around what's going on here.
  • 3:39
    Before we go in and mess around with the settings file though,
  • 3:41
    let's just verify that the URLs, the actual domain names,
  • 3:46
    are all pointing to the correct Drupal directory first.
  • 3:50
    So if we come over and look at the University of Drupal site that I've installed,
  • 3:55
    this is at the URL.
  • 4:01
    And I'm logged in, so you can see I'm already logged in to this one.
  • 4:05
    Now if I switch over to news.udrupal,
  • 4:07
    you can see that I'm not logged in.
  • 4:10
    So this is another site. This is the other URL.
  • 4:12
    But it is pointing to the same installation because I have that same title on the Drupal site,
  • 4:16
    so it is pointing to the right place.
  • 4:18
    And then we also have
  • 4:21
    So all three of the URLs are pointing to the site that I've just installed.
  • 4:25
    I'm logged in on the original domain name that I created the site with which was udrupal.
  • 4:31
    So we definitely have the domain names working.
  • 4:34
    Everything's pointing properly.
  • 4:36
    And so now it's all up to the Drupal site to figure out what to do with those domain names when they hit,
  • 4:41
    and that's what Domain Access is going to do for us.
  • 4:44
    So I'm going to go ahead and open up the file system here,
  • 4:48
    so we can take a look at my Drupal installation.
  • 4:51
    This is just the Drupal root you would normally see,
  • 4:53
    and now we're going to go into sites.
  • 4:56
    There are two things that I would like to do here.
  • 4:58
    One is I just want to verify that I do have Domain Access.
  • 5:00
    So I did get the download, and that's there and ready to install.
  • 5:04
    And then the other thing is I'm going to want to go into my default folder
  • 5:08
    where my site database settings are and such like that.
  • 5:11
    And I'm going to make this change that I need to do to the settings.php file.
  • 5:17
    So let's go ahead and open up settings.php
  • 5:19
    and we're going to just go all the way down to the bottom.
  • 5:22
    We're getting all this stuff, we're going to add some stuff to the bottom of this file.
  • 5:26
    I'm going to go back to that documentation, and I'm going to copy/paste the line that I need.
  • 5:32
    So we need to include and then we're going to use a global variable that defines what the Drupal root is
  • 5:38
    because Drupal knows where its root directory is.
  • 5:41
    And then we need to put the path to the actual file that's in that domain folder that we just looked at.
  • 5:48
    And you can see in the second example, this has the standard typical location for that file
  • 5:53
    which is exactly what we have on our site.
  • 5:55
    We're not doing anything funny with the location of our modules folder.
  • 5:59
    So we can actually just copy and paste this entire bit right here,
  • 6:03
    and this is going to work on our site.
  • 6:06
    So I'm going to copy that and then go back to my settings.php file
  • 6:11
    and down here at the bottom, we're just going to add some lines that we just copied here.
  • 6:17
    Adds a little space at the bottom so we can see this.
  • 6:20
    So I added the comment—create some space for that.
  • 6:23
    It's a good idea to comment it.
  • 6:25
    Even if you don't copy this one, make sure you make a note of what this thing is here and why.
  • 6:29
    And then it's just including— again, it's jumping down the path from the Drupal root
  • 6:34
    to the file which is included in that domain module folder that we've already downloaded.
  • 6:39
    So that's all I need to do to change that.
  • 6:41
    So let's save it.
  • 6:44
    And with that saved, now we should be able to go through the installation process
  • 6:49
    and have everything work the way it's supposed to be.
  • 6:51
    So I'm just going to go to the module configuration page.
  • 6:55
    Now one thing I do want to note is if you end up using Drush to do this installation,
  • 7:01
    there are actually some specific instructions that you should use.
  • 7:05
    So if you go back to the documentation real quick,
  • 7:08
    if you go to actually installing the module,
  • 7:10
    you'll see that there's some Drush instructions.
  • 7:13
    You need to add the domain URI so that it knows what the default domain is going to be
  • 7:18
    for the installation of the module.
  • 7:20
    So just keep this in mind if you're using Drush, to read the instructions
  • 7:23
    for how to do that and add this additional flag in there.
  • 7:27
    I'm just going to do it through the UI though.
  • 7:29
    So we'll keep it simple.
  • 7:31
    So here, Module administration, we have Domain Access.
  • 7:34
    Again, here are all of the modules that come with that package when we downloaded it.
  • 7:39
    But all we need is the main Domain Access module.
  • 7:43
    We don't need these additional ones right now.
  • 7:46
    So we're just going to do the main Domain Access module and save it.
  • 7:51
    Now you'll notice when this done that it's giving me a little bit of warning here
  • 7:55
    that says content access permissions need to be rebuilt,
  • 7:58
    and it gives me a handy link to be able to go do that.
  • 8:01
    This is not an uncommon thing
  • 8:03
    when you are dealing with node access modules, contributed modules,
  • 8:08
    and it's a way for it to just sort of clean things up and make sure it has a clean slate
  • 8:12
    as it begins to change how the access system works on your site.
  • 8:15
    So we can click on this link to go rebuild permissions.
  • 8:19
    You'll notice it's taking me to reports.
  • 8:22
    So the way to find this if I didn't click that link directly
  • 8:26
    is if we go to Reports and go to Status Report,
  • 8:30
    if you scroll down, you'll see for node access permissions,
  • 8:33
    we have a new entry in the status report.
  • 8:35
    And that is giving us the rebuild permissions link here.
  • 8:39
    And then I can go ahead and rebuild it from here.
  • 8:41
    So let's go ahead and do that real quick. Done.
  • 8:45
    So now we have the module enabled,
  • 8:48
    we've rebuilt our permissions.
  • 8:50
    We did put the include file in there,
  • 8:52
    so let's go see and make sure it actually worked properly.
  • 8:55
    So let's go look at the administration for domain access.
  • 8:59
    So if we go up into the Structure section,
  • 9:01
    you'll notice we have a new section here called Domains
  • 9:04
    which is where we're going to manage this stuff.
  • 9:06
    And you can see it is actually working.
  • 9:08
    We have things installed properly.
  • 9:10
    This default site that we installed it from
  • 9:13
    is the default domain right now and it's the only one listed
  • 9:16
    because we haven't configured anything else yet.
  • 9:19
    So we have the University of Drupal. It's showing me the domain here.
  • 9:22
    I'm using a dev version, but it's the same domain name.
  • 9:25
    Udrupal is our main domain name,
  • 9:28
    and we can see that it's active and it is set to the default obviously because it's the only one.
  • 9:34
    But we now have Domain Access installed.
  • 9:38
    So in this tutorial, we got Domain Access module installed properly.
  • 9:42
    There's a little bit more that was involved in the process than just a regular module installation
  • 9:46
    because A, first we had to make sure the domains were functioning correctly through Apache.
  • 9:52
    So first we tested the domains, made sure all three of our domains were pointing to the Drupal installation that we set up,
  • 9:58
    so that was good.
  • 10:00
    And then before we actually did the installation of the module itself,
  • 10:04
    we had to add the Domain Access include file to our settings.php
  • 10:08
    because that's a critical piece that Domain Access has to have
  • 10:13
    in the settings file in order for it to get things properly aligned with domain names.
  • 10:19
    Once we had those things in place,
  • 10:22
    then of course the installation itself was actually just a normal installation of a Drupal module.
  • 10:27
    We enabled it.
  • 10:29
    And then we were prompted to rebuild the permissions
  • 10:32
    because this is a node access module
  • 10:34
    and that's a very typical step we would need to take.
  • 10:37
    So we went ahead and rebuilt the permissions,
  • 10:39
    cleaned all that stuff up,
  • 10:41
    and then we just went and looked at the Domain Access configuration page
  • 10:44
    to verify that it was actually working properly.
  • 10:48
    And we got to see the beginning of our domain list
  • 10:51
    and where we're going to be able to configure our Domain Access domains.

Install Domain Access


In this tutorial we will get hands-on with Domain Access by getting the module installed. This is a more involved process than a regular module installation, but we just need to make sure we have a few things in place first. We're going to need to make sure we have our domains functioning correctly through Apache, and then add the Domain Access include file to our settings.php. With the configuration and module in place, we'll also verify that it is working properly and take a look at our domain list.

After watching this tutorial you will be able to properly install the Domain Access module, with its additional steps, and then verify that the installation was correct.

Log in or sign up to download companion files.
Additional resources: