Craft CMS Multi-Site with Craft Nitro

Supporting a Craft multi-site installation with Craft Nitro requires using the `nitro alias` command.

Sup­port­ing a Craft mul­ti-site instal­la­tion with Craft Nitro relies sole­ly on the nitro alias command. 

The nitro alias com­mand allows you to choose an exist­ing site in your Nitro envi­ron­ment and then add a domain alias for it so any requests to that alias domain will be rout­ed to the main Craft installation. 

Craft mul­ti-site is a sin­gle Craft instal­la­tion and a sin­gle index.php in the web root that han­dles the request and boot­straps the application. 

Let’s set up a mul­ti-site instal­la­tion using the learnnitro project we cre­at­ed at the begin­ning of the course.

  1. Log in to the Con­trol Pan­el at learnnitro.nitro/admin
  2. Sites -> New Site
  3. Cre­ate new site called Learn Dock­er”, https://learndocker.nitro (we’ll just hard code the URL into the set­tings field for now).
  4. Let’s copy the site han­dle so we can cre­ate a tem­plate fold­er for this site.
  5. In the templates direc­to­ry, cre­ate a direc­to­ry for learnDocker and one for default (the first/​primary created).
  6. Let’s cre­ate a sim­ple index tem­plate in each project. And place {{siteName}} at the top.

And now we can set up the alias in Nitro so an addi­tion­al domain points at the Dock­er con­tain­er for this project. Since we defined the Base URL in the Site Set­tings, Craft will route any requests via that Base URL to the cor­rect site.

		In the root of the main project:
➜ nitro alias

Enter the alias domain for learndocker.nitro with­out the protocol.


Hit enter and then con­firm that you want to apply the changes. This updates Nitro so it can han­dle requests using that domain.

This is going to update our hosts file, so we’ll like­ly need to enter our password.

Now let’s try it out by vis­it­ing both domains!

Let’s update the learndocker.nitro index tem­plate just to con­firm that we’re point­ing at the right place.

And, we are!

Here are all of the videos in Local Development with Craft Nitro:

1What is Craft Nitro?Craft Nitro is a Docker-based local hosting solution by Pixel & Tonic, the developers of Craft. It is designed as an officially-supported way to handle local development of Craft CMS website builds, as well as when working on plugin development. 04:08
2Is Craft Nitro Right for Me?Five checks to see if Craft Nitro is the local development environment for you. 02:33
3How to Install Craft NitroInstalling Craft Nitro on macOS requires Docker, so that means you need to first have Docker Desktop for Mac installed and working. 09:20
4Creating Your First Site with NitroNow that we have Nitro installed, we are ready to create our first Craft hosted with Nitro. 09:49
5Setting Up A Boilerplate Project with Craft NitroIf you have a boilerplate project that you work with when starting new projects, it’s simple to use that to create a new Nitro project via the `nitro create` command. 04:35
6Migrating an Existing Project to Craft NitroMigrating an existing project to Nitro is probably going to be the most common scenario you run into, assuming you move all of your projects over instead of just using Nitro for new projects. 05:04
7Running Craft Commands Against a Craft Nitro SiteIt's best to run all `craft` commands through the `nitro` command. 02:15
8Craft CMS Multi-Site with Craft NitroSupporting a Craft multi-site installation with Craft Nitro requires using the `nitro alias` command. 04:33
9How to Recall Which Nitro Sites Are RunningI like to be able to get a quick peak and reminds myself of what’s what and if I’ve even set up a project in Nitro yet. 02:58
10Removing a Site from Craft NitroHere is how to remove a site from Craft Nitro. 03:05
11Testing Email Sending in Craft NitroIn addition to the core functionality of local hosting, Craft Nitro also has ancillary services that fill out the total experience of running a Craft site. 05:28
12Updating Craft NitroNitro is an actively maintained project by Pixel & Tonic. You’ll get the best experience with Nitro if you regularly update to get the latest features and improvements. 01:37
13Uninstalling Craft NitroIf you decide that Nitro isn’t for you or you need to troubleshoot an issue by uninstalling Nitro, then this is how to do it. 02:47
Course In-ProgressThis course is still being updated with new content. Check back for more!

Loading next video...