Drupal 7 Standard or Express install with Lando
- If you haven’t installed Lando on your machine; now is the time to do so. See Installing Lando below.
1. Install the Codebase
Web Express
-
Set up a project folder with CU Boulder Drupal 7 Express Codebase and Profile
Specifically, CU Boulder’s Hardened Drupal 7 into specified project folder:
git clone https://github.com/CuBoulder/d7core.git {mySiteName}cd into profiles folder and clone down the ExpressMono profile into folder named ‘express’
cd {mySiteName}/profiles
git clone https://github.com/CuBoulder/express_mono.git express
Plain Old Drupal
Unzip Drupal 7 Tarball; rename folder to something workable like {mySiteName}.
Don’t forget to copy default.settings.php to settings.php and allow write privileges
chmod -R a+w sites/default
Drupal 9
With this one, we pull the latest Drupal Tarball from Drupal.org and initialize Lando all in one five-minute step.
composer create-project drupal/recommended-project myNewSite
cd myNewSite
composer require drush/drush
lando init --source cwd --recipe drupal9 --webroot web --drush true --full --name myNewSite
lando start
lando drush site:install standard --db-url=mysql://drupal9:drupal9@database:3306/drupal9 --account-name=admin --account-pass=admin -v -y
lando drush upwd admin "admin"
2. Initialize Lando in project folder
You must initialize Lando before you can go further, since Lando spins up the database that our site will be using. Go back to root of {mySiteName} folder
cd ../
and initialize it for Lando. A .lando.yml file will be created in your project folder. Lando has an extensive library of parameters. These are the ones we use to start:
lando init --source cwd --recipe drupal7 --webroot . --full --name {mySiteName}
3. Start Lando
lando start
Once the app has started up correctly, you’ll see the list of your appserver URLs:
https://localhost:32845
http://localhost:32846
http://mysite.lndo.site
https://mysite.lndo.site
Use the non-secure server protocol or your browser will be unhappy.
From now on, all your drush commands start with lando: lando drush {drush-command}.
4. Install the chosen Drupal Profile with drush
The database name, login and password are all ‘drupal7.’
Syntax: lando drush si my_profile_name my_profile_form.my_settings.key=value --db-url=mysql//admin_user:admin_password@db_host:db_port/database_name
PlainOldDrupal7
lando drush si standard --db-url=mysql://drupal7:drupal7@database:3306/drupal7 -v -y
PlainOldDrupal9
lando drush si standard --db-url=mysql://drupal9:drupal9@database:3306/drupal9 -v -y
Express cu_core
lando drush si express express_profile_configure_form.options.cu_core --db-url=mysql://drupal7:drupal7@database:3306/drupal7 -v -y
Express cu_testing_core
lando drush si express express_profile_configure_form.options.cu_testing_core --db-url=mysql://drupal7:drupal7@database:3306/drupal7 -v -y
Express cu_pantheon_core
lando drush si express express_profile_configure_form.options.cu_pantheon_core --db-url=mysql://drupal7:drupal7@database:3306/drupal7 -v -y
4.5 Modify Lando to use with XDebug and PHPStorm
According to Lando + PhpStorm + Xdebug
Open lando.yml and under ‘config’ add:
webroot: .
php: 7.2
xdebug: true
conf:
php: config/php.ini
Copy your local config/php.ini file to the root of your new site.
Under services.appserver.overrides.environment add
PHP_IDE_CONFIG: "serverName={mySiteName}.lndo.site"
5. Tweak local settings
Set base URL
cd sites/default/
code . # (if local machine configured to open Visual Studio Code)
Edit settings.php
DRUPAL 7: Uncomment line 315; put in local URL
$base_url = 'http://mysitename.lndo.site'; // NO trailing slash!
DRUPAL 9: Add trusted host pattern (include localhost for local installs):
$settings['trusted_host_patterns'] = [
'^mysitename\.lndo\.site$',
'^localhost$',
];
Logging in
Web Express
You can’t login with LDAP at this time. You can either:
- Put the site in Mixed Mode and enable the CU Local Users.
lando drush php-eval "variable_set('ldap_authentication_conf', array('authenticationMode' => 1));"
lando drush en cu_local_users -y - Login with the “drush uli” command
lando drush uli yourUserName
It will return a string. Grab the whole thing and paste into the browser’s address bar.
user/reset/{aBunchOfNumbers}/login
after which you may want to put the site in Mixed Mode and create a local user and login.
PlainOldDrupal7
Login with the “drush uli” command:
lando drush uli admin
Done. Go have fun coding.
Optional Site Setup
Turn on Theme Debug mode
lando drush vset theme_debug 1
More Info: Stack Exchange Drupal Answers Template Debugging
lando drush vset site_name 'Two Word Site Name'
lando drush vset theme_default cusimple
Options: cuhighlight cutradition cuswatch cuspirit cushadow curise cumodern cuminimal culayers cuivory cusimple
Enabling the bundles
Most of Them
lando drush en cu_advanced_content_bundle cu_advanced_design_bundle cu_advanced_layout_bundle cu_news_bundle cu_people_bundle cu_photo_gallery_bundle cu_feeds_bundle cu_seo_bundle cu_social_media_bundle -y
All of Them
lando drush en cu_advanced_content_bundle cu_advanced_design_bundle cu_advanced_layout_bundle cu_feeds_bundle cu_news_bundle cu_people_bundle cu_photo_gallery_bundle cu_seo_bundle cu_social_media_bundle cu_forms_bundle cu_video_hero_unit_bundle cu_publications_bundle express_collections_bundle express_localist_bundle cu_digital_campaign_bundle cu_mega_menu_bundle cu_livestream_bundle cu_content_sequence_bundle cu_newsletter_bundle cu_campus_news_bundle express_responsive_visibility_bundle -y
Create test content
lando drush en cu_test_content_admin_bundle cu_test_content_articles cu_test_content_blocks cu_test_content_collections cu_test_content_context cu_test_content_gallery cu_test_content_pages cu_test_content_people -y
Disable the Test Content modules
lando drush dis cu_test_content_admin_bundle cu_test_content_articles cu_test_content_blocks cu_test_content_collections cu_test_content_context cu_test_content_gallery cu_test_content_pages cu_test_content_people -y
Using SequelPro
SequelPro connects to the Lando database using the external connection port. This number changes every time you restart Lando on your project.
lando info
Sequel Pro settings are:
Standard
Host: 127.0.0.1
Username: drupal7
Password: drupal7
Database: drupal7
Port: external_connection port number, from above
Exporting a Site
To save all the work you’ve done on a site:
Export the database: lando drush sql-dump > my-sql-dump-file-name.sql
If completely and physically destroying, save the pics and uploaded files: save the sites/default/files folder, as that holds all the uploaded files.
Importing a Database
Destroy current drupal7 database and import a new one using these steps:
- Connect to SequelPro as above; once it’s destroyed you won’t be able to connect
- Destroy drupal7 database with
lando drush sql-drop -y - SequelPro: import database file; File » Import » navigate to database
- Alternatively, do it with command line
lando drush sql-cli < my-sql-dump-file-name.sql
Important: if your database requires certain modules to be enabled, be sure they are. Otherwise your site may blackscreen.
More Info Use Drush to Export/Import a MySQL Database Dump File
Lando Problems
Rebuilding a Lando Project
lando rebuild -y : Rebuilds the lando project while preserving any database data; can solve some problems
lando destroy : Destroying a project removes the Lando container and everything contained therein; i.e. your site’s database and its contents. It does not delete Drupal core or the Express Profile files cloned from GitHub. You can start over from Step 4: Install the chosen Drupal Profile with drush.
Cannot fully test WebForm
Emails cannot be sent through Lando; nor does the recaptcha work: ERROR for site owner: Invalid domain for site key
Misc Drush Commands
Run update script: lando drush updb
Disable modules: lando drush dis module_name
Variables:
lando drush vget {variable_name} # find out value of variable
lando drush vset {variable_name} {value} # set value of variable
lando drush vdel {variable_name} # delete variable
Running Test Content again (work in progress)
Note: So far this doesn’t work
Delete the Test Variables
lando drush vdel cu_test_content_beans
lando drush vdel cu_test_content_context
lando drush vdel cu_test_content_blocks_page
lando drush vdel cu_test_content_pages
Installing Lando (One Time Setup)
Get Lando dmg from GitHub; run through package installation
Lando config is created at ~/.lando
Lando Documentation