Skip to content
therobyouknow edited this page Nov 17, 2022 · 4 revisions

This is a defacto community standard for a local developer setup - as in the web application/site running locally on a developer's personal machine.

Then once installed, assuming using a command line terminal setup, e.g. Ubuntu, macOS or WSL2, start ddev.

This will use the ddev setup created in .ddev for our purposes. This setup contains the php and mysql versions that are closest to the original dev setup before ddev and on production. A brand new .ddev setup can be created by doing ddev config before ddev start, but ddev will select more recent php and mysql versions as defaults.

e.g. for reference, running ddev config setup looks like this:

ddev config
Creating a new ddev project config in the current directory (/home/robd/Work/projects/scratchpads/sites/scratchpads-dev)
Once completed, your configuration will be written to /home/robd/Work/projects/scratchpads/sites/scratchpads-dev/.ddev/config.yaml

Project name (scratchpads-dev):

The docroot is the directory from which your site is served.
This is a relative path from your project root at /home/robd/Work/projects/scratchpads/sites/scratchpads-dev
You may leave this value blank if your site files are in the project root
Docroot Location (current directory):
Found a drupal7 codebase at /home/robd/Work/projects/scratchpads/sites/scratchpads-dev.
Project Type [backdrop, drupal6, drupal7, drupal8, drupal9, laravel, magento, magento2, php, shopware6, typo3, wordpress] (drupal7):
Ensuring write permissions for scratchpads-dev
No settings.php file exists, creating one
Existing settings.php file includes settings.ddev.php
Configuration complete. You may now run 'ddev start'.

Troubleshooting

problem:

Error like: 'docker not found' or 'Docker command can't connect to Docker daemon'

solution:

1 - add your user to the docker group: sudo usermod -aG docker $(whoami)

2 - reload user group assignments in your current terminal shell where you are trting to run docker(this saves having to open a new shell or avoid logging out and back in)

su - $USER

credit:

1 - https://stackoverflow.com/a/33782459 2 - https://superuser.com/a/345051

Import database

ddev import-db < dump.sql

problem:

Importing database dump fails with either or both of the below errors:

ERROR 1071 (42000) at line 59: Specified key was too long; max key length is 767 bytes
SQL client error occurred.
ERROR 1709 (HY000) at line 59: Index column size too large. The maximum column size is 767 bytes.
SQL client error occurred.

solution:

ssh into ddev container, run sql cli, run several commands to configure db to accept the things it was rejecting and erroring on.

steps:

ddev ssh
mysql -uroot -proot
GRANT SUPER ON *.* TO 'db'@'localhost' IDENTIFIED BY 'db';
FLUSH PRIVILEGES;
SET @@global.innodb_large_prefix = 1;
set global innodb_file_format = BARRACUDA;
set global innodb_large_prefix = ON;

credits:

problem:

An error like one of the following when importing a copy of a site db into your local personal setup:

Database error: data inserted in one transaction is greater than 10% of redo log size

ERROR 1118 (42000) at line 3384: The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size. Increase the redo log size using innodb_log_file_size.

solution:

Set innodb_log_file_size=256M for database

steps:

Add a .cfg file under .ddev folder in Scratchpads 2 git source tree, call it innodb_log_file_size.cnf. The path to it in Scratchpads git source should therefore be: .ddev/mysql/innodb_log_file_size.cnf

Inside innodb_log_file_size.cnf put the following lines:

[mysqld]
innodb_log_file_size=256M

Save file. And restart ddev so that the changes are picked up.

ddev restart

Note for future that this change will already appear in master in a future release, which will mean these steps not required to be done manually because in future they will already be in the code in git. But still worth documenting here the solution.

credits: