Lesson 1.3: Adding a second site step by step
This is the central practical lesson of the module. Each learner turns a single-site training installation into a
two-site one: a new folder becomes the root of a second site, a new siteaccess serves it, and the administration
learns that the site exists. Every setting is written with exp:ini, so learners can see and undo each change.
Note
Use your own training installation. The steps write settings files and clear the INI cache.
At a glance
| Course | Multisite and site packages |
| Module | Module 1: Siteaccesses for several sites |
| Duration | 60 minutes (15 presenting, 45 exercise) |
| Level | Intermediate |
| Audience | Administrators and developers |
| Prerequisites | Lesson 1.1 and Lesson 1.2; a training installation with URL matching (the exp:install default) and an administrator account on it |
Learning objectives
After this lesson, learners can:
- create the root folder of a second site and read its node ID;
- create a siteaccess by copying an existing one and set its name, start page and root node;
- register the siteaccess in
AvailableSiteAccessList[]andRelatedSiteAccessList[]; - reach the new site by its URL path and check it from the command line;
- tell the administration which public sites exist (
SiteList[]).
Trainer's notes
How to present it
Source: Setting up several sites in one installation, step by step.
- The five changes (5 minutes). Show the order on the board: content (a folder), siteaccess (a directory),
registration (two lists), matching (module 2; with URL matching nothing is needed), caches. Explain that with
MatchOrder=uriand the shippedURIMatchType=element, the first element of the path is taken as the name of a siteaccess, so/site_breachessite_bas soon as it is inAvailableSiteAccessList[]. - The settings of the new siteaccess (5 minutes). In
site.ini [SiteSettings]:SiteName,IndexPageandDefaultPage(/content/view/full/<node id>). Incontent.ini [NodeSettings]:RootNode. Mention[DesignSettings] SiteDesignfor a different look; the theme design course covers designs. - Why
exp:ini(3 minutes). It changes only the lines of the setting, keeps comments, backs the file up and clears the INI cache;--dry-runshows the diff first. Show one--dry-runon the projector. - Telling the administration (2 minutes).
SiteList[]insite.ini [SiteSettings]lists the public sites, so previews and links can use them. The installer writes it into the global override, so add a new site there. When several sites each have their own administration,FrontSiteAccessin that administration'ssite.ininames the site its Open the site links lead to.
Common questions
Why copy site instead of starting empty? The copy brings the design, the language and the other settings the
installer wrote, so the new site renders at once. Change what differs.
Does the new site need its own users? No. Users and roles are shared; lesson 4.3 limits a team to one site.
What if the copy carries a PathPrefix? A PathPrefix hides the first part of URL aliases for that
siteaccess. A copy keeps the prefix of the original, which belongs to the other site's folder. Step 6 checks it.
Is /site_b the final address? For the training lab, yes. Module 2 gives the site a host name of its own.
Pitfalls
- Node ID or object ID. The Details tab shows both.
RootNodeandIndexPageneed the Node ID. - A typo in the siteaccess name.
exp:inirefuses a scope for a siteaccess that has no directory; copy the directory first, then write the settings. - Velocity. If the lab runs on Exponential Velocity, restart it after the settings change
(
php bin/php/console exp:velocity restart), or the workers keep the old settings. - Unpublished folder. A folder that was only saved as a draft has no node; publish it first.
Hands-on exercise
Use your own training installation (URL matching, as installed by exp:install without --access). Commands run in
its root directory; add --allow-root-user if you work as root.
Sign in to the administration. In Content structure, open the top folder. Under Sub items, press Create new and choose Folder. Name it
Site Band press Send for publishing.Open the new folder, open its Details tab and note the Node ID.
In the shell, copy the public siteaccess:
cp -r settings/siteaccess/site settings/siteaccess/site_bSet the name and the start page (replace
NNNwith the node ID):php bin/php/console exp:ini set site.ini/SiteSettings/SiteName "Site B" siteaccess:site_b --dry-run php bin/php/console exp:ini set site.ini/SiteSettings/SiteName "Site B" siteaccess:site_b php bin/php/console exp:ini set site.ini/SiteSettings/IndexPage /content/view/full/NNN siteaccess:site_b php bin/php/console exp:ini set site.ini/SiteSettings/DefaultPage /content/view/full/NNN siteaccess:site_bSet the root node:
php bin/php/console exp:ini set content.ini/NodeSettings/RootNode NNN siteaccess:site_bCheck the path prefix the copy inherited:
php bin/php/console exp:ini get site.ini/SiteAccessSettings/PathPrefix siteaccess:site_bIf it prints a value, remove it from the copy:
php bin/php/console exp:ini rem site.ini/SiteAccessSettings/PathPrefix siteaccess:site_b.Register the siteaccess for the whole installation:
php bin/php/console exp:ini add 'site.ini/SiteAccessSettings/AvailableSiteAccessList[]' site_b global php bin/php/console exp:ini add 'site.ini/SiteAccessSettings/RelatedSiteAccessList[]' site_b globalTell the administration about the site:
php bin/php/console exp:ini add 'site.ini/SiteSettings/SiteList[]' site_b globalClear the INI cache (and restart Velocity if it serves the lab):
php bin/php/ezcache.php --clear-tag=iniCheck from the shell, with your lab's address:
curl -sI http://127.0.0.1:8087/site_b | head -1Open
/site_bin the browser. The page title shows Site B and the start page is the new folder.Run
php bin/php/console exp:ini where site.ini/SiteSettings/SiteName site_band find the file that wins.
Expected result
curlanswersHTTP/1.1 200 OK(orHTTP/2 200) for/site_b.- The browser shows the folder Site B as the start page, with the design of the main site and the name Site B.
exp:ini wherelistssettings/siteaccess/site_b/site.ini.append.phpwithSiteName=Site Bas the value in effect (unless the global override also setsSiteName; then the override wins, and the learner removes that line or sets the name there per siteaccess with module 3's tools).- Setup > System information, section Siteaccesses, counts one siteaccess more than in lesson 1.1.
- The trainer checks two learners'
/site_bon the projector.
Quiz
- Which ID does
RootNodetake, the node ID or the object ID? - With
MatchOrder=uriandURIMatchType=element, what makes/site_breach the siteaccesssite_b? A. AURIMatchMapItems[]entry B. The name is inAvailableSiteAccessList[]C. A DNS entry D. A Velocity restart - Why copy
settings/siteaccess/siteinstead of starting with an empty directory? - Which setting lets the administration know about the public sites?
- After the change, the site still shows the old name. Name two causes.
Answers
- The node ID, as on the Details tab.
- B. The element method takes the first part of the path as the siteaccess name; it must be an available
siteaccess (
settings/site.ini,URIMatchType=element). - The copy brings the design, language and other settings, so the new site renders at once; you change only what differs.
SiteList[]insite.ini [SiteSettings], which the installer writes into the global override (Setting up several sites).- The INI cache was not cleared; the global override sets
SiteNameand wins; Velocity was not restarted.
Further reading
- Setting up several sites in one installation: the steps with host matching.
- Changing settings from the command line: exp:ini:
set,add,rem,--dry-run. - 10.2 Siteaccesses and site addresses.
- Structuring the content tree.
Related pages
- Module 1: Siteaccesses for several sites
- Multisite and site packages: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.