Setting up a Local/Staging Environment
  • Setup your local LAMP stack (Local by Flywheel, etc).
  • I recommend using for your local environment.
  • In Terminal, navigate to
  • Git clone all files from Bitbucket: $ git clone . (Note the period at the end).
  • This will create a directory structure
  • Note that Local’s web root is /app/public/ and the repo contains /www/ as it’s root. We need to modify Local and point to the correct path
    • SSH into by right-clicking on the sitename and selecting “Open Site SSH”.
    • Edit the apache default site config file $ nano /etc/apache2/sites-enabled/000-default.conf
    • Make the following edits:
      • DocumentRoot /app/public/www/
      • <Directory /app/public/www/>
    • Save the file and exit. Control+o then Control+X
    • In Local, shut down and then restart
  • In Local, click the Trust SSL button to setup a trusted SSL certificate.
  • Open and ensure it loads the file in the browser.
  • The wp-config.php file is not stored in GIT. Download a copy from the production website (Noam can provide a copy).
  • All setting underneath the line if( stristr( $_SERVER[‘SERVER_NAME’], “” ) ) { will apply to your environment.
  • Add in the values for DB_NAME, DB_HOST, DB_USER, DB_PASSWORD provided by Local.
  • Note that Local uses Port 5005 for the database by default. Ensure this port is added to DB_HOST. Example: define(‘DB_HOST’, ‘’);
  • Erase all other DB_PASSWORD entries in wp-config.php are erased for increased security.
  • Erase entries for FTP_PASS.
  • In wp-config.php, review WPLT_DISABLED_PLUGINS and add any plugins that should be disabled on Local
  • Ensure that WPLT_SERVER is set to ‘DEVELOPMENT’.
  • Also open valuate/wp-config.php and add in the same values for DB_NAME, DB_HOST, DB_USER, DB_PASSWORD.
  • Local places two files in /app/public which should be moved to the new root directory (/app/public/www): local-adminer-*.php and local-phpinfo.php
  • Delete /app/public/.htaccess
  • Open /app/public/www/.htaccess
    • Add a # before each of these lines to comment them out:
      #php_value (All)
      #php_flag (All)
      #RewriteCond %{HTTPS} off
      #RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    • Search and replace to
    • Find the line “Attempt to load media files from production” and change ^staging\.getrefm\.com to ^www\.getrefm\.dev$ [NC]
    • Change$1 [NC,L] to$1 [NC,L]
    • Alternatively, download the large /wp-content/uploads directory from the Production server.
    • Save the .htaccess file.
  • Download /wp-content/advanced-cache.php from production (not included in GIT) and edit the file and update the paths.
  • Download a copy of the latest database from Production.
    $ mysqldump -u getrefm -p -h getrefm > ~/assets/database/getrefm-DB-file-RDS.sql
  • Open Sequel Pro from Local and delete all existing wp_* tables.
  • Import downloaded .sql file. When importing your database dump, you may need to select Western (Mac OS Roman) as the encoding format for the file to import without issue.
  • Download Search and Replace version 3+ from
    Password protect the directory and place it in a unique subdirectory. (I.E.,
    Never place the script in online without password protecting it.
    Load the script in your browser and search and replace:

    • –>
    • /opt/www/getrefm/www/ –> /app/public/www/
  • If you run into timeout errors, you can SSH into the Local server and run it from the command line:
    $ cd /app/public/www/Search-Replace-DB-master
    $ php srdb.cli.php -h -n pressmatic -u root -p root -s -r -x guid
  • $ php srdb.cli.php -h -n pressmatic -u root -p root -s /opt/www/getrefm/www/ -r /app/public/www/ -x guid
  • Be sure to delete the /Search-Replace-DB-master/ directory once complete.
  • If you are setting up a publically-accessible website, ensure search engines are blocked. Settings -> Reading: “Discourage search engines from indexing this site”.
  • Local has MailCatcher built-in and no configuration changes are required.
  • MailCatcher is also available on Configure Postman to send email via SMTP localhost port 1025:

    Then view the emails in MailCatcher here:
    User: mailcatcher
    Password: GgETr*EM
  • If you are setting up, setup OAuth Server on Staging ( with this client:
    • Client Name: getwpauth-staging
    • Client ID: hED2pAL0ZXF9yTGH6c8JXbJDh9JcQV
    • Client Secret: 68AJaZkW0kTFtrza9Gmipkt8YLiHY9
  • If the Client details must change, notify of the new OAuth details.
  • Once Local is setup: Right click on and click Save as Blueprint. (Will take a looong time….)
  • NOTE: We are using WP Offload S3 so shares Amazon S3 media assets with the live If you delete a file from the media library on it will delete it from (May not be true if we deleted the AWS keys.. TBD)
  • Check error logs for any issues in the directory.


Looking for self study products and access? Go to REFM's Courses Platform
left to take 50% off with coupon code: yearend50