- Setup your local LAMP stack (Local by Flywheel, etc).
- I recommend using www.getrefm.dev for your local environment.
- In Terminal, navigate to www.getrefm.dev/app/public/
- Git clone all files from Bitbucket: $ git clone https://[email protected]/colabcoop-ondemand/getrefmwp.git . (Note the period at the end).
- This will create a directory structure www.getrefm.dev/app/public/www/
- 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 www.getrefm.dev 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 www.getrefm.dev
- In Local, click the Trust SSL button to setup a trusted SSL certificate.
- Open http://www.getrefm.dev/humans.txt 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’], “getrefm.dev” ) ) { will apply to your getrefm.dev 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’, ‘192.168.75.100:5005’);
- Erase all other DB_PASSWORD entries in wp-config.php are erased for increased security.
- Erase entries for FTP_PASS.
- Erase entries for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
- 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 getrefm.com to getrefm.dev.
- Find the line “Attempt to load media files from production” and change ^staging\.getrefm\.com to ^www\.getrefm\.dev$ [NC]
- Change https://www.getrefm.dev/wp-content/uploads/$1 [NC,L] to https://www.getrefm.com/app/uploads/$1 [NC,L]
- Alternatively, download the large /wp-content/uploads directory from the Production server.
- Save the .htaccess file.
- Add a # before each of these lines to comment them out:
- 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 production-getrefm-wp.getrefm.com 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 https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Password protect the directory and place it in a unique subdirectory. (I.E., https://www.getrefm.com/__unique123/searchreplace/)
Never place the script in online without password protecting it.
Load the script in your browser and search and replace: - 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 192.168.75.100:5005 -n pressmatic -u root -p root -s getrefm.com -r getrefm.dev -x guid - $ php srdb.cli.php -h 192.168.75.100:5005 -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 staging.getrefm.com. Configure Postman to send email via SMTP localhost port 1025:
Then view the emails in MailCatcher here:
http://getrefmmailcatcher.colab.coop/
User: mailcatcher
Password: GgETr*EM
- If you are setting up staging.getrefm.com, setup OAuth Server on Staging (https://staging.getrefm.com/wp-admin/admin.php?page=wo_settings) with this client:
- Client Name: getwpauth-staging
- Client ID: hED2pAL0ZXF9yTGH6c8JXbJDh9JcQV
- Client Secret: 68AJaZkW0kTFtrza9Gmipkt8YLiHY9
- If the Client details must change, notify [email protected] of the new OAuth details.
- Once Local is setup: Right click on www.getrefm.dev and click Save as Blueprint. (Will take a looong time….)
- NOTE: We are using WP Offload S3 so getrefm.dev shares Amazon S3 media assets with the live getrefm.com. If you delete a file from the media library on getrefm.dev it will delete it from getrefm.com. (May not be true if we deleted the AWS keys.. TBD)
- Check error logs for any issues in the getrefm.dev/logs directory.
Resources
https://github.com/10up/wp-hammer