Introduction
This guide will walk through the steps needed to setup WordPress on a Windows desktop by installing everything manually, as opposed to using something like WampServer or Xampp. There is nothing wrong with those options and I highly recommend them if you want a convenient solution.
At the time of writing the latest versions are:
- PHP 7.3.7
- MySQL Community Server 8.0.16
- WordPress 5.2.2
Install PHP in Windows
- Download PHP 7. I use the x64 Thread Safe version.
- Unzip it to your target location. Any destination would work. I use
C:\opt\php\
. Your home directory works fine too. - Put the PHP directory in your PATH using the GUI or with
setx PATH %PATH%;C:\opt\php
. - Copy
php.ini-development
sample file tophp.ini
. - Edit
php.ini
and go to theDynamic Extensions
section. - Uncomment the extensions you want to use. Be sure to include the
mysqli
. It shouldn't hurt to turn more on if you are unsure which ones you need. For example:
extension=curl
extension=gd2
extension=mbstring
extension=exif
extension=odbc
extension=mysqli
extension=pdo_mysql
Install MySQL in Windows
- Download MySQL Community Server.
- During install, choose to include MySQL Workbench.
- Choose option to setup as Windows Service.
- Run
services.msc
to manage theMYSQL80
service. Make sure it isRunning
when trying to use the WordPress site.
The next steps for database setup require interaction with the MySQL server that was just installed. You can do this using MySQL Workbench, or using the MySQL Command Line Client. I will provide the command line statement for each step but you can do them in the GUI as well. The command line statements are meant to go in to the MySQL Command Line Client, not the Windows Command Prompt. You could also run the commands as a query in MySQL Workbench.
Create a database
WordPress will need a database to store information. All you need to provide is a name.
CREATE DATABASE mywordpress;
Create a database user
Next you need to create a user that can be used to access the database that was just created. You need to provide a name and password.
CREATE USER nanodano@localhost IDENTIFIED WITH mysql_native_password BY 'mypass';
If you use MySQL workbench to create the new user make sure you
set the auth setting Authentication Type to Standard
instead of the default caching_sha2_password
otherwise PHP7/WordPress
won't be able to connect properly.
Grant user database privileges
After creating the database and the user, the user will need privileges
to modify the database. Grant all privileges on all the tables in the database
by using the following query. You need to specify what privileges (ALL
),
which database (mywordpress
), what tables (*
), and what user (dano@localhost
);
GRANT ALL PRIVILEGES ON mywordpress.* TO nanodano@localhost;
Setup WordPress
Now we're ready to actually run WordPress.
- Download WordPress
- Unzip the files to wherever you want. For example:
C:\Users\NanoDano\mywordpress\
- Open Command Prompt (
cmd.exe
) - Change directories to where WordPress was unzipped.
cd C:\Users\NanoDano\mywordpress
- Run the PHP built-in server.
The safer option is to bind to
localhost
but if you want to share with other people on your network, bind to all interfaces with0.0.0.0
. If you want to share with the internet outside of your network, you will need to setup port forwarding on your router to route external traffic to your machine.
php -S localhost:8000
php -S 0.0.0.0:8000
At this point, PHP should be serving the index.php
of the WordPress site.
Visit it in your browser at http://localhost:8000.
It should prompt you for database information to complete the install.
Pass it localhost
for the server and use the database name, user,
and password that were used in the MySQL setup process.
Conclusion
After following this guide you should have a better idea of how to install and run WordPress on your local Windows machine.