Note that this recipe is for a generic LEMP stack. Definitely check out Lando's other recipes before you use this as there may be one designed specifically for use with your framework.
Before you get started with this recipe we assume that you have:
- Installed Lando and gotten familiar with its basics.
- Initialized a Landofile for your codebase for use with this recipe.
- Read about the various services, tooling, events and routing Lando offers.
Note that CakePHP could be any other php framework or your own custom php thing.
# Initialize a LEMP recipe using the latest CakePHP 2.0 version lando init \ --source remote \ --remote-url git://github.com/cakephp/cakephp.git \ --remote-options="--branch 2.x --depth 1" \ --recipe lemp \ --webroot . \ --name my-first-lemp-app # Start it up lando start # List information about this app. lando info
Here are the configuration options, set to the default values, for this recipe's Landofile. If you are unsure about where this goes or what this means we highly recommend scanning the recipes documentation to get a good handle on how the magicks work.
recipe: lemp config: php: '7.3' composer_version: '2.0.7' webroot: . database: mysql:5.7 xdebug: false config: server: SEE BELOW php: SEE BELOW database: SEE BELOW vhosts: SEE BELOW
Note that if the above config options are not enough, all Lando recipes can be further extended and overriden.
Choosing a php version
You can set
php to any version that is available in our php service. However, you should make sure that whatever framework or custom code you write is designed to work with your choice.
The recipe config to set the LEMP recipe to use
5.4 is shown below:
recipe: lemp config: php: '5.4'
Choosing a composer version
You can set
composer_version to any version that is available in our php service.
recipe: backdrop config: composer_version: '1.10.1'
Choosing a database backend
By default, this recipe will use the default version of our mysql service as the database backend but you can also switch this to use
mariadb or 'postgres' instead. Note that you can also specify a version as long as it is a version available for use with lando for either
Using MySQL (default)
recipe: lemp config: database: mysql
recipe: lemp config: database: mariadb
recipe: lemp config: database: postgres
Using a custom version
recipe: lemp config: database: postgres:9.6
recipe: lemp config: xdebug: true|false
However, for more information we recommend you consult the php service documentation.
Using custom config files
You may need to override our default LEMP config with your own.
If you do this, you must use files that exist inside your application and express them relative to your project root as shown below:
Note that the default files may change based on how you set both
via. Also note that the
server config will be explicitly for
nginx. We highly recommend you check out the nginx if you plan to use a custom
A hypothetical project
Note that you can put your configuration files anywhere inside your application directory. We use a
config directory but you can call it whatever you want such as
.lando in the example below:
./ |-- config |-- default.conf |-- my-custom.cnf |-- nginx.conf |-- php.ini |-- index.php |-- .lando.yml
Landofile using custom LEMP config
recipe: lemp config: config: php: config/php.ini database: config/my-custom.cnf
Connecting to your database
Lando will automatically set up a database with a user and password and also set an environment variable called
LANDO INFO that contains useful information about how your application can access other Lando services.
The default database connection information for a LEMP site is shown below:
Note that the
host is not
database: lemp username: lemp password: lemp host: database # for mysql port: 3306 # for postgres # port: 5432
You can get also get the above information, and more, by using the
lando info command.
Importing Your Database
Once you've started up your LEMP site, you will need to pull in your database and files before you can really start to dev all the dev. Pulling your files is as easy as downloading an archive and extracting it to the correct location. Importing a database can be done using our helpful
lando db-import command.
# Grab your database dump curl -fsSL -o database.sql.gz "https://url.to.my.db/database.sql.gz" # Import the database # NOTE: db-import can handle uncompressed, gzipped or zipped files # Due to restrictions in how Docker handles file sharing your database # dump MUST exist somewhere inside of your app directory. lando db-import database.sql.gz
You can learn more about the
db-import command over here
By default, each Lando LEMP recipe will also ship with helpful dev utilities.
This means you can use things like
php via Lando and avoid mucking up your actual computer trying to manage
php versions and tooling.
lando composer Runs composer commands lando db-export [file] Exports database from a service into a file lando db-import <file> Imports a dump file into database service lando mysql|psql Drops into a MySQL (or psql) shell on a database service lando php Runs php commands
# Download a dependency with drush lando composer require phpunit/phpunit --dev # Run composer tests lando db-import dump.sql.gz # Drop into a mysql shell lando mysql # Check hte app's installed php extensions lando php -m
You can also run
lando from inside your app directory for a complete list of commands. This is always advisable as your list of commands may not be 100% the same as above. For example, if you set
database: postgres you will get
lando psql instead of