As a WordPress developer, you should have as many tools in your belt as possible, including knowledge of WordPress localhost. Knowing how to install WordPress locally so you can have a local WordPress development site can dramatically streamline your web develpment workflow.
In this guide, we cover how to develop a WordPress site on a local server, or localhost. We’ll explain everything you may not know about how WordPress localhost works and why you may want to use it for development. We’ll discuss the benefits of building your own WordPress local development environment for your WordPress site. You’ll also learn exactly how to set up WordPress locally and how you can move your local development site to a live site when it’s ready for the world to see.
Now, let’s take a look.
In case you didn’t already know, WordPress is now the most popular website building and content management system (CMS) in the world. In fact, the WordPress platform is currently powering over 39% of the world’s websites!
In 2020, there are over 455 million websites that are running on WordPress. And every single day, there are hundreds of more people entering into the community of WordPress website development.
The need for WordPress developers is in such high demand that you’ll want to make sure your WordPress web development workflow is as streamlined as possible, and that includes having a local WordPress install for development purposes. WordPress localhost is a powerful way to take your WordPress development skills from beginner to expert in a relatively short amount of time.
What Is WordPress Localhost?WordPress Localhost allows you to set up a direct copy of a live WordPress website onto a local hard drive.
To drill down a bit further into the definition of WordPress localhost, in the most human-friendly, simplest terms, localhost translates directly to “this computer.” More specifically, localhost means “the computer that a program is running on.” Depending on your exact setup and the specific programs you’re using, localhost can mean your web server or your own computer.
Why Install WordPress on Localhost? 6 Reasons
Before we get into the nitty-gritty on how to use localhost in your WordPress development repertoire, let’s first look at why WordPress localhost is important in the first place.
1. Avoid the Risks of Developing on a Live Website
When starting out in the world of WordPress development, a common mistake is making changes major changes to a WordPress website directly on the live version of the website.
After all, if you’re not going to make changes to the live site, where else would you do it? A website is live to the world, right? When you need to make a change to the site, it seems to make the most sense to do it live.
However, running untested changes on your live website presents some major potential dangers, even if you’re planning to use something like a WordPress maintenance mode plugin while you work. At the end of the day, your live site is still open and viewable to the public. If you make a site change and something breaks or goes otherwise wrong, everyone currently browsing the site will certainly notice.
Not only does “live development” appear unprofessional and suspicious to some users (many users are now informed enough to be extremely wary of their data being left unprotected or stolen), you’ll probably lose a lot of users that will never come back.
But there’s no need to stress. Almost every single beginning WordPress developer has made this mistake at some point. This is where localhost for WordPress comes into play to save the day.
One of the major benefits of using localhost is that you’ll be able to make more high-risk changes to your site without the risk of experimenting while the site is live. However, there are even more benefits to localhost than this.
2. Test Themes and Plugins
If you’ve ever installed and activated a plugin, only to have it immediately conflict with something else already running on your site, you already know what happens: Your website crashes.
And sometimes, the theme or plugin conflict can be so severe that you won’t even be able to login to your WordPress dashboard to fix the problem. You’ll only be able to make site adjustments in your host’s cPanel.
If this hasn’t yet happened to you, rest assured that at some point it probably will.
However, when you have a local copy of your WordPress site, you’ll be able to test and try as many plugin and theme combinations that you want, without taking the risk of incompatibilities on your live site.
Once you know that the new plugins or themes work properly in localhost, you can push the changes to your live site.
3. Make Safe Updates to WordPress Core, Themes & Plugins
As a WordPress developer, it’s important to stay on top of software updates that become available for WordPress core, as well as the themes and plugins that you run.
In fact, keeping your WordPress website components fully updated at all times is one of the most pivotal things to do in order to maintain the safety and security of your site. A WordPress security plugin like iThemes Security Pro can help, of course, as well as WordPress security best practices.
As many WordPress developers have learned, running software updates to WordPress core, plugins or themes can sometimes cause conflicts or errors on their sites. When you click on that “update” button, it really is a crapshoot on what will happen when the update is complete.
But when you develop your WordPress site using localhost, you’ll be able to implement these important updates locally to check for problems prior to sending them live. If you experience problems in the local environment, you’ll be able to resolve the issues without disrupting your site’s uptime.
This small extra step will save you hours of frustration and downtown when software conflicts come through in WordPress core, plugin or theme software updates.
4. No Need for an Internet Connection
If you’re like most people, time is precious and downtime must be avoided at all costs.
By developing your WordPress site locally, you’ll be able to work on it without having any connection to the Internet.
Even if your Wifi goes down, you can continue to make updates to your local site and get it ready to send live with new updates as soon as you have an Internet connection again.
5. Speed Up Your Web Development Workflow
In the vast majority of cases, WordPress localhost sites run much faster than live sites. This is because the performance of a live site is dependent on the speed (or lack thereof) of an Internet connection.
This simple but important factor can vastly speed up your workflow while working on local site updates. When making individual updates to a live site, you’re probably losing a few seconds between each click that requires a new webpage to load.
By working locally, those load times will almost unnoticeable.
6. WordPress Localhost Staging Won’t Cost a Dime
Nearly any paid website hosting company will offer a staging area where you can develop your site before sending it online. However, it will come at a price.
Using localhost for WordPress is completely free. You’ll never need to spend a dollar on the WordPress core software of anything you need to get WordPress running locally.
A lot of new WordPress developers don’t even know that developing locally is an option. As such, they spend money on a staging area that isn’t needed. You can save a lot of money by developing locally.
How to Install WordPress Locally
Now that we’ve covered why you should develop WordPress sites locally, let’s cover a few different approaches for how to install WordPress locally.
Installing WordPress locally is an effective method when you want to test updates and applications that aren’t ready for public consumption. If you have a local WordPress install, you’ll have a fully-functioning offline version of your site that doesn’t require an Internet connection.
Remember, however, that although you’ll end up with a fully-functioning local site, nobody outside of the view of your computer screen will have visibility to it until you move it to a live host.
How to Install WordPress Locally on Windows
If you’re working with a machine powered by Windows, you can have a local WordPress installation by following these steps.
- Download XAMPP by heading over to Apache Friends.
- When the download is complete, run the file. The file is quite large and will take some time to download.
- Click through the prompts.
- Choose the correct components. You don’t need every component presented to you for installing XAMPP for WordPress. Aside from the required components, all you need to choose is phpMyAdmin and MySQL.
- Leave the install folder setting at default.
- On the next screen, click to uncheck the box for installing Bitnami for XAMPP. It isn’t needed.
- Click on “Next” and you’re ready for the install.
- Once the installation process completes, start the control panel. MySQL and Apache are required for a proper XAMPP install and WordPress. You can start each of these from within the XAMPP control panel.
- After they’re launched, the status should turn to green.
- Test the functionality of your local server by opening a web browser and navigating to http://localhost/. If everything was performed correctly, you’ll now have a fully-functioning XAMPP server on your local workstation.
Now it’s time to get a WordPress site running on your XAMPP server.
- Start by navigating to C://xampp (or something similar) to access the folder where the XAMPP application is installed. Within this folder, find the htdocs subfolder.
- Inside of the htdocs subfolder, create a brand new folder that you’ll use to test your WordPress site. Keep in mind that the name you choose for the folder will be the sub-name used to access your site (http://localhost/myfoldername).
- Extract the zip file you downloaded for WordPress core directly into the subfolder you just created.
- Login into the XAMPP control panel and start running phpMyAdmin.
- At the top of your screen, click on “databases” to create a new WordPress database for your local site.
- Enter a name, then click on “create.”
- Access your site by navigating to http://localhost/myfoldername. Here, you should now see the WordPress installer.
- When the system asks for the database details, use the name of the database that you created in phpMyAdmin for the “Database Name” field. For “Username,” use the root word. Leave the password field empty.
- Complete what remains of your WordPress install.
At this point, if everything was performed properly, you should now be seeing your WordPress install on localhost. Congratulations!
How to Install WordPress Locally on Mac
You don’t need to be a Windows user to locally install WordPress. However, for Mac users, there are a few steps that differ from the above.
- Download MAMP.
- After the download is done, run the installation wizard. There’s no need to install the Pro version. You can use the free version just by clicking on the grey folder.
- After installation is complete, head over to the MAMP controller to start the server.
- Unzip your WordPress core download file and place the folder inside the document root folder in MAMP.
- Re-name the folder to the name you want to use for your local WordPress site.
- Create the WordPress database by navigating to the phpMyAdmin function in MAMP’s control panel.
- Type in a new database name, then add the credentials of the database to your wp-config.php file.
- Open a browser and navigate to http://localhost/myfoldername. Run the WordPress installation.
The remaining steps for Mac are the same as for a Windows local WordPress install.
How to Install WordPress Locally on Linux
- Installing a local version of WordPress on Linux involves using XAMPP and following the same steps for installing on a Windows machine. Although some steps may have minor differences within the process, you should be able to navigate through them without much of a struggle.
How to Install WordPress Locally on Ubuntu
- To install WordPress locally on Ubunto, you need to work on a computer that’s running a Ubuntu Server 16.04 LTS and run an Apache2 server.
- To perform a local installation of WordPress, use this command:
sudo apt install wordpress php libapache2-mod-php mysql-server php-mysql
- If you still need to install MySQL, you’ll be asked for a password for the root MySQL user. You can leave this field empty.
- After that, you’ll need to create the Apache site for the installation. Create /etc/apache2/sites-available/wordpress.conf by using the following lines to configure WordPress on Apache.
To enable the site:
sudo a2ensite wordpress
To enable URL rewriting:
sudo a2enmod rewrite
To reload Apache2:
sudo service apache2 reload
- When this is all done, the next step is creating the MySQL database. Use this code to configure the database for Ubuntu.
- In order to configure your application of WordPress to use the database, open /etc/wordpress/config-localhost.php and write the lines:
<?php define('DB_NAME', 'wordpress'); define('DB_USER', 'wordpress'); define('DB_PASSWORD', '<your-password>'); define('DB_HOST', 'localhost'); define('DB_COLLATE', 'utf8_general_ci'); define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content'); ?>
- You’ll then want to enable MySQL by using:
sudo service mysql start
- At this point, you’re almost done. To configure your WordPress installation, open a browser and navigate to http://localhost/yoursitename. Here, you’ll be asked for your site title, username, email and password.
- You can now login to the WordPress dashboard at http://localhost/yoursitename/wp-login.php and begin creating your new local WordPress site.
How Do I Develop WordPress Locally?
No matter which of the methods you followed for how to install WordPress locally, now is when your work actually begins: developing your WordPress site. It’s time to begin the work of creating a new site and getting the finished product published to the world .Developing your WordPress site locally is no different than developing a live WordPress site. All of the functions available in the WordPress core software will be at your fingertips locally, rather than on a remote live server.
That’s what’s so great about WordPress localhost: You can create every detail of your new WordPress site right on your local machine, rather than building it piece-by-piece while the site is live for the world to see.
What’s also great about local WordPress development is that you can experiment on ideas, designs and functions to your heart’s content. Nobody else will be seeing your changes happen in real time, as they do when you develop on a live website.
But before you start digging in too deep to local WordPress development, first make sure to protect your work with a WordPress backup plugin like BackupBuddy.
The BackupBuddy plugin will automatically create backup versions of your site whenever a change is made. This way, if the worst should happen and your work is lost or corrupted, you can immediately recover the site from its last working moment.
BackupBuddy really should be the first plugin you install, no matter if you’re working on one WordPress site or manage multiple WordPress sites. The BackupBuddy plugin will also be your key tool for sending a local WordPress site to the live.
How to Copy a WordPress Site
If you are redesigning or making big changes to an existing WordPress site, you’ll need a copy of a WordPress site.
Copying a WordPress website is very similar to making a backup of a website. Why? A WordPress backup essentially makes a copy of your entire WordPress installation (including your WordPress database and all files in your WordPress installation). Just like making a backup, you’ll also need an easy way to access your backup files in a downloadable format.
The WordPress backup plugin, BackupBuddy, makes copying WordPress sites much easier than doing it manually. With BackupBuddy, there’s no need to manually export or download any files.
Here are a few ways BackupBuddy makes copying a WordPress site easier:
- You can copy your WordPress site directly from the WordPress admin dashboard (no need to login to cPanel or an FTP client).
- Your can download an entire WordPress website in a zip file (including your database and files) in a matter of minutes (sometimes seconds).
- You can quickly move the website copy to a new location such as a different domain, host or testing server with BackupBuddy’s ImportBuddy script.
We cover all the steps in more detail in this post: How to Copy a WordPress Site.
How to Move WordPress Localhost To Live Site
The final step of developing WordPress locally is moving the local site to a live site when you’re ready.
The BackupBuddy plugin is a multi-purpose tool for sending a local WordPress site to the live, allowing you to copy a WordPress site.
These are the steps to follow when it’s time to move a local WordPress site to a live domain:
- Install the BackupBuddy plugin. After it’s installed, run the Quick Setup to enable the required features.
- Use BackupBuddy to create a complete site backup of your local site. Within your WordPress dashboard, navigate to BackupBuddy > Backups page and click on the button that says “Complete Backup.”
- When the backup is done running, download the zip file and save it on your workstation. Don’t unzip it.
- Download the ImportBuddy file by navigating back to BackupBuddy > Backups and downloading the file called importbuddy.php.
- Confirm your password for ImportBuddy. When a window pops up, put in a new password or leave the field blank to use the ImportBuddy password that you set up with you installed BackupBuddy. Your password is important. It locks the ImportBuddy script from unauthorized access.
- Click “OK” and watch the download start.
- Create a new WordPress database and database user from your cPanel by logging into your hosting account.
- Once in the cPanel, find the MySQL Database Wizard icon and open it. This will automatically guide you through the required steps.
- Upload your backup zip file and ImportBuddy file into the new directory that was created. Use FTP access to access the server or the file manager within your host’s cPanel. Just make sure you have access to upload and delete server files.
To do so, open the directory folder of the final location of your WordPress site. It will be located in the /public_html directory. Make sure the directory is empty prior to uploading your backup zip file and importbuddy.php file. If you see any files in the /public_html directory, simply delete them. Now, upload the backup zip file and importbuddy.php file into the empty /public_html directory. To do this, you can use the upload function within your file manager.
- Then, open a browser and navigate to your site URL/importbuddy.php. For example, the URL would look like: http://myawesomeblog.com/importbuddy.php
- After the webpage loads, you’ll see an ImportBuddy screen. Enter the password you created in step five above. Click on the button that says “Authenticate.”
- Follow the next 6 ImportBuddy steps to complete the migration.
And that’s it! You’ve just migrated your localhost WordPress site to your live server. Make sure to check your site’s internal links to ensure everything is working the way you expect.
Wrapping Up: WordPress Localhost Is a Powerful Tool for Devs
Now that you understand localhost for WordPress, how it’s used, and why, now may be the time for you to start doing some of your web development locally.
For the most part, small site changes don’t need to be initiated in localhost. But if you’re making major site changes that will require hours of development work, using WordPress localhost is probably your best option.
Each week, the team at iThemes team publishes new WordPress tutorials and resources, including the Weekly WordPress Vulnerability Report. Since 2008, iThemes has been dedicated to helping you build, maintain, and secure WordPress sites for yourself or for clients. Our mission? Make People’s Lives Awesome.