Local WordPress Development
This is a subpage of our wordpress directory.
If you’re looking to become a WordPress developer or if you just regularly edit WordPress themes, you’ll need to have a development environment set up on your computer. This is known as having a local copy of a site or local development.
The advantages of having a local development site are:
- Create and edit coding without having to upload your changes to see the effects
- Run code locally using a url structure that matches your development environment
- Perfecting code and working out bugs before deploying
- and many more
Editing files locally and running a website locally are a must to have complete and total control over the website you’re working on.
You’ll Need A Webserver With PHP and MySQL installed
To work on WordPress sites you’ll need to have a web server with PHP and MySQL installed. This is usually referred to as a LAMP server (Linux, Apache, Mysql, PHP), WAMP server (Windows, Apache, MySQL, PHP), or MAMP server (Mac, Apache, MySQL, PHP).
The first part you already have. Your operating system. Whether that be Windows, Linux or Mac.
The rest is software that needs to be installed.
On Windows, you can set up an all in one pre-configured WAMP server software. This is recommended for ease of use. However, if you’d like to learn more, install Apache, MySQL, and PHP separately so you can configure them together and learn how they work with each other.
On Mac, it is similar to windows. You can install an all-in-one MAMP server, or install the packages individually.
On Linux (or Windows Subsystem for Linux), you can install lamp-server package or install the packages individually. Again, I’d recommend installing them individually.
For WSL/Linux, see:
PHPMyAdmin Helps A Lot, Too
I always install PHPMyAdmin on every machine I work on. It’s a great visual tool so that you’re not using MySQL command line for everything. It’s indisposable.
Use A Subfolder For Every Website
Directory structure is going to matter once you start getting more than one website on your local machine. Therefore, I’d recommend setting up each website in it’s own directory inside of your public_html or htdocs directory.
Your directory should look like:
/htdocs
/site1
/site2
/site3
/etc
Keeping organized is a must.
Setting Up SSL with OpenSSL
If you’re accessing your websites using http, you really need to set up SSL so that you can use https. Everything on the web is https now and most browsers will display a big warning when you’re viewing a site that’s not SSL (or even partially not SSL).
Also, if parts of your websites use SSL, you can replicate that functionality on your local development environment.
You can use OpenSSL to make SSL work on your local machine.
See:
Use Virtual Hosts To Set Up Local Domains
If you have multiple websites and are not using virtual hosts with Apache, then you’re probably accessing your websites in your browser using localhost/site1, localhost/site2, etc.
To maintain a good URL structure on your websites and more comfortably match your development URLs, you can use virtual hosts to set up local domains.
https://localhost/site1 becomes https://site1.local. https://localhost/site2 becomes https://site2.local, so on and so forth.
A Fresh WordPress Installation
After you have your local development environment set up you can begin to install wordpress and write some code! Download a copy of WordPress from wordpress.org and put it in your public_html or htdocs folder. Visit the site in your browser and complete the WordPress installation.
This is how you set up WordPress from scratch.
You’re done!
Recommended Code Editors
You can edit your code in any text editor or IDE that you like. This topic is so debatable as to the best code editor that I hate to even mention it here. However, if you’re new, I can recommend with 100% confidence Visual Studio Code closely followed by Sublime Text.
You can use notepad if you’d really like, but don’t. 🙂
Previous: Why Use WordPress
Next: WordPress Hosting