Skip to content
Hosting

Setting Up WordPress on Laravel Homestead: Free Local Development

Laravel Homestead can host WordPress locally for free. This guide explains the setup process, from YAML editing to database configuration.

Setting Up WordPress on Laravel Homestead: Free Local Development

Laravel Homestead isn’t just for Laravel development. It can also provide a reliable, free local environment to develop WordPress sites. For developers juggling both ecosystems, this versatility is a practical advantage.

Homestead is a prepackaged Vagrant box loaded with PHP, MySQL, Nginx, and other essential tools for web development. While traditionally used for Laravel projects, setting up WordPress within Homestead is not only feasible but straightforward. This approach offers a seamless integration for developers who work across both platforms.

Configuring Homestead.yaml for WordPress

The process begins with configuring the Homestead.yaml file, found at ~/.homestead/Homestead.yaml on macOS. This file maps your local domain to the corresponding project folder. Here’s the setup:

wordpress on homestead
Editing the Homestead.yaml file is a key step in setup. — Photo: Negative Space / Pexels
  • - map: somewordpress.dev
  • to: /home/vagrant/Code/somewordpress.dev/public
  • databases:
  • - somesite_db

Spacing in the YAML file is critical. After saving these changes, provision the server using:

cd ~/Homestead
vagrant reload --provision

This step ensures your local environment is updated with the new configuration.

Editing Hosts File and Preparing WordPress

Next, point your browser to the local web server by editing your /etc/hosts file. Add this line:

wordpress on homestead
Installing WordPress in Homestead completes the configuration. — Photo: Pixabay / Pexels

192.168.10.10 somewordpress.dev

With the domain mapped, create a directory at ~/Code/somewordpress.dev/public. This folder will house your WordPress installation. Download the latest WordPress version and extract its contents into the public directory.

Rename wp-config-sample.php to wp-config.php and configure the database settings:

  • define('DB_NAME', 'somesite_db');
  • define('DB_USER', 'homestead');
  • define('DB_PASSWORD', 'secret');

Replace the authentication keys as instructed within the config file. This ensures your installation remains secure.

Testing Your Local WordPress Setup

Finally, the moment of truth: open your browser and visit somewordpress.dev. If the WordPress installation screen appears, your setup is complete. Laravel Homestead is now ready to support your local WordPress development projects.

By leveraging Homestead, developers can unify their workflows across Laravel and WordPress without additional tools or costs. Homestead’s simplicity and flexibility make it a compelling choice for local development.

Related News