As easy as it is to set up and run a website with WordPress, there’s still a lot you can do wrong. Among the biggest mistakes user make:
- Neglecting to back up their WordPress site
- Not caring about WordPress security
- Using plugins and themes from non-trustworthy sources
One of the worst practices, however, is making changes to their live sites.
Ever found yourself uploading your modified functions.php or style sheet to your site praying that it won’t break something? Or tried out a new plugin only to find that it shot your entire site to hell and left you scrambling for a fix for hours?
There’s gotta be a better way, right?
Well, it turns out there is and it is called local development. What’s that you ask? Well, it basically means setting up a copy of your WordPress website on your local computer instead of an online web server.
Why would anyone do that? Well, knowing how to install WordPress offline offers numerous benefits. In this post you will not only learn what those are but also how up a local server on your computer and install WordPress on it.
Are you ready for that? Then let’s get started.
Why Install WordPress Offline?
There are many good reasons to install WordPress on a local server. For some people, like theme and plugin developers, it’s even mandatory in order to test their work.
In addition to that, in contrast to an online staging environment a local development server is completely independent of an Internet connection and you can take it with you wherever you go.
Besides that, since everything is happening on your local computer, you benefit from faster loading times and a more efficient workflow.
Plus, installing WordPress offline allows you to test site changes, themes and plugins in a safe environment that, if something goes wrong, won’t take your live site down with it.
Finally, as you will see below, setting up a local development environment is completely free, something that can’t be said about most rented online space.
Convinced yet? Then let’s take a look at how to make this happen.
Some Things You Will Need
As you probably know, the WordPress platform can not run on its own but needs a server environment. In fact, it has some very specific requirements.
For example, WordPress needs both PHP and MySQL present in order to work. The former is the main language it is written in while the latter powers its database.
In addition to that, most servers come with database administration interface like phpMyAdmin (unless you know how to write MySQL queries, that is) and some other extras.
Long story short, to install WordPress offline, you need to recreate this kind of environment on your local computer.
There are several free solutions out there to do so, however, in this tutorial will be using XAMPP, which stands for cross-platform, Apache, MySQL, PHP, Perl.
As you can already see from the name, this piece of software contains all of the components to set up a local server. It also works across platforms, meaning both PC, Mac and Linux users can use it. Plus, you can download XAMPP for free from Apache Friends.
There are also Windows and Mac specific software stacks called WAMP and MAMP. They also get the job done, however, we found XAMPP to be the most versatile of the pack.
Installing XAMPP on Your Computer
In the following, you will learn how to install XAMPP on a PC with Windows 7. Don’t worry, if you run a different machine, the steps should be very similar and we will include some specific advice for Mac users further below.
1. Run the Installer
After download, double click on the XAMPP installation file. Upon startup, you might get a warning about using software from unknown sources. If so, allow to continue to the installation wizard.
First, you need to choose the components you want to install. Apache and PHP are activated by default and we also need to check the boxes for MySQL and phpMyAdmin.
XAMPP also comes with some other things like a virtual FTP and mail server, however, unless you have specific reasons to install those, you probably don’t need them. Click Next when done.
After that, you will be asked where to install XAMPP. Be aware that the software will also save your websites in the same place so choose an easy installation path. Otherwise you might have to do a lot of clicking later on.
The next step of the installation process is a promotion for Bitnami. While they offer an interesting tool, we don’t need it at this point. Therefore, uncheck the box and move on to the next step.
XAMPP is now ready to install. One more click and it will start copying all necessary files to your hard drive. After that’s done, the software is installed. Leave the last checkbox active so it gets started right away after you click Finish.
2. Configure XAMPP
When XAMPP is first started, you might receive a firewall warning from Windows. If that’s the case, give it full permission for private networks so it can work.
After that, you will see the control panel for the first time.
You can start both Apache and MySQL by clicking their respective Start buttons. Usually this should go off without a hitch but some users might encounter conflicts with other applications that use the same ports as XAMPP like Skype.
One way to solve the problem is to close the conflicting application and start the blocked XAMPP component again. However, in Skype, you can also fix it permanently by opening the video call software and going to Tools > Options > Advanced > Connection. Here, uncheck box that says Use port 80 and 443 for additional incoming connections.
After saving and restarting Skype, the problem should no longer appear.
Back to XAMPP, under Config in the upper right corner, you also have the possibility to configure which modules should be started automatically at startup. By checking Apache and MySQL you can make sure both components will kick in by themselves next time you open up the XAMPP control panel.
3. Test the Connection
Once you are done and everything is running, it’s time to test your local server. For that, open any browser and type in http://localhost/. If everything is fine, you should see the following XAMPP welcome screen:
That’s it, the software is now working properly. Well done!
Installing XAMPP on Mac OS
Getting started with XAMPP on a Mac is even easier. All you need to do is download the .dmg file and open it.
After that, either double click on the XAMPP icon or drag it to your application folder. The program is now installed and you can configure it the same way as described above.
Creating a Database in XAMPP
Like on a web server, the first thing we need in order to install WordPress offline is a MySQL database. Thankfully, we can use phpMyAdmin for that since we installed it during the setup.
You can either get there by using the phpMyAdmin link at the bottom of the XAMPP home screen or go to http://localhost/phpmyadmin directly.
There is also an Admin button in the XAMPP control panel next to MySQL which will take you to the same place.
Setting up a database in XAMPP is basically the same as on any other server with some small differences. To get started, click Databases at the top of the screen to get to this screen.
Here, enter a name for your database under Create a database.
Pick the appropriate collation from the drop-down menu (usually utf8_your_language or, if your language is not available, pick utf8mb4_general_ci).
Then hit Create.
For a local installation that’s all it takes. You don’t necessarily need to set up a password and database user.
However, creating them can be a good idea anyway since using the same database name, username and password as the live environment makes moving back and forth between live site and local installation much easier.
If you do choose to set up a user, click on your newly created database to open it and then choose Privileges at the top.
Pick Add User at the bottom. You will then be asked to provide a username, host and password.
Choose Local for host from the drop-down menu. Everything else is up to your choosing but it’s a good idea to note down the info for later.
Before creating your user by clicking Go at the bottom, make sure the checkbox to grant all privileges for your new database is active.
That’s it for the database, now on to the installation.
Installing WordPress Offline
An offline installation of WordPress is set up basically in the same way as any other installation
The main difference: There is no FTP client involved.
Instead of dialing into your server to upload files, you can just copy them to a location on your hard drive which is much faster.
Inside the XAMPP directory there is a folder called htdocs. It’s here that all your websites get saved.
To set up a new one, all you need to do is access the directory and create a new folder. Name it anything you want, preferably the domain name of your site. In any case, it should be something you can remember since it is part of the browser path to access your local site.
Now, in order to install WordPress offline, download the latest version and unpack it. After that, all you need to do is copy the files inside to your newly created local site directory.
That’s basically it. When you now access http://localhost/yourdirectory the normal WordPress installation wizard should start. You can follow it as you usually would, complete with typing in your database credentials and all.
The only difference is that if you have chosen not to provide a MySQL user and password, in the step where you are asked to input that information, you need to give root as the user and leave the password field empty.
After that, provide a website title, username, password and email as you usually would. Whether or not to check the box which forbids search engines to index your local site is up to you. Since not even Google can access it on your hard drive, it doesn’t really matter.
Just make sure to disable the check box once you decide to move your site to the live server. Otherwise you might be disappointed by your search results and traffic.
Pick Install WordPress and you are done. Well done, you have officially installed WordPress in a local environment!
Learning how to install WordPress offline is an almost mandatory skill for anyone working with the platform professionally.
Being able to set up your website in a local environment allows you to test themes, plugins and website changes without the danger of compromising your live site.
It’s also a quick and free alternative to staging environments that allows you to work on your site independent of an Internet connection.
In addition to that, tools like XAMPP make installing WordPress offline no more complicated than setting it up on a normal server, in some ways even easier.
In this tutorial you have learned how to create you own local testing environment for WordPress websites. You are now free to do anything on your site you would usually do on your live install.
Install themes and plugins, modify the stylesheet, set up custom templates, work with functions.php and whatever your heart desires.
The only difference is that now if something breaks, nobody but you will be affected and you can always go back to a previous version without doing any damage.
Once you are satisfied, you can then move your changes to the live environment. I promise, this one change will revolutionize the way you work with WordPress.
Which tool do you use to install WordPress offline? Any additions or thoughts on the above? Let us know in the comment section below!