How to set up your Mac with WordPress to develop a news site like ours

How to set up your Mac with WordPress to develop

This post draws inspiration from NPR’s News Apps team’s comprehensive guide, “How to Set Up Your Mac to Develop News Apps Like We Do.”

At Rest of World, every developer, and even members of the product team if interested, runs a local copy of Rest of World on their Apple laptop for day-to-day development purposes. This setup guide aims to streamline the process, enabling developers to establish a basic environment swiftly.

Our internal documentation encompasses genuine content from our live site, including sample posts for reference and media assets for testing. However, due to its specificity to our usage, we won’t delve into those details here.

Upon completing these steps, users should be able to access the local website at:

https://restofworld.test

As this setup is tailored to Rest of World’s requirements, you may encounter RoW-specific placeholders. Feel free to adjust them as necessary

Chapter 1: Prerequisites

Are you an administrator?

You will have problems if you are not an administrator on your computer. We are Mac users, so adjust as needed to your operating system of choice.

Start System Preferences > Users & Groups

If you don’t see “Administrator” next to your account, you need to resolve it before going any further.

git and Xcode

You need to install git if you don’t already have it. It will be part of Xcode, although there are alternatives to it.

  • git (if you choose not to rely on Xcode)
  • Xcode:
READ  WordPress and Tumblr to Sign AI Learning Content Agreement

local

local is a plugin that takes care of most of the workload of building a local WordPress site. Before it came out we had a much more complex setup using VirtualBox and virtual images.

You should download the latest version of Local from here.

Configure git

  1. On macOS, open the Terminal app (although we prefer and use iTerm)
  2. Run git and follow the instructions
  3. Set up your Github account on your machine
  4. Set your username and password
git config --global user.name "Kathleen Booth"
git config --global user.email [email protected]

Our policy at Rest of World is that if 2FA is offered as an option for any service we use, we are required to enable it.

If you have 2FA set up for Github, follow these steps to generate a new SSH key, add it ssh-agentand add it to your Github account.

Chapter 2: Setup

Install local

If your laptop uses Apple Silicon, Rosetta 2 is required for the Apple Silicon build of Local, thanks to the nginx and MySQL lighting services compiled on the Intel architecture.

Here is the tutorial for installing it.

Configure your site

The native application guides you through the setup process. The only step that needs to be taken ahead of time is creating the directory you want to use.

For us, we go with:

mkdir -p ~/Development/localwp

While the installation process prompts you to create an account localYou don’t need to install and run WordPress locally.

  • Click Add a local site (+) button
    • Site Name: Rest of the World
    • Additional features
      • Set domain restofworld.test
      • Designate a folder for all of these. For this guide, we’ll assume the folder is:
        ~/Development/localwp

There should now be a new directory called localwp. This is where all WordPress files live.

wp-local > app > public > wp-public

This contains WordPress themes and plugins, and will later be where we add the services folders for our projects.

READ  WP Fastest Cache plugin bug exposes 600K WordPress sites to attacks

Whether you choose Preferred or By orderAt the time of writing, these are the current settings.

PHP: Version 8.1.9
Web Server: nginx
MySQL: 8.0.16

In general, use the latest versions unless you have reason to.

  • Click Continue
  • Add a username and password
  • Multisite: No
  • Click Add site
  • Turn on in the control panel One click Admin to: On

There are other steps that we are not covering here as they may vary depending on your needs.

For example; we manually configure the Menus and other fields in WordPress to match our production site. We also have a limited collection of posts, tags, authors, and other custom posts, along with related images from our imported Media Library.

Chapter 3:Version control

We use Github to manage our code, code review, and deployments. We offer separate vaults topics and: plugins folders in WordPress.

The rest of the world uses three separate warehouses;

  • topics for all the main code of the site
  • projects for code ordered for individual projects and
  • plugins For WordPress apps we’ve built or forked

Topics:

Our usual topic, orbit, includes basic website design, layout, and workflow. It includes customizations that probably should have been custom plugins. No one is perfect.

Projects:

Our article-specific and project-based development code is separate topics. Whenever we customize an article and add unique elements, or go beyond the standard visual treatment, that code goes here.

Plugins

We don’t put plugins in the plugins directory unless we build them in-house. It’s always best to enable automatic updates in WordPress, and you don’t want installations to break the latest versions.

READ  Top WordPress Plugins for Beginners Starting a WordPress Site

Troubleshooting

When working with the repository for the first time, you may get this warning about the pull.rebase configuration. A possible solution is this.

git config pull.rebase false  # merge (default strategy)

Additional reading:

Chapter 4: Final Configuration

SSL certificate on macOS

local supports a one-click solution to trust a site’s SSL certificate, but it never went as planned for us. There is documented work here.

Conclusion

You must be good to go.

At this point we will be adding our standard applications such as ACF Pro, Query Monitor (development environment only) and Co-Authors Plus. You do yourself.

Leave a Reply

Your email address will not be published. Required fields are marked *