Getting your local WordPress site live on a server
Last updated: September 14, 2024
Introduction
You can usually build most of the site locally, but at some point – the clients are going to want to actually add data to it – and have other people be able to visit it on the real internet.
So, what does that involve?
What Makes Your WordPress Site Work Locally?
Everything that powers your WordPress site locally will also be needed when you move it to a live server. It’s not a mystery—you’ll need all of the same components to ensure it functions properly. Here’s what to consider:
- A MAMP/LAMP stack (to handle HTTP requests, PHP interpretation, and run a database server)
- The core WordPress files (these must be stored and executed within the server environment)
- A MySQL database server (this needs to be running in the background)
- A database (where all your site’s content and configurations are stored)
- Running the WordPress installer (this sets up the core database tables and connects everything)
- Your custom theme files (these define the appearance and layout of your site)
- Any key plugins (for additional functionality)
Our “Web Developer” Workflow
- WordPress Installation
- Manual Installation via FTP or command line, or use a one-click installer through the hosting cPanel.
- Database Setup
- Manually configure the database or let the one-click installer handle it.
- File Migration
- Manually transfer theme files and plugins to the server.
- Database Migration
- Use a tool like WP Migrate Pro to migrate the database from local to live.
- Version Control and Automation
- GitHub integration to automate code updates on the server when changes are committed.
- Single Source of Truth
- Once handed off to the client, the live site becomes the single source of truth.
- Data is pulled down from the live server, and code is pushed up, ensuring the client has the ability to update and manage content.
Comparing Other Common Workflows
- Manual “Cowboy Coding”
- Directly editing files on the live server.
- No version control or automated processes.
- High risk of errors and inconsistencies.
- One-Click Installers and Manual File Transfer
- Install WordPress via cPanel’s one-click installer.
- Manually transfer files via FTP or file manager.
- Suitable for simpler setups but lacks the efficiency and safety of automated workflows.
- All-in-One Migration Plugins
- Use plugins like All-in-One WP Migration or Duplicator to handle both file and database migration in one step.
- Simpler but less customizable, and less control over specific aspects.
- Managed WordPress Hosting (e.g., WP Engine, Kinsta)
- The hosting provider handles many aspects such as backups, caching, and staging environments.
- Easy setup with pre-configured WordPress installations.
- Limited control over server settings but ideal for those who want to focus solely on development and content.
- Custom CI/CD Pipelines
- Fully automated deployment with services like GitHub Actions or GitLab CI to push code updates, manage database changes, and handle server configurations.
- Advanced and requires setup, but ideal for teams or complex projects.
Our Approach vs. Others
- Control and Customization: Our workflow ensures full control over every aspect of deployment, from database to file migration and version control, which is more flexible than using one-click setups or migration plugins.
- Safety and Consistency: Automating updates via GitHub and using a migration tool ensures consistency across environments and mitigates the risks of cowboy coding.
- Client Handoff: By keeping the live site as the single source of truth, clients maintain control over content while we manage the code, offering a clean separation of responsibilities.
Steps!
Ok. This video process is important (we think), but here are the steps (As we’re watching it and editing it).
- Decide where your WordPress project(s) are going to live
- In their own stand-alone folders?
- Now you can’t really reuse your other core code like CSS
- And you’ll need a second git repo (and github probably)
- If you’re using Buddy or some automation tool, you might not have any more free options to deploy (you can figure out other ways)
- Or within your core personal website structure?
- It’s a lot of code now in your core (all the framework code) (but you will git ignore it) (you can also tell your text editor to ignore those files too
- Probably still can’t really reuse your other core code like CSS
- Which is better? Depends! Both have pros and cons. But also – they are both equally a bit more work and stuff to deal with – but that’s life!
- You’ll get to your site in MAMP like
localhost:8888/projects/my-wordpress/wp-admin
so, that will be a bit longer / but you won’t have to switch between MAMP hosts…
- In their own stand-alone folders?
- Decide what server you’re going to put the live WP site on
- Are you going to use the PE projects server?
- If so, get on a call with Derek, and he can help get a WP instance installed up on the server – either in your personal folder / or somewhere else of your choosing.
- Do you already have your own server for your personal website? If so, let’s explore how that host does things and get it setup. What type of host is it?
- Are you going to use the PE projects server?
- Decide if you’re going to more manually setup the database and WordPress install – or if you’re going to use a quick install (a one-click option that will install WP that most hosting providers offer)
- If you’re manually setting it up – then you’ll need to get the WP framework files up there either by FTP or some CLI or something, and to do that, you’ll need to have permissions and a way to connect.
- You’ll add those files, create a database and user, add those credentials to the wp-config in the files, visit the live site – and run the installation (which will seed the database with the core data needed to run it)
- If you use the one-click/quick/wizard install – it will likely create the database – connect it in the wp-config, and then install it for you (so just note what it’s doing for you / you probably won’t get to name the database for example) (Also note if there are any backups and other options for the hosting)
- Now you should be able to login with your credentials and see the live admin panel
- You’ll have two installs but:
- the live site won’t have the same data because they are two separate databases on different servers
- the live site won’t have your theme code either (yet) (probably)
- So, you’ll need to move your theme files up – and remember to activate that theme
- But it’ll probably be broken because none of your post types or data will exist
- Then you’ll need to get your local data up on the live server
- We use wp-migrate (a plugin) / so, talk to Derek about the options and patterns there
- There are many ways to do this with varying degrees of possible disaster
- After that – the data will be up to date – and you’ll be logged out because your users all got replaced
- So, you can log in again
- We use wp-migrate (a plugin) / so, talk to Derek about the options and patterns there
- Now you’ll have:
- Local (your local virtual server)
- Live (your public server on the open web)
- Decide if your client is going to be using the live site – or if you’re going to be doing all data/admin from local
- Talk about the patterns there.
- Any questions? Help us flesh this out.