I'm using XAMPP on Windows. While it's great, it doesn't help me to create a development WordPress site quickly (like domain.dev
). I had to do many things manually like adding the virtual host configuration, download WordPress and install. When the number of development sites increases, it takes a lot of time. So, I write a batch script to do the job automatically.
Basically, the script does the following:
- Adding domain to the Windows hosts file (so you can run
domain.dev
from your browser) - Adding virtual host configuration to Apache
- Creating database
- Download and installing WordPress
Here is the script:
https://gist.github.com/rilwis/6b3ae9528665dabdbb4eef38b1d303f2
Change the variables at the top of the script to match your system configuration (like installed Apache path, where you put your website, etc.).
To make the script works, you have to:
- Install WP-CLI. See this guide for details.
- Add paths to MySQL and WP-CLI to your system environment variables.
- Add paths to the
vhost.bat
file above to your system environment variables.
When it's done, just open the command line with Admin privileges (right click on the Start button and select Command Prompt (Admin)) and run the following command:
vhost somedomain
Then restart your Apache, and open the browser, type the address somedomain.dev
. Bump, your WordPress website is there! You can try to access the Dashboard with username and password admin
.
Hope this article saves you some time. Feel free to edit it to suit your system (even Linux or Mac). Happy development with Windows, XAMPP and WordPress!
Leave a Reply