Local Development with Craft Nitro
Supporting a Craft multi-site installation with Craft Nitro requires using the `nitro alias` command.
Supporting a Craft multi-site installation with Craft Nitro relies solely on the nitro alias
command.
The nitro alias
command allows you to choose an existing site in your Nitro environment and then add a domain alias for it so any requests to that alias domain will be routed to the main Craft installation.
Craft multi-site is a single Craft installation and a single index.php
in the web root that handles the request and bootstraps the application.
Let’s set up a multi-site installation using the learnnitro
project we created at the beginning of the course.
templates
directory, create a directory for learnDocker
and one for default
(the first/primary created).{{siteName}}
at the top.And now we can set up the alias in Nitro so an additional domain points at the Docker container for this project. Since we defined the Base URL in the Site Settings, Craft will route any requests via that Base URL to the correct site.
In the root of the main project:
➜ nitro alias
Enter the alias domain for learndocker.nitro
without the protocol.
learndocker.nitro
Hit enter and then confirm that you want to apply the changes. This updates Nitro so it can handle requests using that domain.
This is going to update our hosts file, so we’ll likely need to enter our password.
Now let’s try it out by visiting both domains!
Let’s update the learndocker.nitro index template just to confirm that we’re pointing at the right place.
And, we are!
Local Development with Craft Nitro is made up of the following videos: