Local Environment Setup (VirtualBox + Docksal)
Please feel free to view a video of local environment setup as well follow the instructions below. Note that this is an outdated setup process; our team has moved to a setup that uses Laravel Valet and DBngin on MacOS (view more here).
First-time setup
Download VirtualBox for Mac
Download the VirtualBox package from the link
Follow the instructions to install Docksal through the command line
Install Homebrew if needed
Project setup
Clone the project from Bitbucket
Log into Bitbucket, navigate to desired project, click on clone in the top right corner
Copy the git clone command (ex:
git clone git@bitbucket.org:relias/relias-wceiblog.git
)Copy in the Projects folder within the terminal
A new folder will be created automatically with the repo inside
If on a mac, click cmd + shift + . to see hidden files
Add Wordpress Core files to the new project root folder. See all versions here
Do not overwrite wp-content or .htaccess files
Make sure you use WP Core version that is the same as the version that your project is using
Add uploads for project
Download a backup from WPEngine that includes all file uploads
Navigate to http://www.wpengine.com , click on sign in. Log in with your credentials.
Navigate to production version of desired site
Click on “backup points” from the left side menu
Click on “Create backup”
Within the pop-up:
enter backup description (typically “deployment backup”)
remove email addresses listed and only enter your email address. This is where the notification is sent that a backup has been created.
Click “Create production backup”
Once the backup has been created, you will receive an email notification. You may then navigate to wpengine backup points, choose your recently created backup point, and click “prepare zip”.
You may choose to do a full backup or partial backup. If you choose a partial backup, you will need the entire database and media uploads.
Make sure you’re sending notifications only to your email address
When the zip has been successfully created, you can then click on the download link to download the zipped version of the production environment.
When moving uploads to project uploads folder, only copy over each year’s folder from the backup. Ignore sucuri logs and .htaccess, these are not needed locally.
Run
fin system start
in the project root folder in terminalSince docksal files are already configured in git, you won’t need to worry about those.
Please note, this may take a while if it’s your first time building
Run
fin p start
in the project root folder in the terminal to start your project.Visit the project URL provided in the terminal
You should see a Wordpress startup screen, since the database has not been imported and a wp-config file has not been generated yet.
Navigate through screens but stop at the screen where you need to enter database connection details. You’ll need to make sure your database is set up prior to doing this. Please follow the sets in https://relias.atlassian.net/wiki/spaces/CEMVP/pages/2540831060/Relias.com+%7C+Local+Environment+Setup#Set-up-the-database section before proceeding.
After database has been set up, please fill in the screen with the following:
Database name: local_wceiblog (or whatever your database name is)
Username: root
Password: root
Database Host: db
Table Prefix: wp_
Set up the database
Download/open Sequel Pro (if you’re on a mac)
Hook up your project’s configuration files to the new database connection:
In the docksal.env file, remove hashes and add single quotes around variable values for your database’s credentials
MYSQL_ROOT_PASSWORD=’root’
MYSQL_USER=’user’
MYSQL_PASSWORD=’root’
Change the port mapping variable to a unique port number:
MYSQL_PORT_MAPPING=’00000:3306’
Run ‘fin p restart’ to initialize changes.
Docksal has a MYSQL service built in that is exposed to a random port by default. Create a new connection using these credentials:
Name: your project’s name (use ‘local_projectname’)
Host: 192.168.64.100
Username: root
Password: root
Database: [leave blank]
Port: [choose a number unique for this project]
Verify the connection works, then save it as a favorite in Sequel Pro for quick use.
Add the wp-config-local.php file to your project root folder. Update the database variables similarly for this file:
define(‘DB_NAME’, ‘local_projectname’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ‘root’);
define(‘DB_HOST’, ‘db’);
Do the same for wp-config-sample.php
Run ‘fin p restart’ to initialize changes
Import the database file from the backup you downloaded from WPEngine
Once you have tested and made the connection, go to File > Add Database in Sequel Pro
Add a new db with the same name you set up in your wp-config-local.php file for DB_NAME
Import the mysql.sql file from your site backup’s wp-content folder
Now that the database is imported and connected, run through the Wordpress setup screens in your local environment browser tab.
If you see an error that says “error establishing database connection”, there is likely a problem with the wp-includes/wp-config.php file.
Within wp-config.php file, you can remove the section that says “Authentication unique keys and salts”. This is not needed for the local environment.
After you make changes to files, always do a
fin p restart
within the terminal. This updates your instance with whatever changes you’ve made in files.Visit your project url and you should see a working project.
Sometimes images and css won’t load and you’re see errors within your console. In that case, run the following commands:
Within terminal on the project, run the following commands that will allow read/write/execute access to all files within directory
chmod -R 755 wp-includes
chmod -R 755 wp-content
navigate to the wp-content and run:
chmod -R 755 uploads
Some errors are expected because some 3rd party tools are not needed on a local environment. You can ignore these errors. If you have any questions about the errors please reach out to the team lead.
Search-replace the database
Before visiting the project URL, need to adjust the database so that existing plugins and URLs do not conflict with local setup
Use wp-cli to disable the following plugins (if they exist):
fin wp plugin deactivate redirection
fin wp plugin deactivate sucuri-scanner
fin wp plugin deactivate autoptimize
Search and replace all live URLs with local project URLs:
fin wp search-replace ‘https://www.livesite.com ’ ‘http://project.docksal’ --dry-run
Be very mindful of entering the correct urls and your syntax
When satisfied with dry run results, re-run command without --dry-run argument
Run
fin p restart
, to refresh everythingGive the new project folder permissions needed for Docksal to access images. From the Projects folder, run this command in Terminal:
chmod -R 755 <folder name>
Your local environment should now be ready to use.
Notes:
Use
fin vm restart
to fix 403 Forbidden errors