If you want to use Lando for local development, here are some basic steps for getting set up.
-
Copy
lando/default.lando.yml
to.lando.yml
. -
Take the
.loc
domains in the.lando.yml
file and add them to your/etc/hosts
file, as shown below:127.0.0.1 africanstudies.suhumsci.loc 127.0.0.1 amstudies.suhumsci.loc 127.0.0.1 anthro-net.suhumsci.loc 127.0.0.1 anthropology.suhumsci.loc 127.0.0.1 antiracismlab.suhumsci.loc 127.0.0.1 archaeology.suhumsci.loc 127.0.0.1 art.suhumsci.loc 127.0.0.1 artexhibitions.suhumsci.loc 127.0.0.1 bingschool.suhumsci.loc 127.0.0.1 biology.suhumsci.loc 127.0.0.1 biologyvirtualshowcase.suhumsci.loc 127.0.0.1 bsurp.suhumsci.loc 127.0.0.1 buddhiststudies.suhumsci.loc 127.0.0.1 ccsre.suhumsci.loc 127.0.0.1 ceas.suhumsci.loc 127.0.0.1 cesta.suhumsci.loc 127.0.0.1 chemistry.suhumsci.loc 127.0.0.1 clas.suhumsci.loc 127.0.0.1 classics.suhumsci.loc 127.0.0.1 cmbprogram.suhumsci.loc 127.0.0.1 cmems.suhumsci.loc 127.0.0.1 cqmd.suhumsci.loc 127.0.0.1 creativewriting.suhumsci.loc 127.0.0.1 creees.suhumsci.loc 127.0.0.1 culture-emotion-lab.suhumsci.loc 127.0.0.1 datasciencemajor.suhumsci.loc 127.0.0.1 dennylab.suhumsci.loc 127.0.0.1 dfetter.humsci.suhumsci.loc 127.0.0.1 dfetter2022.humsci.suhumsci.loc 127.0.0.1 dlcl.suhumsci.loc 127.0.0.1 dsresearch.suhumsci.loc 127.0.0.1 duboislab.suhumsci.loc 127.0.0.1 ealc.suhumsci.loc 127.0.0.1 economics.suhumsci.loc 127.0.0.1 em1060.suhumsci.loc 127.0.0.1 english.suhumsci.loc 127.0.0.1 ethicsinsociety.suhumsci.loc 127.0.0.1 facultyaffairs-humsci.suhumsci.loc 127.0.0.1 facultyaffairs-humsci2021.suhumsci.loc 127.0.0.1 feldman.suhumsci.loc 127.0.0.1 feminist.suhumsci.loc 127.0.0.1 finance-humsci.suhumsci.loc 127.0.0.1 francestanford.suhumsci.loc 127.0.0.1 gavin-wright.humsci.suhumsci.loc 127.0.0.1 gavin_wright2022.humsci.suhumsci.loc 127.0.0.1 gender.suhumsci.loc 127.0.0.1 globalcurrents.suhumsci.loc 127.0.0.1 grandtour.suhumsci.loc 127.0.0.1 gus-humsci.suhumsci.loc 127.0.0.1 gus-humsci2021.suhumsci.loc 127.0.0.1 heidi-williams.humsci.suhumsci.loc 127.0.0.1 heidi_williams2022.humsci.suhumsci.loc 127.0.0.1 history.suhumsci.loc 127.0.0.1 hopkinsmarinestation.suhumsci.loc 127.0.0.1 hs-colorful.suhumsci.loc 127.0.0.1 hs-design.suhumsci.loc 127.0.0.1 hs-fcp.suhumsci.loc 127.0.0.1 hs-sandbox.suhumsci.loc 127.0.0.1 hs-testing-sandbox.suhumsci.loc 127.0.0.1 hs-traditional.suhumsci.loc 127.0.0.1 hsbi.suhumsci.loc 127.0.0.1 hshr.suhumsci.loc 127.0.0.1 hsweb-userguide.suhumsci.loc 127.0.0.1 humanbiology.suhumsci.loc 127.0.0.1 humanexperience.suhumsci.loc 127.0.0.1 humanitiescore.suhumsci.loc 127.0.0.1 humanitiescore2022.suhumsci.loc 127.0.0.1 humanrights.suhumsci.loc 127.0.0.1 impact.suhumsci.loc 127.0.0.1 insidehs.suhumsci.loc 127.0.0.1 internationalrelations.suhumsci.loc 127.0.0.1 iranianstudies.suhumsci.loc 127.0.0.1 iriss.suhumsci.loc 127.0.0.1 islamicstudies.suhumsci.loc 127.0.0.1 it-humsci.suhumsci.loc 127.0.0.1 jewishstudies.suhumsci.loc 127.0.0.1 language.suhumsci.loc 127.0.0.1 linguistics.suhumsci.loc 127.0.0.1 lowe.suhumsci.loc 127.0.0.1 mathematics.suhumsci.loc 127.0.0.1 mcs.suhumsci.loc 127.0.0.1 mediterraneanstudies.suhumsci.loc 127.0.0.1 memorylab.suhumsci.loc 127.0.0.1 morrisoninstitute.suhumsci.loc 127.0.0.1 mrc.suhumsci.loc 127.0.0.1 mrc2021.suhumsci.loc 127.0.0.1 mtl.suhumsci.loc 127.0.0.1 music.suhumsci.loc 127.0.0.1 oconnell.suhumsci.loc 127.0.0.1 philit.suhumsci.loc 127.0.0.1 philosophy.suhumsci.loc 127.0.0.1 physics.suhumsci.loc 127.0.0.1 planning-humsci.suhumsci.loc 127.0.0.1 politicalscience.suhumsci.loc 127.0.0.1 popstudies.suhumsci.loc 127.0.0.1 psychology.suhumsci.loc 127.0.0.1 publicpolicy.suhumsci.loc 127.0.0.1 religiousstudies.suhumsci.loc 127.0.0.1 researchadmin-humsci.suhumsci.loc 127.0.0.1 scl.suhumsci.loc 127.0.0.1 sgs.suhumsci.loc 127.0.0.1 shenlab.suhumsci.loc 127.0.0.1 sitp.suhumsci.loc 127.0.0.1 siw.suhumsci.loc 127.0.0.1 sociology.suhumsci.loc 127.0.0.1 southasia.suhumsci.loc 127.0.0.1 stanfordsciencefellows.suhumsci.loc 127.0.0.1 starlab.suhumsci.loc 127.0.0.1 statistics.suhumsci.loc 127.0.0.1 sts.suhumsci.loc 127.0.0.1 suac.suhumsci.loc 127.0.0.1 swshumsci.suhumsci.loc 127.0.0.1 swshumsci-sandbox.suhumsci.loc 127.0.0.1 symsys.suhumsci.loc 127.0.0.1 tessier-lavigne-lab.suhumsci.loc 127.0.0.1 texttechnologies.suhumsci.loc 127.0.0.1 urbanstudies.suhumsci.loc 127.0.0.1 west.suhumsci.loc 127.0.0.1 womensleadership.suhumsci.loc 127.0.0.1 womensleadershipcp.suhumsci.loc
-
Build your containers:
lando rebuild
- Note: You should then see a list a APPSERVER URLS. A green URL signifies the step 3 worked correctly, and you'll be able to access the site in your browser (you'll see errors until you complete all the steps). If you see a red URL, go back to step 3. TODO: someone with a working proxy system should confirm this. Can you get green URLs after this step, or will it only work after you have a database?
- Watch for
sed
errors
-
Run
lando blt drupal:sync --site=SITE_ALIAS
to pull down a copy of the live database and files for the site you wish to work on (alternatively pull a db from staging or dev). TheSITE_ALIAS
is the site alias and can be found in themultisites
section ofblt/blt.yml
. In most cases, it matches the name in the local domain, with dashes replaced with underscores (hs-traditional
→hs_traditional
). -
Run
lando drush @[SITE_ALIAS].local uli
to log in as user:1 (Example:lando drush @music.local uli
). It will give you a URL likehttp://hs-traditional.suhumsci.loc/user/reset/1/12345/abcd9876/login
This should also run the front-end build. -
If you have issues, see Troubleshooting.
-
Front-end engineers, return to the main documentation for front-end build and watch commands.
lando drush @[SITE_ALIAS].local uli
- Get a link for logging in as an admin userdocker ps
- Check that your docker containers are runninglando info
- Check your lando config, including a list of domains, URLs, ports, etc.lando drush @[SITE_ALIAS].local cr
- clear cachelando drush @[SITE_ALIAS].local config-export
- export your local database settingslando drush @[SITE_ALIAS].local config-import
- import new database settings to your local.
- If you run into issues importing new config files try running the command with the partial flag:
lando drush config-import --partial
. - If the partial flag doesn't work, you may be missing a dependency. Re-sync your whole database, then run
lando composer install
. - If you find yourself in a position where starting fresh is your best plan of action,
lando destroy
will completely clear your running lando instances for a clean start. - If running
lando composer install
results in a timeout while installing a dependency, the default composer timeout for lando can be increased by runninglando composer --global config process-timeout 2000
.
When Docker is configured to use VirtioFS for file sharing, you might get multiple errors like this when running lando rebuild
:
sed: preserving permissions for '/app/docroot/sites/sts/settings/sed7b9pfU': Permission denied
or
sed: couldn't open temporary file /app/docroot/sites/africanstudies/settings/sed5mM1CH: Permission denied
This is caused by a bug in the sed
command that causes incompatibilities with VirtioFS. It has been fixed, but the images used by Lando don't have the latest version. To work around it, do the following:
-
Edit
.lando.yml
and comment or remove the following lines:- find /app/docroot/sites/ -name local.settings.php | xargs -I {} sed -i "s/'username' => 'root'/'username' => 'drupal'/g" {} - find /app/docroot/sites/ -name local.settings.php | xargs -I {} sed -i "s/'password' => 'password'/'password' => 'drupal'/g" {} - find /app/docroot/sites/ -name local.settings.php | xargs -I {} sed -i "s/'host' => 'localhost'/'host' => 'database'/g" {} - cp /app/lando/lando.sites.php /app/docroot/sites/local.sites.php
-
After running
lando rebuild
, execute the lines manually, changing the paths to match the ones on your local machine. If you're on macOS, you also need to alter the options for thesed
command a bit:find docroot/sites/ -name local.settings.php | xargs -I {} sed -i '' "s/'username' => 'root'/'username' => 'drupal'/g" {} find docroot/sites/ -name local.settings.php | xargs -I {} sed -i '' "s/'password' => 'password'/'password' => 'drupal'/g" {} find docroot/sites/ -name local.settings.php | xargs -I {} sed -i '' "s/'host' => 'localhost'/'host' => 'database'/g" {} cp lando/lando.sites.php docroot/sites/local.sites.php
- Copy an existing site's folder in
docroot/sites/
and rename it to the new site's name. - Edit the
blt.yml
file within your new site's folder with the corresponding site names. All other files within this folder use variables and don't need any modification. - Add the site domain to
.lando.yml
and/etc/hosts
. - Run
lando rebuild -y
Lando/docker initial versions had known compatibility issues with the first ARM-based Macs. Most of these issues have been fixed in the latest version, but if you still have problems, try the following:
- Edit your
.lando.yml
file and remove all but one or two sites from theproxy
configuration. - Perform the same setup tasks as above.
- If you need to test more than 1-2 sites at a time you will need to repeat step 1 and run through the full setup process again.
NOTE: This does not work well on ARM-based Mac's. Using Linux is highly recommended.
-
Copy codeception yml for setup. Copy
lando/default.codeception.yml
totests/codeception.yml
.- Edit this new
tests/codeception.yml
file and change theHTTP_HOST
,uri
andurl
(lines 19, 23, 25, and 28) to be the lando host of the site you are working on locally. - For example: hs-colorful would be
hs-colorful.suhumsci.loc
(keephttp://
for the url.) - You can also just edit
$db_name
inlando/default.codeception.yml
by appending the site name.
- Edit this new
-
Add local Drush configuration for testing
- Edit
docroot/sites/default/settings/local.settings.php
database connection to be the connection located indocroot/sites/sparkbox_sandbox/settings/local.settings.php
.
- Edit
-
Create
drush/local.drush.yml
and copy this code into that file and change thesparkbox_sandbox
to the directory name of the site you are working on locally. For example hs-colorful would behs_colorful
:# # This file defines drush configuration that applies to drush commands # # for the entire application. For site-specific settings, like URI, use # # ../docroot/sites/[site]/drush.yml drush: paths: # Load a drush.yml configuration file from the current working directory. config: - ../docroot/sites/sparkbox_sandbox/local.drush.yml - docroot/sites/sparkbox_sandbox/local.drush.yml # Allow local global config overrides. - local.drush.yml - drush/local.drush.yml include: - '${env.home}/.drush' - /usr/share/drush/commands
-
Change the uri in
/docroot/sites/[site_name]/local.drush.yml
to the uri of the site you are working on locally. For hs-colorful this would behs-colorful.suhumsci.loc
-
Edit
docroot/sites/default/local.drush.yml
and change the uri to the uri of the site you are working on. For hs-colorful this would behs-colorful.suhumsci.loc
-
Add the
creds
section to.lando.yml
. The database should match the site you are currently working on. For example for hs-colorful this would bedatabase: suhumsci_hs_colorful
.Example: services: appserver: ssl: true database: # Override the database that comes in the drupal8 creds: # recipe and use it for the /sites/default site. user: drupal password: drupal database: sparkbox_sandbox
-
Edit
/blt/local.blt.yml
and change the uri, hostname, and database (lines 4, 5 and 8) to the values for the site you are working on. For example, for hs-colorful, these would behs-colorful.suhumsci.loc
for the uri and hostname, andsuhumsci_hs_colorful
for the database. -
Rerun
lando rebuild
to get the new configuration added in step 5.
To run codeception tests run lando blt codeception --group=install
. Or if you wish to run a single class/method add the annotation in the docblock @group testme
and then run lando blt codeception --group=testme
.
In order to sync from a staging or dev site, you will have to do the following:
- In
suhumsci/docroot/sites/SITENAME/blt.yml
(SITENAME
being the site you are working with), change line 10 for remote to:remote: hs_colorful.stage
orremote: hs_colorful.dev
. - Sync the database as you normally would:
lando blt drupal:sync --site=SITENAME
.
To configure the SimpleSAML module so that you stop seeing the configuration errors in Drupal from that module and also to allow you to login from the /user login page with your Stanford account. (These commands should be run from the root directory.)
- Run
lando blt sws:keys
- Run
lando blt sbsc
- Go to the
/simplesamlphp/config
folder and edit thelocal.config.php
file. - Make sure lines 10,11,12 match the information from your
lando.yml
file for the site you are working on.- Example: If you are working on
sparkbox_sandbox
you will want to addsparkbox_sandbox
in for the host and the dbname on line 10 and update the username and password below to drupal.
- Example: If you are working on
- After you’ve gotten that file up to date, you need to
run lando blt sbsc
once more and then clear your site cache withlando drush @[site_name] cr
and the error should be gone upon reloading.
Notes:
-
There are still some slight bugs to work out with SimpleSAML. It will work for log in, but after logging in may throw errors on the login page. This can be resolved by clearing the browser cookies for that site.
-
The command for
lando drush @SITENAME.local uli
should still function with or without SimpleSAML configured to log in to the local site, if this is redirecting or not functioning correctly you should ensure the module is enabled or resync the configuration on your local site.