WordPress Local Development on OS X with Valet and Bedrock

Originally published at: https://roots.io/wordpress-local-development-on-os-x-with-valet-and-bedrock/

Laravel’s Valet tool makes spinning up a local development environment quick and painless for OS X users. Valet uses Nginx, PHP 7, along with MariaDB. It can be installed in just a few minutes with Homebrew and Composer. Valet or Trellis We recommend using Trellis to have dev/prod parity, but sometimes you need something quick…

12 Likes

This is pretty awesome! This will be an awesome tool for those clients that don’t have the budget to set up a custom Trellis install. It’s like a light weight, cli based MAMP.

If you already have a local stack of some sort running, you might run into some conflicts with existing packages. Make sure to walk through the steps to remove existing mySQL installs. Pay attention to the notices that Brew displays.

In my case, I had to remove PHP brew uninstall php55 or brew unlink php55 or whatever equivalent you have been using. As well as MySQL, all though this was a little more work. I ran into the following error.

➜  ~ brew install mariadb
==> Downloading https://homebrew.bintray.com/bottles/mariadb-10.1.16.el_capitan.bottle.tar.gz
==> Pouring mariadb-10.1.16.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
    mysql -uroot

To have launchd start mariadb now and restart at login:
  brew services start mariadb
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
🍺  /usr/local/Cellar/mariadb/10.1.16: 573 files, 137.1M

In the end, it required removing my rm /etc/my.cnf file.

If you continue to run into issues I found this helpful link to remove all existing mySQL installs - https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks

Other than this, I was able to get things rolling pretty quickly.

4 Likes

Nice one, wanted to try Valet for a while as Trellis is great but a bit overkill if you want to test something fast like a new plugin/theme or a framework.

Great article thanks, @ben!

I’ve had good results running this setup with Windows 10 as well. MariaDB, PHP7 and Caddy can all be downloaded and added to your PATH.

Does anyone have an optimal Caddyfile for bedrock deployments? I haven’t had a chance to look through all of their docs, but this has worked for me:

localhost:8080
root web/
gzip
fastcgi / 127.0.0.1:9000 php
rewrite {
    if {path} not_match ^\/wp\/wp-admin
    to {path} {path}/ /index.php?_url={uri}
}
tls off
errors visible

I’ve given this a shot an was up and running in minutes. Super helpful for getting a quick instance up and running.

Thanks for the tip. Installed it now. Do not forget to add the required directory to your path before installing valet:
export PATH=$PATH:~/.composer/vendor/bin
I forgot to run a brew services start mariadb so could not connect to database right away. Anf last but not least I got this error;

Uncaught phpmailerException: Invalid address: wordpress@.... But found out it was related to the WordPres 4.6 bug and that the installation did work out.

1 Like

I recently released v1.0 of my valet command for WP-CLI, which complements Laravel Valet and makes spinning up new sites a total breeze. If you’ve never heard of it, it essentially automates the whole process of creating a new local install, that’s ready to use in your browser in a matter of seconds.

Originally it only supported vanilla WP, but with 1.0 support was added for creating new Bedrock installs as well. Support for all other Valet-supported WordPress projects is also in the works (mostly just pending Valet drivers to be merged).

To create a new ready-to-use Bedrock install, simply run:

wp valet new my-project --project=bedrock

With cached dependencies, the install is really fast…

You can install the package w/ WP-CLI right now with

wp package install aaemnnosttv/wp-cli-valet-command:^1.0

Or check it out on GitHub :eyeglasses:

14 Likes

I ran into a similar issue as alkymst when trying to get Valet running on my mac.

I don’t have the exact error/warning anymore but after running brew install mariadb homebrew would state something about running brew unlink mysql to resolve. I also received the same output noted above by alkymst.

I followed the first section: Remove MySQL completely per The Tech Lab from this post: https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks

After running those commands and restarting my machine I was able to brew install mariadb and valet worked like a charm.

1 Like

How do one actually log in to the wordpress dashboard?

I did everything described in the tut and when I spin up the http://new-site.dev, it just says “Just works”. Isn’t the Wordpress already installed? What do I have to do furthermore?
How can I make it available via https/SSL?

Thanks in advance! We love you guys for the awesome work :heart_eyes:

The credentials are admin / admin

1 Like

local macOS Apache was still running and I needed to restart valet then again - wow it works great!

If you want https/ssl, you’ll need to create a certificate for your localhost

This post was helpful.

Basically it follow this guide and then you add the cert location to the browsersync options

1 Like

Has anyone had any luck with changing the max upload size for sites set up with Valet? It seems to be set at 8MB.

Steps I’ve tried:

  1. Editing /usr/local/etc/php/7.0/php.ini
  2. Editing the WordPress function.php file
  3. Last ditch attempt was using various plugins but as expected, they get ignored

Any ideas?

Edit your php.ini:

php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/etc/php/7.0
Loaded Configuration File => /usr/local/etc/php/7.0/php.ini

So then edit the php.ini found there at:

/usr/local/etc/php/7.0/php.ini

and edit

upload_max_filesize = 32M

line and use the limitation needed.

Thanks for posting that up @jasperfrumau. Sadly I’ve already tried this to no avail.

Just installed Valet 2 (released a few days ago) and they’ve switched over from Caddy to Nginx. As a result, I’ve been able to add client_max_body_size 100m; to my global nginx.conf (located at /usr/local/etc/nginx/nginx.conf). Just restart nginx and good to go :slight_smile:

1 Like

Glad to hear that! Having issues with the latest Laravel Valet version and wp valet itself - ticket myself. May be another Valet 2.x issue. Hitting 404s now.

I was having some issues after upgrading but I ended up performing a full restart of the computer and everything worked fine for me after.

Looking at the ticket you linked to, is your URL https://video-tuts.localhost? Did you manually change your domain over to .localhost? I read that you’ll need to manually set that again after the upgrade. Not sure if you did that yet? Also, did you re-park your sites directory?

1 Like