# Lando
# Create a local environment for WP (i.e. BitBucket Project)
- Create a new
wp-config-local.phpfile (if there isn't one). * - Add lando credentials
<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'wordpress');
define('DB_HOST', 'database');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
/*
* Insert salts here
* URL: https://api.wordpress.org/secret-key/1.1/salt
*/
define('WP_DEBUG', true);
- Generate and add salts (opens new window).
- In
wp-config, make sure the local config file is being loaded. - Add the
.htaccessto the root directory. (touch .htaccess) - Paste the following into the htaccess file:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
- Start the server (from project root):
lando start. - Import the backup DB:
lando db-import backup.sql.gz. - Perform a search and replace on the local environment:
lando wp search-replace <old-url.dusted> <new-url.lndo.site>
* Make sure there's a conditional statement for loading the wp-login-staging.php. i.e.
if (file_exists(dirname(__FILE__) . '/wp-config-local.php')) :
require_once(dirname(__FILE__) . '/wp-config-local.php');
else :
// main config credentials
endif;