Reasons to run WordPress locally
There are many reasons to want to use WordPress locally. Three use cases immediately come to mind:
-
You want to create something like a private diary, journal or notebook for your own use.
-
Prototype a website before incurring the expense and effort of registering a public domain and engaging a webhosting provider.
-
Have a place to develop and test changes to your website before affecting what the public sees.
In addition, many webmasters & developers find that working on a website located on their PC is much easier and faster.
WordPress is a web application
As a web application, it needs a web server and associated software on which to run. This software must be installed and running on your PC in order for WordPress to work.
This package of software is often referred to as a stack and includes:
-
Web server, often Apache.
-
Database Server, usually MySQL, or more recently, MariaDB.
-
Server side scripting language(s) such as PHP and Perl.
WordPress uses the web server, MSQL/MariaDB server and PHP, so these components must be installed and running.
Step By Step Instructions
-
Download & Install XAMPP
-
Open the XAMPP Control Panel to start the Apache and MySQL servers.
-
Create a database for WordPress to use by clicking on the Admin button for the MySQL server . This will open phpMyAdmin in a browser window. The Databases button is the first button on the left. Click it to go to a window where you can create databases
-
phpMyAdmin allows you to create databases and users. To minimize confusion, I name the database the same as the domain name it’s used with. (In this case, localhost.) If/when you add other domain names to work on separate projects, it’s easier to keep the databases straight if they match the domain names.
-
Also to minimize confusion, I always use a root user account with no password for 1.0.0.127. Since this is a personal development machine, usually in my possession and not accessible from outside, I accept the security risk.
-
If you’ll be using XAMPP frequently, you may want to run Apache and MySQL as services. This eliminates the need to always start them when you want to use them and they’ll always be ready to use. Since my local web development is only part of what I use my PC for, I only start Apache & MySQL when I intend to use them.
-
Unless you intend to allow other developers to access your environment, you should restrict access to Apache, phpMyAdmin and MySQL to only allow connections from 1.0.0.127, your own system.
-
Once XAMPP is up & running and you’ve got a database for WordPress to use, you can install WordPress. The first window confirms that you’ve got a database working with a user that has access. If not, open phpMyAdmin in another window to create the necessary database and user. Once those tasks are completed, you’ll return to the start WordPress installation Confirmation page. Wen ready, you’ll proceed to the page with the list of languages to choose from. a list of languages to use on your website. The WordPress installation is rather boring and will leave you at the home page of the website you’ve just created with a couple of annoying references to this being a useless site and basically forcing you into editing or deleting a blog post it has “helpfully” created or doing some other work so the site doesn’t look like a lame loser. So be prepared to edit any existing blog posts and other riff-raff left behind by the installation process.
Problems You May Encounter
-
If UAC is enabled, it will prevent changes to files under the Program Files folder. I therefore always install XAMPP under C: \xamp
-
If Skype is installed on your PC, by default, it listens on port 80, which obviously will conflict with the Apache web server listening on port 80 for web connections. I don’t use Skype, so I disable it. You may choose to move Skype or Apache to use another port. Whichever you move, you will have to include the new port number when connecting to it. I’ve never run into a conflict with port 433 which Apache uses for https connections. I suppose it could happen but I would leave https on port 433.
-
Depending on its configuration, Windows Firewall may prevent connections to any port on your system. Confirm if Windows Firewall is the problem by turning it off to see if you can access your Apache web server and MySQL database server. If so, go into Windows Firewall configuration to open their ports.