{"id":353,"date":"2019-02-28T07:36:56","date_gmt":"2019-02-27T23:36:56","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=353"},"modified":"2021-11-11T17:09:52","modified_gmt":"2021-11-11T09:09:52","slug":"setup-wordpress-development-server","status":"publish","type":"post","link":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/setup-wordpress-development-server\/","title":{"rendered":"How To Setup A WordPress Development Server"},"content":{"rendered":"\n
You should have a development environment for every live WordPress site you own or work on.<\/p>\n\n\n\n
You'll hear terms like \"staging site\", \"local server\" or \"development environment\".<\/p>\n\n\n\n
Yes there are often nuances between them, but basically they're just a copy of your live site.<\/p>\n\n\n\n
You really should have at least one copy of your live WordPress site. This is where you test any updates or play around with new plugins or themes.<\/p>\n\n\n\n
Once your site goes live, that should be the end of testing on that server.<\/p>\n\n\n\n
Sometimes it's unavoidable, due to overly restrictive plugin developer licensing situations. But in any other case, just build a clone somewhere.<\/p>\n\n\n\n
How to setup a WordPress Development Server:<\/strong><\/p>\n\n\n\n Others might use these terms differently, but I typically think of four different types of setups:<\/p>\n\n\n\n The Live Website<\/em> is the one attached to your domain. It's the one the public visits and that goes on your business cards.<\/p>\n\n\n\n The Staging Site<\/em> is pretty much an exact copy of Live Website. It will often be on the same host (as an Addon Domain). But it might be on a different host.<\/p>\n\n\n\n This will be your last testing place to make sure everything's going to work on the Live Website.<\/p>\n\n\n\n The Staging Site will usually be accessible to anyone with an internet connection. You'll block search engines from seeing it. You might also put it in \"Maintenance Mode\"<\/a>, so only logged in users can see the site.<\/p>\n\n\n\n A Local Server<\/em>, in this context, is a copy of your WordPress site that sits on your computer.<\/p>\n\n\n\n It is great for rapid testing. No one will ever see it, so you can play with concepts and break things without fear.<\/p>\n\n\n\n Local Servers are free to setup and usually low on disk usage.<\/p>\n\n\n\n If you've got a Local Server setup on a laptop, you can work on your website from anywhere in the world, without worrying about an internet connection.<\/p>\n\n\n\n Then when you're ready, you just roll out those changes to the Staging Site, then the Live Website.<\/p>\n\n\n\n A Development Environment will often be the same thing as the Local Server.<\/p>\n\n\n\n Depending on what site you're building, you might have a separate Development Environment that has testing tools (like PHPUnit) installed.<\/p>\n\n\n\n The exact setup you go with for a project depends on how many people are involved, how big the project is, and how much custom programming you'll be doing.<\/p>\n\n\n\n If I'm working on my own projects, I'll usually have the Live Website with a Local Server on my desktop.<\/p>\n\n\n\n If you're working with a client, you'll need a Staging Site as well.<\/p>\n\n\n\n On my bigger projects, I'll have all four. Yes, two copies of the website on my desktop. One with testing tools and a connection to GitHub<\/a> repositories.<\/p>\n\n\n\n The \"local environment\" is the set of files and folders on your computer that allow WordPress to run offline, as well as the databases.<\/p>\n\n\n\n There are a number of different options for your local environment.<\/p>\n\n\n\n Some of the more popular ones are WAMP, MAMP and Local by Flywheel.<\/p>\n\n\n\n For years I've used XAMPP. It's free, open source and gets the job done. It's available for Windows<\/a>, Mac<\/a> and Linux.<\/p>\n\n\n\n If you're starting from scratch, then install a clean version of WordPress.<\/p>\n\n\n\n Otherwise, install WordPress from a backup. Basically, migrate the site to your local environment.<\/p>\n\n\n\n You can get away with just using Notepad++<\/a>. I did that for years.<\/p>\n\n\n\n That was until I discovered Atom. It's free, open source, works on Mac, Windows & Linux, and you can get it here<\/a>.<\/p>\n\n\n\n You might prefer a more complete Integrated Development Environment (\"IDE\") like Visual Studio or PHP Storm. I just find Atom to be lightweight, intuitive and so easy to use.<\/p>\n\n\n\n We'll also be using the easy git integration in a later step.<\/p>\n\n\n\n If you are developing a WordPress plugin or theme on this install, you need to have a testing suite.<\/p>\n\n\n\n If you're just doing a bit of theme customization, you can skip this step.<\/p>\n\n\n\n As someone who resisted learning Test Driven Development (\"TDD\") and Behavior Driven Development (\"BDD\") for way too long... just take a day to learn it. It will save you huge amounts of time.<\/p>\n\n\n\n For WordPress development on a local environment, you should install the free testing suite Codeception, which you can get here<\/a>.<\/p>\n\n\n\n Codeception is built on PHPUnit, and has an easy to use system for unit tests and acceptance tests.<\/p>\n\n\n\n If you don't already have Composer, get that setup first. That's available for free here<\/a>.<\/p>\n\n\n\n If you're on Windows, you should also install ConEmu<\/a> for running the tests. You could do it just in the standard Windows Command line if you had to. I just like that ConEmu allows you to have color coordinated responses.<\/p>\n\n\n\n Whether you're customizing a child theme<\/a> or building your own plugin from scratch, it's a very good idea to use git to keep track of your progress.<\/p>\n\n\n\n The main reason is so you don't keep lots of copies of a folder \"just in case\" you change your mind on some changes.<\/p>\n\n\n\n You can always go back and see what you changed when.<\/p>\n\n\n\n There are two main options for this. You could use GitHub<\/a> or BitBucket<\/a>.<\/p>\n\n\n\n Almost all of the time you'll be using Private Repositories.<\/p>\n\n\n\n For a long time, you had to go GitHub Pro (for $7\/month) if you wanted to use Git. They changed that in January 2019. Now the free version does what we need.<\/p>\n\n\n\n Some organizations prefer BitBucket, primarily because the free version allowed unlimited private repositories. But now GitHub has that feature, we'll just use that in these demos.<\/p>\n\n\n\n Sign up for the free plan of GitHub<\/a>, if you haven't already.<\/p>\n\n\n\n Once you're logged in, click \"New\" to create a new repository.<\/p>\n\n\n\nDefinition of terms<\/h2>\n\n\n\n
Live Website<\/h3>\n\n\n\n
Staging Site<\/h3>\n\n\n\n
Local Server<\/h3>\n\n\n\n
Development Environment<\/h3>\n\n\n\n
What types of development servers should you have?<\/h2>\n\n\n\n
Setup your local environment<\/h2>\n\n\n\n
Install WordPress<\/h2>\n\n\n\n
Install a good text editor<\/h2>\n\n\n\n
Install a testing suite<\/h2>\n\n\n\n
Create a git repository<\/h2>\n\n\n\n