Setting up a local WordPress development environment
- 2. Local
– your physical machine (PC/Mac/Laptop)
Staging
– Hosted (interwebs) site used for client showcase and
testing of website changes
Production
– The live website being accessed by visitors
- 3. • Heaps faster (no waiting on file transfers)
• Safe environment (let’s not make untested
changes to production)
• Demo to clients and quickly change stuff on the
fly on-site
• Don’t need no freaking interwebs
– Work on a plane or
during a zombie apocalypse
- 4. 1. Install WordPress on local
2. Edit code and test changes
3. Push changes to the server
– Either direct to production (try to avoid this)
– Or to staging then production
Local Staging Production
Local Production
- 5. On your local machine
– Apache (web server)
– MySQL (database server)
– PHP (programming language)
– WordPress
– Code editor
– Your fav web browser
• Or most likely all of them for testing
Server
Component
(AMP)
- 6. • Desktop Server (Win & Mac)
– http://serverpress.com/products/desktopserver/
– Free open source
• Setup wizard – installs Apache, MySQL, PHP,
WordPress & PHPMyAdmin
• Uses .dev local TLD
– Sites are installed as:
www.example.dev
Top Level Domain
- 7. • XAMPP Apache + MySQL + PHP + Perl
– https://www.apachefriends.org/
– Win, Mac, Linux = free open source
• Just installs the server component
– requires some knowledge of setting up Apache &
MySQL databases
• More granular control over your environment
• Can install WordPress as an add-on module
– https://www.apachefriends.org/add-ons.html
Another Script Language
- 8. • MAMP – Apache + MySQL + PHP + Perl + Python
– https://www.mamp.info/
– Win & Mac (mostly Mac users) = free + paid version
• Just installs the server component
– requires some knowledge of setting up Apache &
MySQL databases
• More granular control over your environment
• You need to install WordPress manually
Another Script Language
- 9. • AMPPS: Apache + MySQL + PHP + PERL + Python + MongoDB
– http://www.ampps.com/
– Win, Mac & Linux = free
• Same story as MAMP, XAMPP
– Highly configurable but requires setup &
configuration
Alternative Database
- 10. • Vagrant + VirtualBox
– Advanced local dev setup
– Win, Mac & Linux = free open source
• Allows you to create a virtual machine running on local
– Virtualisation software
– Run any operating system
– Run any web server configuration
• Used by expert developers to replicate exact client
environment
- 11. • Command line setup of server image
• Above creates a new virtual machine running Ubuntu
12.04 LTS 32-bit
• “Vagrant SSH” to configure machine
• “Vagrant destroy” to remove all traces from local
machine
$ vagrant init hashicorp/precise32
$ vagrant up
- 12. There is a special build of Vagrant called Chassis
– WordPress, PHP 5.6, NGINX and MySQL pre-installed
“Chassis is a virtual server for WordPress, designed for
simplicity and speed.”
You can read more at http://docs.chassis.io/en/latest/
- 14. • What software versions do you need?
– PHP 5.6? Apache 2.4? NGINX?
– Do you need Python? MariaDB?
• The price you’re willing to pay (most are free)
• What tools/support are included?
– Debugger, frameworks (Zend), PHPMyAdmin
• How easy to set up and configure
– Server components
– WordPress
Alternative Database
Alternative Web Server
- 15. • Grab latest copy from
https://wordpress.org/download/
• Download to local and unzip
• Open /wordpress folder
• Move contents of /wordpress folder to server
– You probably don’t want /wordpress/ in your site URL
• Copy wp-config-sample.php to wp-config.php
• Edit wp-config.php and change
– DB_NAME, DB_USER, DB_PASSWORD, DB_HOST
– e.g. define('DB_HOST', 'localhost');
- 16. • PHPStorm (Win, Mac, Linux) - my fav
– https://www.jetbrains.com/phpstorm/
– Supports WordPress projects
– Also Git/Xdebug/SSH + lots lots lots more
– Paid (30-day trial) ($199 USD March 2016)
• Coda (Mac)
– http://panic.com/coda/
– Supports WordPress Projects (Git +more)
– Paid ($99 USD March 2016)
- 17. • Sublime Text (Win, Mac, Linux)
– http://www.sublimetext.com/
– Paid ($70 USD March 2016)
• Dreamweaver CC (Win, Mac)
– http://www.adobe.com/au/products/dreamweaver.html
– Interacts with Photoshop – CSS from PSD layers
– Paid ($22.99 AUD Adobe CC subscription March 2016)
• Notepad (Win) / TextEdit (Mac)
– Free!!
- 18. • PHPMyAdmin (Win, Mac, Linux)
– http://www.phpmyadmin.net/
– Free open source
– Standard DB interface with most Linux builds
• Navicat (Win, Max, Linux)
– http://navicat.com/ (Win, Mac, Linux)
– Paid ($99-$799 USD March 2016)
– Advanced users
• Visual SQL/Schema builder
• Cloud DB management
- 19. Local Server Running
WordPress Installed
Database Management Installed
Code Editor Ready
- 20. Ultimate goal is to update a production server!
You need to shift code from local to production.
- 21. File transfer (FTP)
– WinSCP (Win)
• http://winscp.net/
– FileZilla (Win, Mac, Linux)
• https://filezilla-project.org/
– Forklift (Mac)
• http://www.binarynights.com/forklift/
– Transmit (Mac)
• https://panic.com/transmit/
- 24. FTP transfers files in plain-text (unencrypted)
FTPS – secure version of FTP, requires SSL
certificate
Even better to use SFTP – using SSH keys to
authenticate, encrypt and transfer files securely
- 25. • Git http://git-scm.com/ (open source)
– Distributed repository version control
– Most popular just now
• Mercurial http://mercurial.selenic.com/ (open source)
– Distributed repository version control
• Subversion https://subversion.apache.org/ (open source)
– Central repository version control
• Dropbox https://www.dropbox.com/
– Hmmm? But yes I’ve seen it being used
- 26. • PHPMyAdmin
– Export database as sql.gz from local
– Reimport to empty database on server
• Search Replace DB
– https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
– PHP file – run through browser
– Replace testdomain.dev with www.mydomain.com
• WP Migrate DB Pro
– https://deliciousbrains.com/wp-migrate-db-pro/
– Push/Pull/Sync WordPress databases
- 27. • Code Diff (compare changes)
– Kaleidoscope (Mac) http://www.kaleidoscopeapp.com/
– Diffmerge (Win) http://www.diffmerge.net/
• Offline API Documentation Browser
– Dash (Mac) https://kapeli.com/dash
– Zeal (Win, Linux) http://zealdocs.org/
- 28. • Testing
– PHPUnit for testing PHP code https://phpunit.de/
– WordPress test data http://wptest.io/
• Git Hosting
– Bitbucket (free private repos) https://bitbucket.org/
– GitHub (free public repos) https://github.com/
- 29. [Front Cover] 1935 Bride of Frankenstein movie
[3] pixbay.com
[6] serverpress.com
[7] apachefriends.org
[10] vagrantup.com
[11] vagrantup.com
[12] chassis.io
[20] memegenerator.net
[22] zeropointdevelopment.com
[23] zeropointdevelopment.com
[Back Cover] zeropointdevelopment.com
- 30. 20+ years in IT: Dev & SysOps
WordPress Developer since 2008
Plugins, APIs, Security & Systems Integrations
Organiser WPSyd & WordCamp Sydney
zeropointdevelopment.com
@DeveloperWil
♥ Pizza & Craft Beer