# WordPress Local Development on OS X with Valet and Bedrock

**URL:** https://discourse.roots.io/t/wordpress-local-development-on-os-x-with-valet-and-bedrock/7505
**Category:** blog
**Tags:** guide
**Created:** 2016-08-30T00:57:11Z
**Posts:** 36

## Post 1 by @ben — 2016-08-30T00:57:12Z

Originally published at: [https://roots.io/wordpress-local-development-on-os-x-with-valet-and-bedrock/](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…

---

## Post 2 by @alkymst — 2016-08-30T05:24:19Z

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](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.

---

## Post 3 by @darjanpanic — 2016-08-30T11:46:22Z

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.

---

## Post 4 by @Josh_Ellis — 2016-08-30T17:44:34Z

Great article thanks, @ben!

---

## Post 5 by @Luke_Markey — 2016-08-31T02:53:07Z

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
```

---

## Post 6 by @nathobson — 2016-08-31T10:09:36Z

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

---

## Post 7 by @jasperfrumau — 2016-09-06T07:41:21Z

Thanks for the tip. Installed it now. Do not forget to [add the required directory to your path](https://laracasts.com/discuss/channels/laravel/problems-with-valet-installation?page=1) 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.

---

## Post 8 by @aaemnnosttv — 2016-09-23T08:20:18Z

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…

![](https://discourse.roots.io/uploads/default/original/2X/6/6d3bd02c64b2de0f7ed88b48dab97686842326f9.png)

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](https://github.com/aaemnnosttv/wp-cli-valet-command) :eyeglasses:

---

## Post 9 by @bondydaa — 2016-11-01T01:59:10Z

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](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.

---

## Post 10 by @iamchriswick — 2016-11-24T07:19:12Z

How do one actually log in to the wordpress dashboard?

---

## Post 11 by @fabianhenzler — 2016-11-24T20:14:22Z

I did everything described in the tut and when I spin up the [http://new-site.dev](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:

---

## Post 12 by @iamchriswick — 2016-11-25T00:42:33Z

The credentials are admin / admin

---

## Post 13 by @fabianhenzler — 2016-11-25T05:44:12Z

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

---

## Post 15 by @analogmemory — 2016-11-30T07:34:45Z

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

[This post was helpful.](https://laracasts.com/discuss/channels/elixir/laravel-valet-not-playing-nice-with-browsersync/replies/186186)

Basically it follow this [guide](https://certsimple.com/blog/localhost-ssl-fix) and then you add the cert location to the browsersync options

---

## Post 16 by @nathobson — 2016-12-03T15:43:43Z

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?

---

## Post 17 by @jasperfrumau — 2016-12-12T13:50:24Z

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.

---

## Post 18 by @nathobson — 2016-12-12T14:09:50Z

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

---

## Post 19 by @nathobson — 2016-12-12T15:15:25Z

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:

---

## Post 20 by @jasperfrumau — 2016-12-12T15:28:07Z

Glad to hear that! Having issues with the latest Laravel Valet version and wp valet itself - [ticket](https://github.com/aaemnnosttv/wp-cli-valet-command/issues/15#issuecomment-266429781) myself. May be another Valet 2.x issue. Hitting 404s now.

---

## Post 21 by @nathobson — 2016-12-12T16:15:55Z

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?

---

## Post 22 by @jasperfrumau — 2016-12-12T16:39:40Z

Hmm, I set the domain again. No change. Then I restarted once more and then I removed the installation and added a new one and now it seems to load just fine :smile:

---

## Post 23 by @jasperfrumau — 2016-12-12T17:02:27Z

Hmm. home loads and all frontend pages, but now issues with the /wp/ backend pages.

`2016/12/12 20:01:40 [error] 2609#0: *21 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: video-tuts.localhost, request: "GET /wp/wp-login.php HTTP/2.0", upstream: "fastcgi://unix:/Users/jasper/.valet/valet.sock:", host: "video-tuts.localhost"`

Will test some more again tomorrow.

---

## Post 24 by @jasperfrumau — 2016-12-13T02:30:36Z

404s now seem to be related to [this issue](https://github.com/laravel/valet/commit/a501ebcd5b15121068875d5e19019d8881afa29f) with _secure_ urls.

---

## Post 25 by @giacomo.alonzi — 2017-01-13T21:26:22Z

I have this problem, anyone can help me?

```
www wp package install aaemnnosttv/wp-cli-valet-command
Installing package aaemnnosttv/wp-cli-valet-command (dev-master)
Updating /Users/giacomoalonzi/.wp-cli/packages/composer.json to require the package...
Using Composer to install the package...
---
Loading composer repositories with package information
Updating dependencies
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in phar:///usr/local/bin/wp/vendor/composer/composer/src/Composer/Json/JsonFile.php on line 266

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in phar:///usr/local/bin/wp/vendor/composer/composer/src/Composer/Json/JsonFile.php on line 266
```

update:

Set `memory_limit = 512M` in php.ini solved the problem.

update 2:

this  
`wp valet new my-project --project=bedrock`

return me this  
`Don't go anywhere, this should only take a second...`  
`Error: sh: composer: command not found`

in .zshrc I have this  
`alias composer="php /usr/local/bin/composer.phar"`  
`export PATH="$PATH:$HOME/.composer/vendor/bin"`

whats wrong? if i run `composer`in terminal, all works! Thank you!

Update 3:

Ok after this

`curl -sS https://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer`

all works!

---

## Post 27 by @giacomo.alonzi — 2017-01-13T23:25:11Z

[this](https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks) solved all mysql problem error! Thank you! @bondydaa:slight_smile:

---

## Post 28 by @andrew40 — 2017-04-10T18:34:32Z

I have it all installed and successfully pinging \*.dev.

When you install a new project for example as per your article “wp valet new bedrock --project=bedrock”

I am getting

“Error: This does not seem to be a WordPress install.”

If I do a wp core download which it suggests I then get a:

“Error: ‘wp-config.php’ not found.  
Either create one manually or use `wp core config`.”

Now I’m either being dumb here or I’m missing something. I have followed your article to the letter and it all seems to work but creating a new project doesn’t…

Is it expecting a working bedrock installation before I do anything with valet?

---

## Post 29 by @jasperfrumau — 2017-04-12T12:37:24Z

@andrew40 Could be related to johnpbloch/wordpress repo changes. See solution here [Deploy fails : This does not seem to be a WordPress install](https://discourse.roots.io/t/deploy-fails-this-does-not-seem-to-be-a-wordpress-install/9152/2) Perhaps it is your issue with Valet too and in that case you could do the composer part of the solution. Not certain though. But certainly cannot hurt.

---

## Post 31 by @PeterEmil — 2017-09-19T08:37:13Z

& after adding the required directory quit your Terminal and reopen to let it take effect :slight_smile:

---

## Post 32 by @andrew40 — 2017-11-30T14:47:00Z

Got this all installed successfully. I can navigate to bedrock.dev ok but it shows standard ‘It works’ page. I suspect its not directing to /web/. the db is installed correctly and fields populated all ok.

`4	home	http://bedrock.dev/wp	yes`

I note you specify changing the hosts file to:

`Set your site vhost document root to /path/to/site/web/`

How do I do that on a Mac (High Sierra)?

---

## Post 33 by @andrew40 — 2017-11-30T15:24:02Z

I had a power cut! When it came all back on it was all working as expected, which is a bit weird?

So do I have to restart any services when I do this in future bedrock installations…

---

## Post 34 by @erit — 2018-05-25T01:44:58Z

Just some notes on what I did that worked:

## MariaDB

The “uninstall all versions of mysql for a fresh one” solution solved this error as well:  
`Don't go anywhere, this should only take a second... Error: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)`

Here’s what I did:

- Stopped all mysql processes I could by running things like `brew services stop mariadb` and `mysql.server stop`
- `brew remove mysql` and was also prompted to run `brew uninstall --force mysql`
- ran through the first list of commands from [the coderwall link](https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks)
- In addition, had to run: `brew uninstall mariadb`
- couldn’t find mysql with `which mysql` or `ps aux | grep mysqld` after that
- Ran through list of commands in the second list on the coderwall link but the long command produced an error “unkown variable tmpdir”, found solution in comments to run: `mysqld -initialize --verbose --user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp` instead
- Finally ran: `brew install mariadb` (valet needs mariadb specifically, not mysql)

## PHP

Before I knew I had to fix PHP I temporarily increased the memory limit to install the wp-cli valet command, like so: `php -d memory_limit=512M "$(which wp)" package install aaemnnosttv/wp-cli-valet-command:^1.0`

Instead of uninstalling all versions of PHP I made a symlink for php@7 into usr/local/bin. My command ended up looking like this:  
`ln -s /usr/local/Cellar/php@7.0/7.0.30/bin /usr/local/bin/php`  
making a symlink for mariadb did not work since I had multiple running for some reason.

Sometime during the install process I also had stop apache on OSX: `sudo /usr/sbin/apachectl stop`

* * *

After a while valet stopped working and I ran through these steps to get going again:  
[When Valet Stops Working Properly, What Do We Do? | Tom McFarlin](https://tommcfarlin.com/when-valet-stops-working/)

---

## Post 35 by @40Q — 2018-12-18T01:55:55Z

I ran int the same memory problem when trying to install `wp-cli-valet-command`

Having installed php via homebrew I edited `memory_limit = 1024M` in `/usr/local/etc/php/7.3/conf.d/php-memory-limits.ini`, then restart php (in my case, `valet restart`) and, after this, I was able to install this package.

---

## Post 36 by @trainoasis — 2019-06-14T08:16:08Z

`curl -sS https://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer` throws `Could not open input file: $ curl: (23) Failed writing body (0 != 16384)` …
