Laravel Homestead is a prepackaged Vagrant box that provides a development environment for Laravel. It’s packed with PHP, MySQL, Nginx and everything else you need to run a local web server. Homestead is great for developing in Laravel, but can it also work for WordPress? Absolutely!
I’ve been using Homestead for my local WordPress and Laravel development for the past year. While there are many options for developing WordPress sites in a local environment, you can’t go wrong with Homestead. The setup is both powerful and easy to use. Best of all, Laravel Homestead is free.
I’ll show you how to set up your own local WordPress development environment on Laravel Homestead but, first, I recommend you watch my video tutorial on getting started with Laravel Homestead:
Let’s Get Started
First, you’ll want to edit your Homestead.yaml file. If you’re using a Mac, you’ll find this file at ~/.homestead/Homestead.yaml. Once you’ve opened the file in your favorite editor, add the following lines:
– map: somewordpress.dev
to: /home/vagrant/Code/somewordpress.dev/public
databases:
– somesite_db
The yaml file is picky with spacing and tabs so be sure to match what’s already there. After you save the file, you’ll need to provision the server again:
cd ~/Homestead
vagrant reload –provision
This will reload your local development environment with the the new setup for the new local site. Once this is done, you’ll need to edit a local file to tell your browser where to point to. Our end goal is to type somewordpress.dev in the browser and have that route to the local installation of our web server.
You’ll need to edit the /etc/hosts file and add the following line:
192.168.10.10 somewordpress.dev
Next, we’ll install WordPress in Homestead. Make a directory inside your project folder area ~/Code/somewordpress.dev/public. This is where we’ll install WordPress.
Download a fresh copy of WordPress and save the contents inside the public folder. Our web server points to this directory, allowing us to access WordPress via our browser.
Now, we change the name of wp-config-sample.php to wp-config.php and add the following lines for our database:
define(‘DB_NAME’, ‘somesite_db’);
/** MySQL database username */
define(‘DB_USER’, ‘homestead’);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘secret’);
Donโt forget to get your unique auth keys at the URL provided in the config fileand to replace the appropriate lines of your config with your auth keys.
We’ve now reached the moment of truth. Fire up your browser and visit somewordpress.dev. If you see the WordPress installation screen, you’ve successfully installed WordPress on Laravel Homestead.
It’s easy to set up Laravel Homestead for your local WordPress development projects. You can also use Laravel
Your WordPress siteโs performance can be directly tied to your user satisfaction, search engine rankings, and ultimately, your revenue. Yeah, itโs that important. Without proper optimization, your site will get slower over time. However, it […]
Bounce rate is one of the most important metrics to determine the effectiveness and success of your WordPress website. Some sources list the average bounce rate as anywhere from 26% to 70%. But, this will […]
Providing a high-performing website experience to your visitors is essential for growing your business. As such, you probably spend a great deal of time optimizing your page load time to get it as low as […]